diff options
author | cvs2git <cvs2git> | 2010-12-27 00:04:45 +0000 |
---|---|---|
committer | cvs2git <cvs2git> | 2010-12-27 00:04:45 +0000 |
commit | c82d349f864e6bd9f96fd1156903bc1f7193a203 (patch) | |
tree | e117a87533656110b6acd56fc0ca64289892a9f5 /bin/ping | |
parent | 74e058c8a010ef6feb539248a550d0bb169c1e94 (diff) |
This commit was manufactured by cvs2svn to create tag 'TORRUS_1_0_9'.TORRUS_1_0_9
Diffstat (limited to 'bin/ping')
-rwxr-xr-x | bin/ping | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/bin/ping b/bin/ping deleted file mode 100755 index 605a2047e..000000000 --- a/bin/ping +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/perl - -use Net::Ping; -use Net::SSH qw( ssh_cmd ); -use Email::Send; - -my @other_hosts = ( 'freeside.biz', 'saturn5.com' ); - -my( $machine, @emails ) = @ARGV; -die "no notification email given" unless @emails; - -my $ping = new Net::Ping; # 'icmp'; #requires root - -my $pong = ''; -# can't tcp ping... $ping->ping($machine) and -$pong = eval { ssh_cmd('freeside@'.$machine, 'echo pong') }; -#(command ignored if authorized_keys setup w/command=) - -if ( $@ || $pong !~ /pong/ ) { #houston, we may have a problem - - #warn "can't reach $machine, checking @other_hosts\n"; - - #let's do a sanity check, can we see some other hosts? - exit unless grep $ping->ping($_), @other_hosts; - - #uh-oh, this is bad. - - #warn "checking to see if we've alerted on this recently\n"; - - #but we don't want to be too noisy, have we alerted on this in the last 24h? - my $file = "/tmp/alert-$machine"; - exit if -e $file && -M $file < 1; - - open(FILE, ">>$file"); - print FILE "emailing\n"; - close FILE; - - #warn "emailing alerts\n"; - - foreach my $email ( @emails ) { - - my $message = <<"__MESSAGE__"; -From: support\@freeside.biz -To: $email -Subject: ALERT - $machine - -ALERT: $machine appears to be down. - -__MESSAGE__ - - my $sender = Email::Send->new({mailer => 'SMTP'}); - $sender->mailer_args([Host => 'mail.freeside.biz']); - $sender->send($message); - - } - -} - |