# 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@@";
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 ); }
}
if ($main::HOSTS{$host} eq "") {
- &error("save_status: undefined host [$host]");
+ &error("save_event undefined host [$host]");
return;
}
($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;
}
# 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);
}
- }
}
# 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;
$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 );