A System Monitoring Dashboard
Listing 1. smtp.pl tests outgoing mail through the SMTP server.
#!/usr/bin/perl -w
#
# Title : smtp.pl
# Author : John_Ouellette@yahoo.com
# Files : smtp.pl
# Pupose : Send email through SMTP server
# Called from monitor_smtp.sh
#
# Submit as
use Net::SMTP;
my $rcpt = $ARGV[2] || 'mygroup@somewhere';
my $sender = $ARGV[1] || 'root@host01';
my $host = $ARGV[0];
#Start Script
my $smtp =Net::SMTP->new($host, Debug => 1);
my $input="test msg for server $host";
$smtp->mail("$sender");
$smtp->to("$rcpt");
$smtp->data();
$smtp->datasend("To: $rcpt\n") ;
$smtp->datasend("From: $sender\n") ;
$smtp->datasend("Subject: $host test\n") ;
$smtp->datasend("$input");
$smtp->dataend();
$smtp->quit;
Do I Have That Perl Module Installed?
An easy way to check whether you have any Perl module installed is by issuing this from the command line:
$ perl -e "use Net::SMTP";
If nothing prints, you have that module installed. If you're missing the module, you get an error that looks like this:
$perl -e "use Net::OTHER"; Can't locate Net/OTHER.pm in @INC (@INC contains: /usr/lib/perl5/5.8.3/i386-linux-thread-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at -e line 1. BEGIN failed--compilation aborted at -e line 1.
This error indicates a lack of the module in question.
Finally, we come to our stats script, monitor_stats.pl. This script logs in to each host and runs the commands:
df -k swapon -s top -n 1 | head -n 20 hostname uptime
It then displays the results in a browser (Figure 2) and saves the result in a log, again sorted by date on the filesystem. It serves as a simple dashboard to give quick stats on each server.
The benefit of this monitoring design is threefold:
We have a history of CPU, disk and swap usage, and we easily can pinpoint where problems may have occurred.
Tedious typing to extract this information for each server is reduced. This comes in handy before leaving work to resolve potential problems before getting paged at night.
Management quickly can see how well we're doing.
We are using the insecure rsh protocol in this script to show you how to get this set up quickly, but we recommend that you use SSH with properly distributed keys to gain security.
With the use of this new system monitoring dashboard, my team's productivity has increased and and its confidence in monitoring has soared, because we no longer are wasting time chasing down false positives. A history of system performance has been a real time saver in diagnosing problems. Finally, easy installation allows users with basic skills to conquer a complex system administration problem in one business day.
Resources for this article: /article/8269.
John Ouellette is a system administrator with nine years of experience in Microsoft Windows NT and UNIX. He believes the command line is king and loves chicken parmigiana. He can be reached at john_ouellette@yahoo.com.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- seo services in india
1 hour 33 min ago - For KDE install kio-mtp
1 hour 34 min ago - Evernote is much more...
3 hours 34 min ago - Reply to comment | Linux Journal
12 hours 19 min ago - Dynamic DNS
12 hours 53 min ago - Reply to comment | Linux Journal
13 hours 52 min ago - Reply to comment | Linux Journal
14 hours 42 min ago - Not free anymore
18 hours 44 min ago - Great
22 hours 31 min ago - Reply to comment | Linux Journal
22 hours 39 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?





Comments
Nagios
I believe Nagios already does this.
Also checking the page ...
We have also scripts for monitoring a web server. Additionally to know that the web service is up and running we were interested in knowing that the page haven't had changes, so we did this:
- Precalculated and stored de md5 from the page we want to check
- Every few minutes (crontab line), get the page and calculate the md5 for the page we get and compare it with the precalculated. If they are different, there is a problem.
The calculus is an onliner:
fetch -q -o - http://www.thepage.tocheck | md5
Also, to avoid the problem of installing some modulus in Perl to send email, we use this:
sub send_mail {
# Send email messages using the sendmail process
# parameters:
# $from_address, addres to use in From field
# $subject, Subject for the message
# $body, Message body
# $to_address, address(es) destination for the message
my ( $from_address, $subject, $body, $to_address) = @_;
open(SENDMAIL, "|/usr/lib/sendmail -t") or warn "Cannont open sendmail: $!\n";
print SENDMAIL <<MESSAGE;
To: $to_address
From: $from_address
Subject: $subject
$body
.
MESSAGE
close SENDMAIL;
}
So, not having the module is not a problem for sending emails :)
Sendmail
How would you include you sendmail script in the web_monitor.sh ?
script errors
I get a ": bad interpreter" error when running monitor_web.sh after having configured web servers, email addy and correcting the path to wget. Please advise.
line endings
I had to fix the line endings of the script after downloading it to Windows XP and moving the tgz file to my Debian box. Try
tr -s "\r" "\n" < monitor_web.sh > b && mv b monitor_web.sh;
You'll have to re-enable the executable bit.
bash or ksh ?
is the first line pointing to bash or ksh?
make sure its bash if using linux as most distros don't have ksh by default.
permissions ok?
have you set perms to 755 on the script?