From ed0e7d668a77afc3ffec1671b84c8db2f03fc837 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Tue, 19 Dec 2000 20:00:42 +0000 Subject: [PATCH] removed pingecho use and fixed problem with alarm() in the eval{} block --- src/lib/Spong/Network/plugins/check_ping | 53 +++++++++++------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/src/lib/Spong/Network/plugins/check_ping b/src/lib/Spong/Network/plugins/check_ping index b5a8f57..1e99efe 100755 --- a/src/lib/Spong/Network/plugins/check_ping +++ b/src/lib/Spong/Network/plugins/check_ping @@ -20,36 +20,31 @@ sub check_ping { } foreach $host ( @hostlist ) { - if( ! pingecho( $host, 3 ) ) { - # Try again with a IMCP ping, for those goofy machines that don't run - # the echo service... This is a bit slower... Make sure your ping - # program only sends a finite number of pings... - - my $myping = $PING; - my $pingok = 0; - $myping =~ s/HOST/$host/g; - - eval { - local $SIG{'ALRM'} = sub { die }; - alarm(5); - - open( PING, "$myping 2>&1 |") || warn "can't call ping: $!"; - while( ) { - $message .= $_; - if( /bytes from/ ) { $pingok = 1; } - if( /is alive/ ) { $pingok = 1; } - } - - alarm(0); - }; - close PING; - - if( ! $pingok ) { - $color = "red"; - $message .= "\n"; - push( @down, $host ); - } + my $myping = $PING; + my $pingok = 0; + $myping =~ s/HOST/$host/g; + + eval { + local $SIG{'ALRM'} = sub { die }; + alarm(5); + + open( PING, "$myping 2>&1 |") || warn "can't call ping: $!"; + while( ) { + $message .= $_; + if( /bytes from/ ) { $pingok = 1; } + if( /is alive/ ) { $pingok = 1; } + } + + }; + close PING; + alarm(0); + + if( ! $pingok ) { + $color = "red"; + $message .= "\n"; + push( @down, $host ); } + } $summary = "ping failed for " . join( ',', @down ) if $color eq "red"; -- 2.30.2