#!/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"; } };
Using Perl to run a ping host check
No TrackBacks
TrackBack URL: http://baldwinsung.com/cgi-bin/mt-tb.cgi/83
Leave a comment