|
|
  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 # perl -MCPAN -e shell
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>
cpan> i /Sendmail/
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/Devel-Tinderclient-1.2.zip)
20 items found
cpan>
|
Let's install the correct module:
install Mail::Sendmail
Running install for module Mail::Sendmail
Running make for M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
LWP not available
CPAN: Net::FTP loaded ok
Fetching with Net::FTP:
ftp://archive.progeny.com/CPAN/authors/id/M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
CPAN: Digest::MD5 loaded ok
LWP not available
Fetching with Net::FTP:
ftp://archive.progeny.com/CPAN/authors/id/M/MI/MIVKOVIC/CHECKSUMS
CPAN: Compress::Zlib loaded ok
Checksum for /root/.cpan/sources/authors/id/M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz ok
Scanning cache /root/.cpan/build for sizes
Mail-Sendmail-0.79/
Mail-Sendmail-0.79/Todo
Mail-Sendmail-0.79/README
Mail-Sendmail-0.79/MANIFEST
Mail-Sendmail-0.79/test.pl
Mail-Sendmail-0.79/Sendmail.pm
Mail-Sendmail-0.79/Changes
Mail-Sendmail-0.79/Makefile.PL
Mail-Sendmail-0.79/Sendmail.html
CPAN.pm: Going to build M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Mail::Sendmail
**********************************************************************
NOTE
----
The test (test.pl) is a real test for this module: it sends an e-mail.
You may want to edit test.pl before running it (directly or through
make test), so the mail is sent to you. If you also leave my address,
the mail goes into a database from which I can get statistics.
Read the docs, and have fun...
**********************************************************************
cp Sendmail.pm blib/lib/Mail/Sendmail.pm
Manifying blib/man3/Mail::Sendmail.3pm
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..2
Test Mail::Sendmail 0.79
Trying to send a message to the author (and/or whoever if you edited test.pl)
(The test is designed so it can be run by Test::Harness from CPAN.pm.
Edit it to send the mail to yourself for more concrete feedback. If you
do this, you also need to specify a different mail server, and possibly
a different From: address.)
Current recipient(s): 'Sendmail Test '
ok 1
Server set to: mail.alma.ch
Sending...
content of $Mail::Sendmail::log:
Mail::Sendmail v. 0.79 - Sun Jun 8 14:02:50 2003
Date: Sun, 8 Jun 2003 14:02:50 -0700
Server: mail.alma.ch Port: 25
From: sendmail@alma.ch
Subject: Mail::Sendmail version 0.79 test
To: sendmail@alma.ch
Result: 250 Ok: queued as 5F1627FCC
ok 2
/usr/bin/make test -- OK
Running make install
Installing /usr/lib/perl5/site_perl/5.8.0/Mail/Sendmail.pm
Installing /usr/man/man3pm/Mail::Sendmail.3pm
Writing /usr/lib/perl5/site_perl/5.8.0/i686-linux/auto/Mail/Sendmail/.packlist
Appending installation info to /usr/lib/perl5/5.8.0/i686-linux/perllocal.pod
/usr/bin/make install -- OK
cpan>
|
The Sendmail module is all happy. Let's grab the Ping test module:
cpan> i /Ping/
Author PING ("Ping Liang" )
Distribution B/BB/BBB/Net-Ping-2.30.tar.gz
Distribution C/CO/COLINM/Net-Ping-External-0.11.tar.gz
Distribution P/PI/PING/PBJ-JNI-0.1.tar.gz
Distribution R/RC/RCAPUTO/POE-Component-Client-Ping-0.98.tar.gz
Distribution R/RI/RIIKI/Net-Arping-0.02.tar.gz
Distribution T/TE/TEVERETT/Win32-PingICMP-0.02.tar.gz
Module Fwctl::Services::ping (F/FR/FRAJULAC/Fwctl-0.28.tar.gz)
Module HTML::Bricks::Mappings (P/PE/PETERMCD/HTML-Bricks-0.03.tar.gz)
Module Log::Agent::Stamping (M/MR/MROGASKI/Log-Agent-0.304.tar.gz)
Module Net::Arping (R/RI/RIIKI/Net-Arping-0.02.tar.gz)
Module Net::Gnutella::Packet::Ping (I/IW/IWADE/Net-Gnutella-0.1.tar.gz)
Module Net::IDN::Nameprep::Mapping (M/MI/MIYAGAWA/Net-IDN-Nameprep-0.02.tar.gz)
Module Net::Lyskom::TextMapping (C/CD/CDYBED/Net-Lyskom-1.0.tar.gz)
Module Net::Peep::Client::Pinger (S/ST/STARKY/Net-Peep-0.4.5.1.tar.gz)
Module Net::Peep::Client::Pinger::Host (S/ST/STARKY/Net-Peep-0.4.5.1.tar.gz)
Module Net::Ping (B/BB/BBB/Net-Ping-2.30.tar.gz)
Module Net::Ping::External (C/CO/COLINM/Net-Ping-External-0.11.tar.gz)
Module Nmap::Scanner::Util::PingScanner (M/MA/MAXSCHUBE/Nmap-Scanner-0.01.tar.gz)
Module POE::Component::Client::Ping (R/RC/RCAPUTO/POE-Component-Client
-Ping-0.98.tar.gz)
Module VBTK::Wrapper::Ping (B/BS/BSHENRY/VBTK-0.14.tar.gz)
Module Win32::PingICMP (T/TE/TEVERETT/Win32-PingICMP-0.02.tar.gz)
22 items found
cpan>
cpan> install Net::Ping::External
Running install for module Net::Ping::External
Running make for C/CO/COLINM/Net-Ping-External-0.11.tar.gz
LWP not available
Fetching with Net::FTP:
ftp://archive.progeny.com/CPAN/authors/id/C/CO/COLINM/Net-Ping-External-0.11.tar.gz
LWP not available
Fetching with Net::FTP:
ftp://archive.progeny.com/CPAN/authors/id/C/CO/COLINM/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/C/CO/COLINM/Net-Ping-External-0.11.tar.gz ok
Net-Ping-External-0.11/
Net-Ping-External-0.11/Changes
Net-Ping-External-0.11/External.pm
Net-Ping-External-0.11/MANIFEST
Net-Ping-External-0.11/Makefile.PL
Net-Ping-External-0.11/test.pl
Net-Ping-External-0.11/README
CPAN.pm: Going to build C/CO/COLINM/Net-Ping-External-0.11.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Net::Ping::External
cp External.pm blib/lib/Net/Ping/External.pm
Manifying blib/man3/Net::Ping::External.3pm
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..6
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
Running a more verbose test suite.
-------------------------------------------------
Net::Ping::External version: 0.11
6/6 tests passed.
Successful tests:
use Net::Ping::External qw(ping)
ping(host => '127.0.0.1')
ping(host => '127.0.0.1', timeout => 5)
ping(host => 'some.non.existent.host')
ping(host => '127.0.0.1', count => 10)
ping(host => '127.0.0.1', size => 32)
Operating system according to perl: linux
Operating system according to `uname -a` (if available):
Linux srv-1.signalq.com 2.4.20-gentoo-r5 #1 Thu May 22 05:34:28 PDT 2003 i686
Intel(R) Pentium(R) 4 CPU 1.70GHz GenuineIntel GNU/Linux
Perl version: This is perl, v5.8.0 built for i686-linux
-------------------------------------------------
If any of the above tests failed, please e-mail the bits between the dashed
lines to colinm@cpan.org. This will help me in fixing this code for maximum
portability to your platform. Thanks!
/usr/bin/make test -- OK
Running make install
Installing /usr/lib/perl5/site_perl/5.8.0/Net/Ping/External.pm
Installing /usr/man/man3pm/Net::Ping::External.3pm
Writing /usr/lib/perl5/site_perl/5.8.0/i686-linux/auto/Net/Ping/External/.packlist
Appending installation info to /usr/lib/perl5/5.8.0/i686-linux/perllocal.pod
/usr/bin/make install -- OK
cpan>
|
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:
Introduction
Main Routine
Check/Log Routines
Adding Perl Mods
pf and rf routines
|
|