Thursday, February 25, 2010

Ping Monitoring Over a WAN - Adding Perl Mods

SkyHi @ Thursday, February 25, 2010
A couple of modules that we use in our ping monitoring script are Mail::Sendmail and Net::Ping::External. To install these, use the CPAN shell to search for the available Sendmail mods:

root@srv-1 root # <b>perl -MCPAN -e shell</b>
Warning [/etc/inputrc line 28]: Re-binding char #27 from [F_ViEndInsert]
to meta for [91 49 126] => BeginningOfLine.
cpan shell -- CPAN exploration and modules installation (v1.70)
ReadLine support enabled
cpan> <b>i /Sendmail/</b>
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Sun, 08 Jun 2003 09:14:27 GMT
Distribution C/CY/CYING/Sendmail-Milter-0.18.tar.gz
Distribution D/DR/DREDD/Sendmail-AccessDB-0.07.tar.gz
Distribution M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
Distribution M/MS/MSERGEANT/AxKit-XSP-Sendmail-1.4.tar.gz
Module AxKit::XSP::Sendmail (M/MS/MSERGEANT/AxKit-XSP-Sendmail-1.4.tar.gz)
Module Config::Manager::SendMail (S/ST/STBEY/Config-Manager-1.4.tar.gz)
Module Fatal::Sendmail (A/AS/ASKSH/glist-0.9.17a10.tar.gz)
Module Log::Dispatch::Email::MailSendmail (D/DR/DROLSKY/Log-Dispatch-2.06.tar.gz)
Module Mail::Mailer::sendmail (G/GB/GBARR/MailTools-1.15.tar.gz)
Module Mail::Sendmail (M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz)
Module Mail::Transport::Sendmail (M/MA/MARKOV/Mail-Box-2.042.tar.gz)
Module Sendmail::AccessDB (D/DR/DREDD/Sendmail-AccessDB-0.07.tar.gz)
Module Sendmail::Milter (C/CY/CYING/Sendmail-Milter-0.18.tar.gz)
Module SyslogScan::SendmailLine (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module SyslogScan::SendmailLineClone (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module SyslogScan::SendmailLineFrom (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module SyslogScan::SendmailLineTo (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module SyslogScan::SendmailLineTrans (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module SyslogScan::SendmailUtil (R/RH/RHNELSON/SyslogScan-0.32.tar.gz)
Module Tindermail::Sendmail (Z/ZL/ZLIPTON/
20 items found

Let's install the correct module:

<b>install Mail::Sendmail</b><br />Running install for module Mail::Sendmail<br />Running make for M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz<br />LWP not available<br />CPAN: Net::FTP loaded ok<br />Fetching with Net::FTP:<br /><br />CPAN: Digest::MD5 loaded ok<br />LWP not available<br />Fetching with Net::FTP:<br /><br />CPAN: Compress::Zlib loaded ok<br />Checksum for /root/.cpan/sources/authors/id/M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz ok<br />Scanning cache /root/.cpan/build for sizes<br />Mail-Sendmail-0.79/<br />Mail-Sendmail-0.79/Todo<br />Mail-Sendmail-0.79/README<br />Mail-Sendmail-0.79/MANIFEST<br />Mail-Sendmail-0.79/<br />Mail-Sendmail-0.79/<br />Mail-Sendmail-0.79/Changes<br />Mail-Sendmail-0.79/Makefile.PL<br />Mail-Sendmail-0.79/Sendmail.html<br /> Going to build M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz<br />Checking if your kit is complete...<br />Looks good<br />Writing Makefile for Mail::Sendmail<br />**********************************************************************<br />NOTE<br />----<br />The test ( is a real test for this module: it sends an e-mail.<br />You may want to edit before running it (directly or through<br />make test), so the mail is sent to you. If you also leave my address,<br />the mail goes into a database from which I can get statistics.<br />Read the docs, and have fun...<br />**********************************************************************<br />cp blib/lib/Mail/<br />Manifying blib/man3/Mail::Sendmail.3pm<br />/usr/bin/make  -- OK<br />Running make test<br />PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch"<br />1..2<br />Test Mail::Sendmail 0.79<br />Trying to send a message to the author (and/or whoever if you edited<br />(The test is designed so it can be run by Test::Harness from<br />Edit it to send the mail to yourself for more concrete feedback. If you<br />do this, you also need to specify a different mail server, and possibly<br />a different From: address.)<br />Current recipient(s): 'Sendmail Test <>'<br />ok 1<br />Server set to:<br />Sending...<br />content of $Mail::Sendmail::log:<br />Mail::Sendmail v. 0.79 - Sun Jun  8 14:02:50 2003<br />Date: Sun, 8 Jun 2003 14:02:50 -0700<br />Server: Port: 25<br />From:<br />Subject: Mail::Sendmail version 0.79 test<br />To:<br />Result: 250 Ok: queued as 5F1627FCC<br />ok 2<br />/usr/bin/make test -- OK<br />Running make install<br />Installing /usr/lib/perl5/site_perl/5.8.0/Mail/<br />Installing /usr/man/man3pm/Mail::Sendmail.3pm<br />Writing /usr/lib/perl5/site_perl/5.8.0/i686-linux/auto/Mail/Sendmail/.packlist<br />Appending installation info to /usr/lib/perl5/5.8.0/i686-linux/perllocal.pod<br />/usr/bin/make install  -- OK<br />cpan> <br /></>

The Sendmail module is all happy. Let's grab the Ping test module:

cpan> <b>i /Ping/</b><br />Author          PING ("Ping Liang" <>)<br />Distribution    B/BB/BBB/Net-Ping-2.30.tar.gz<br />Distribution    C/CO/COLINM/Net-Ping-External-0.11.tar.gz<br />Distribution    P/PI/PING/PBJ-JNI-0.1.tar.gz<br />Distribution    R/RC/RCAPUTO/POE-Component-Client-Ping-0.98.tar.gz<br />Distribution    R/RI/RIIKI/Net-Arping-0.02.tar.gz<br />Distribution    T/TE/TEVERETT/Win32-PingICMP-0.02.tar.gz<br />Module          Fwctl::Services::ping (F/FR/FRAJULAC/Fwctl-0.28.tar.gz)<br />Module          HTML::Bricks::Mappings (P/PE/PETERMCD/HTML-Bricks-0.03.tar.gz)<br />Module          Log::Agent::Stamping (M/MR/MROGASKI/Log-Agent-0.304.tar.gz)<br />Module          Net::Arping     (R/RI/RIIKI/Net-Arping-0.02.tar.gz)<br />Module          Net::Gnutella::Packet::Ping (I/IW/IWADE/Net-Gnutella-0.1.tar.gz)<br />Module          Net::IDN::Nameprep::Mapping (M/MI/MIYAGAWA/Net-IDN-Nameprep-0.02.tar.gz)<br />Module          Net::Lyskom::TextMapping (C/CD/CDYBED/Net-Lyskom-1.0.tar.gz)<br />Module          Net::Peep::Client::Pinger (S/ST/STARKY/Net-Peep-<br />Module          Net::Peep::Client::Pinger::Host (S/ST/STARKY/Net-Peep-<br />Module          Net::Ping       (B/BB/BBB/Net-Ping-2.30.tar.gz)<br />Module          Net::Ping::External (C/CO/COLINM/Net-Ping-External-0.11.tar.gz)<br />Module          Nmap::Scanner::Util::PingScanner (M/MA/MAXSCHUBE/Nmap-Scanner-0.01.tar.gz)<br />Module          POE::Component::Client::Ping (R/RC/RCAPUTO/POE-Component-Client<br />-Ping-0.98.tar.gz)<br />Module          VBTK::Wrapper::Ping (B/BS/BSHENRY/VBTK-0.14.tar.gz)<br />Module          Win32::PingICMP (T/TE/TEVERETT/Win32-PingICMP-0.02.tar.gz)<br />22 items found<br />cpan> <br />cpan> <b>install Net::Ping::External</b><br />Running install for module Net::Ping::External<br />Running make for C/CO/COLINM/Net-Ping-External-0.11.tar.gz<br />LWP not available<br />Fetching with Net::FTP:<br /><br />LWP not available<br />Fetching with Net::FTP:<br /><br />Checksum for /root/.cpan/sources/authors/id/C/CO/COLINM/Net-Ping-External-0.11.tar.gz ok<br />Net-Ping-External-0.11/<br />Net-Ping-External-0.11/Changes<br />Net-Ping-External-0.11/<br />Net-Ping-External-0.11/MANIFEST<br />Net-Ping-External-0.11/Makefile.PL<br />Net-Ping-External-0.11/<br />Net-Ping-External-0.11/README<br /> Going to build C/CO/COLINM/Net-Ping-External-0.11.tar.gz<br />Checking if your kit is complete...<br />Looks good<br />Writing Makefile for Net::Ping::External<br />cp blib/lib/Net/Ping/<br />Manifying blib/man3/Net::Ping::External.3pm<br />/usr/bin/make  -- OK<br />Running make test<br />PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch"<br />1..6<br />ok 1<br />ok 2<br />ok 3<br />ok 4<br />ok 5<br />ok 6<br />Running a more verbose test suite.<br />-------------------------------------------------<br />Net::Ping::External version: 0.11<br />6/6 tests passed.<br />Successful tests:<br />use Net::Ping::External qw(ping)<br />ping(host => '')<br />ping(host => '', timeout => 5)<br />ping(host => '')<br />ping(host => '', count => 10)<br />ping(host => '', size => 32)<br />Operating system according to perl: linux<br />Operating system according to `uname -a` (if available):<br />Linux 2.4.20-gentoo-r5 #1 Thu May 22 05:34:28 PDT 2003 i686 <br />Intel(R) Pentium(R) 4 CPU 1.70GHz GenuineIntel GNU/Linux<br />Perl version: This is perl, v5.8.0 built for i686-linux<br />-------------------------------------------------<br />If any of the above tests failed, please e-mail the bits between the dashed<br />lines to This will help me in fixing this code for maximum<br />portability to your platform. Thanks!<br />/usr/bin/make test -- OK<br />Running make install<br />Installing /usr/lib/perl5/site_perl/5.8.0/Net/Ping/<br />Installing /usr/man/man3pm/Net::Ping::External.3pm<br />Writing /usr/lib/perl5/site_perl/5.8.0/i686-linux/auto/Net/Ping/External/.packlist<br />Appending installation info to /usr/lib/perl5/5.8.0/i686-linux/perllocal.pod<br />/usr/bin/make install  -- OK<br />cpan> <br /></>

We heart the CPAN modules system.

Don't rely on this script for production servers unless you know exactly what you are doing, and are sure that this script fits your needs. Do feel free to encorporate bits of the script as you need, or the whole script if you desire. Credit NetAdminToools, though, if you feel like it. :) Please read our terms of use.

There are five parts to this article:
Main Routine
Check/Log Routines
Adding Perl Mods
pf and rf routines