From: Stephen L Johnson Date: Thu, 31 Oct 2002 22:56:23 +0000 (+0000) Subject: Added event and page message processing again (patch by Andrew Ruthven) X-Git-Tag: spong-2_8_0-beta1~58 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79d842ae84d0277caae6753c66def8f42c7281ea;p=spong.git Added event and page message processing again (patch by Andrew Ruthven) --- diff --git a/src/spong-server.pl b/src/spong-server.pl index 634b576..464579a 100755 --- a/src/spong-server.pl +++ b/src/spong-server.pl @@ -6,7 +6,7 @@ # There are one or more update processes that listen for status updates # from client programs. -# $Id: spong-server.pl,v 1.54 2002/08/01 17:14:13 supermathie Exp $ +# $Id: spong-server.pl,v 1.55 2002/10/31 22:56:23 sljohnson Exp $ use lib "@@LIBDIR@@"; @@ -307,6 +307,8 @@ sub listen_for_updates { if( $header =~ /^status\b/ ) { &save_status( $header, $message, $paddr ); } + if( $header =~ /^page\b/ ) { save_page( $header, $message ); } + if( $header =~ /^event\b/ ) { save_event( $header, $message ); } if( $header =~ /^ack-del\b/ ) { &del_ack( $header, $message ); } if( $header =~ /^ack\ / ) { &save_ack( $header, $message ); } # if( $header =~ /^config\b/ ) { &save_config( $header, $message ); } @@ -732,7 +734,7 @@ sub save_event { } if ($main::HOSTS{$host} eq "") { - &error("save_status: undefined host [$host]"); + &error("save_event undefined host [$host]"); return; } @@ -770,19 +772,19 @@ sub save_page { ($cmd, $host, $service, $color, $time, $sum) = ($1, $2, $3, $4, $5, $6); if( $host !~ m/^[a-z0-9_\-\.]+$/ ) { - &error( "save_status: invalid host [$host]" ); return; } + &error( "save_page invalid host [$host]" ); return; } if( $service !~ m/^[a-z0-9_\-\.]+$/ ) { - &error( "save_status: invalid service [$service]" ); return; } - if( $color ne "red" && $color ne "yellow" && $color ne "green" ) { - &error( "save_status: invalid color [$color]" ); return;} + &error( "save_page invalid service [$service]" ); return; } + if( $color !~ m/red|yellow|green|purple|clear/ ) { + &error( "save_page invalid color [$color]" ); return;} if( $time !~ m/^\d+$/ ) { - &error( "save_status: invalid time [$time]" ); return; } + &error( "save_page invalid time [$time]" ); return; } } else { - &error( "save_status: invalid header [$header]" ); return; + &error( "save_page invalid header [$header]" ); return; } if ($main::HOSTS{$host} eq "") { - &error("save_status: undefined host [$host]"); + &error("save_page undefined host [$host]"); return; } @@ -794,18 +796,16 @@ sub save_page { # Save the status information to the history table and state file as well. # Update the history file - if (0) { $data = "page $time $service $color $sum\n"; &save_data( ">>", "$SPONGDB/$host/history/current", $data); # If status history is enabled, save status message for history event if ( $STATUS_HISTORY ) { - # Save the status update information + # Save the page update information $data = "timestamp $start $time\ncolor $color\n$time $sum\n$message\n"; &save_data( ">>", "$SPONGDB/$host/history/status/$time-$service", $data); } - } } @@ -963,7 +963,7 @@ sub del_ack { # Do some checking on the message. If it appears bogus, then just # log a message, and close the connection. - if( $header =~ /^(\S+) ([a-z0-9_\-\.]+)-([a-z0-9_\-\.]+)-(\d+)\s*$/i ) { + if( $header =~ /^(\S+) ([a-z0-9_\-\.]+)-([a-z0-9_\-\.,]+)-(\d+)\s*$/i ) { ($cmd, $host, $service, $end) = ($1, $2, $3, $4); } else { &error( "del_ack: invalid header [$header]" ); return; @@ -1255,7 +1255,7 @@ sub message_user { $message ); } } - } elsif ( $cmd eq "page" && $PAGE_MESSAGE eq 'PAGE' ) { + } elsif ( $cmd eq "page" && uc($PAGE_MESSAGE) eq 'yes' ) { &debug("sending a page message notification",2); &send_message( $host, $service, $color, $time, $sum, $duration, $message );