#! /usr/bin/perl -- -*-perl-*-> $LatencyLimit=500.0; # msecs. $FAILFLAG='YES'; # Handle the case when ping returns nothing. foreach $_ (`ping -c 10 -i 2 servername.net`) { $output=$output.$_; ($when)=/time=(\d+\.?\d)\sms/; if ($when < $LatencyLimit && $when > 10.0) {$FAILFLAG='NO';} } if ($FAILFLAG eq 'YES') { open (EMAIL, "|`/usr/sbin/sendmail address1\@email.com address2\@momail.com`"); print EMAIL "From: My Name \ Subject: PING to servername.net fails.\ This is My Name .\ I'm having a network problem. My connection latency is over $LatencyLimit msecs. (or completely fails).\ This situation is so catastophic I had to reset my interface in order to restore normal operation.\ \n"; print EMAIL "$output"; close(EMAIL); }