# There are one or more update processes that listen for status updates
# from client programs.
-# $Id: spong-server.pl,v 1.53 2002/07/09 22:41:23 sljohnson Exp $
+# $Id: spong-server.pl,v 1.54 2002/08/01 17:14:13 supermathie Exp $
use lib "@@LIBDIR@@";
# that can process the message. Currently valid messages are "status",
# "ack", "config", and "stat".
- if( $header =~ /^status\b/ ) { &save_status( $header, $message ); }
+ if( $header =~ /^status\b/ ) {
+ &save_status( $header, $message, $paddr ); }
if( $header =~ /^ack-del\b/ ) { &del_ack( $header, $message ); }
if( $header =~ /^ack\ / ) { &save_ack( $header, $message ); }
# if( $header =~ /^config\b/ ) { &save_config( $header, $message ); }
# spong-message and let it decide if it should page/email someone...
sub save_status {
- my( $header, $message ) = @_;
+ my( $header, $message, $peer ) = @_;
my( $cmd, $host, $service, $color, $time, $sum, $path, $start, $duration );
my( $ttl ) = 0;
# Do some checking on the message. If it appears bogus, then just
# log a message, and close the connection.
+ if(!defined($peer)) { $peer = ""; }
+ else { $peer = " received from $peer"; }
if( $header =~ /^(\w+) (\S+) (\w+) (\w+) ([:0-9]+) (.*)$/ ) {
($cmd, $host, $service, $color, $time, $sum) = ($1, $2, $3, $4, $5, $6);
if( $host !~ m/^[a-zA-Z0-9_\-\.]+$/ ) {
- &error( "save_status: invalid host [$host]" ); return; }
+ &error( "save_status: invalid host [$host]$peer" ); return; }
if( $service !~ m/^[a-z0-9_\-\.]+$/ ) {
- &error( "save_status: invalid service [$service]" ); return; }
+ &error( "save_status: invalid service [$service]$peer" ); return; }
if( $color !~ m/red|yellow|green|purple|clear/ ) {
- &error( "save_status: invalid color [$color]" ); return;}
+ &error( "save_status: invalid color [$color]$peer" ); return;}
if ( $time =~ /(\d+):(\d+)/ ) { $time = $1; $ttl = $2; }
if( $time !~ m/^\d+$/ ) {
- &error( "save_status: invalid time [$time]" ); return; }
+ &error( "save_status: invalid time [$time]$peer" ); return; }
if( $ttl !~ m/^\d+$/ ) {
- &error( "save_status: invalid time to live [$ttl]" ); return; }
+ &error( "save_status: invalid time to live [$ttl]$peer" ); return; }
} else {
- &error( "save_status: invalid header [$header]" ); return;
+ &error( "save_status: invalid header [$header]$peer" ); return;
}
if ($main::HOSTS{$host} eq "") {
- &error("save_status: undefined host [$host]");
+ &error("save_status: undefined host [$host]$peer");
return;
}