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 || 'mygroup@somewhere'; my $sender = $ARGV || 'root@host01'; my $host = $ARGV; #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 firstname.lastname@example.org.
- Readers' Choice Awards 2013
- Mars Needs Women
- RSS Feeds
- Sublime Text: One Editor to Rule Them All?
- Raspberry Pi: the Perfect Home Server
- December 2013 Issue of Linux Journal: Readers' Choice
- IBM Will Minimize Impact of Future Disasters
- Tech Tip: Really Simple HTTP Server with Python
- Linux Systems Administrator
- Senior Perl Developer
- This should be very helpful
16 min 14 sec ago
- As much as I share your point
2 hours 36 min ago
- So girls had it better ?
6 hours 7 min ago
- Reply to comment | Linux Journal
6 hours 27 min ago
- why is GNOME 3 in the fifth position at 14.1 %?
12 hours 8 sec ago
- Sublime Is Brilliant!
17 hours 2 min ago
17 hours 22 min ago
- Rapid[Disk,Cache] better than native ram caching?
17 hours 47 min ago
- Nothing is perfect
18 hours 36 sec ago
- Mixtapes Community
23 hours 39 min ago