Using Perl to run a ping host check

| 0 Comments | 0 TrackBacks
#!/usr/bin/perl use Net::Ping; @servers = ( 'one', 'two', 'three'); foreach (@servers) { $p = Net::Ping->new(); if ($p->ping($_)) { #print $_ . " is alive" . "\n"; $p->close(); } else { open(MAIL, "| /usr/sbin/sendmail -oi -n -t"); print MAIL << EMAIL_TO_USER; To: unix\@whoever.com, unixunix\@whoever.com, From: mon\@whoever.com Subject: MON Alert - Cannot Ping $_ Issue: Cannot Ping $_. Business Impact: $_ may be down and unreachable. Historical Fixes: Console into the server. EMAIL_TO_USER close MAIL; print "Cannont Ping " . $_ . "\n"; } }; 

No TrackBacks

TrackBack URL: http://baldwinsung.com/cgi-bin/mt-tb.cgi/83

Leave a comment

Recent Entries

Test
Test…
I just finished installing Movable Type 4!
Welcome to my new blog powered by Movable Type. This is the first post on my blog and was created…
New design launched using Movable Type
Our web site is sporting a new look and feel thanks to Movable Type and the Professional Template Set.…