From: cvs Date: Tue, 7 Dec 1999 07:22:01 +0000 (+0000) Subject: Removed &status function. Replaced it with Spong::Status module. X-Git-Tag: spong-2_6-beta8~12 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=869e708e955810c60476cb60e8d8b3adcfa4726f;p=spong.git Removed &status function. Replaced it with Spong::Status module. --- diff --git a/src/spong-client.pl b/src/spong-client.pl index f1e7c23..e4fd188 100755 --- a/src/spong-client.pl +++ b/src/spong-client.pl @@ -18,6 +18,7 @@ use Sys::Hostname; use Socket; use Spong::Daemon; +use Spong::Status qw(status); srand( time() ^ ($$ + ($$ << 15 )) ); @@ -71,51 +72,6 @@ unlink( "$SPONGTMP/spong-client.pid" ) unless $nosleep; exit(0); -# --------------------------------------------------------------------------- -# &status( SERVERADDR, HOST, SERVICE, COLOR, SUMMARY, MESSAGE ) -# -# This function sends information to the Spong server. It reports the current -# status of a service, and sends along a string of information that might be -# helpful in diagnosing the problem. This code is modeled after the bb -# program, but is a little different in that it handles multi-line messages -# and send over the time as an int, rather then a string. -# --------------------------------------------------------------------------- - -sub status { - my( $addr, $host, $cat, $color, $summary, $message ) = @_; - my( $iaddr, $paddr, $proto, $line, $ip, $ok ); - - if( $addr =~ /^\s*((\d+\.){3}\d+)\s*$/ ) { - $ip = $addr; - } else { - my( @addrs ) = (gethostbyname($addr))[4]; - my( $a, $b, $c, $d ) = unpack( 'C4', $addrs[0] ); - $ip = "$a.$b.$c.$d"; - } - - $iaddr = inet_aton( $ip ) || die "no host: $addr\n"; - $paddr = sockaddr_in( $SPONG_UPDATE_PORT, $iaddr ); - $proto = getprotobyname( 'tcp' ); - - # Set an alarm so that if we can't connect "immediately" it times out. - - $SIG{'ALRM'} = sub { die }; - alarm(30); - - eval <<'_EOM_'; - socket( SOCK, PF_INET, SOCK_STREAM, $proto ) || die "socket: $!"; - connect( SOCK, $paddr ) || die "connect: $!"; - select((select(SOCK), $| = 1)[0]); - print SOCK "status $host $cat $color ", time(), " $summary\n"; - print SOCK "$message\n"; - close( SOCK ) || die "close: $!"; - $ok = 1; -_EOM_ - - alarm(0); - print STDERR scalar localtime, " can't connect to spong server.\n" if ! $ok; -} - # =========================================================================== # Utility functions, and signal handlers...