# There are one or more update processes that listen for status updates
# from client programs.
-# $Id: spong-server.pl,v 1.35 2000/12/19 22:15:13 sljohnson Exp $
+# $Id: spong-server.pl,v 1.36 2000/12/19 22:50:01 sljohnson Exp $
use lib "@@LIBDIR@@";
# Before we change the state of the database, call message_user()...
$duration = $time - $start;
- &message_user( "status", $host, $service, $color, $time, $sum, $duration );
+ &message_user( "status", $host, $service, $color, $time, $sum, $duration,
+ $message );
# Make sure that this service is registered in our master service list.
# Call message_user()...
# $duration = $time - $start;
- &message_user( "page", $host, $service, $color, $time, $sum );
+ &message_user( "page", $host, $service, $color, $time, $sum, 0, $message );
# Save the status information to the history table and state file as well.
# called with every event that comes in, so it should be somewhat fast.
sub message_user {
- my ( $cmd, $host, $service, $color, $time, $sum, $duration ) = @_;
+ my ( $cmd, $host, $service, $color, $time, $sum, $duration, $message ) = @_;
if (! defined $duration || $duration eq "") { $duration = 0; }
# escalation notifications
if ($color eq 'red' && $duration != 0) {
&debug("color is red, calling smessage for escalations",2);
- &send_message( $host, $service, $color, $time, $sum, $duration );
+ &send_message( $host, $service, $color, $time, $sum, $duration,
+ $message );
return;
}
if ( ! -f "$SPONGDB/$host/services/$service-red"
and $color eq "red" ) {
&debug("change in state to red, messaging a human",2);
- &send_message( $host, $service, $color, $time, $sum, $duration );
+ &send_message( $host, $service, $color, $time, $sum, $duration,
+ $message );
}
# Remove current np file if service has recovered
if ( ( -f "$SPONGDB/$host/services/$service-red" or $color eq "red" )
and ! -f "$SPONGDB/$host/services/$service-$color" ) {
&debug("change in state to/from red, messaging a human",2);
- &send_message( $host, $service, $color, $time, $sum, $duration );
+ &send_message( $host, $service, $color, $time, $sum, $duration,
+ $message );
}
} elsif ( $SEND_MESSAGE eq "CHANGE" ) {
# If status has changed
and ! ($firstrun and $color eq "green" ) ) {
# If this is the first update, don't page on a green status!!
&debug("change in state, messaging a human",2);
- &send_message( $host, $service, $color, $time, $sum, $duration );
+ &send_message( $host, $service, $color, $time, $sum, $duration,
+ $message );
}
}
} elsif ( $cmd eq "page" && $PAGE_MESSAGE eq 'PAGE' ) {
&debug("sending a page message notification",2);
- &send_message( $host, $service, $color, $time, $sum, $duration );
+ &send_message( $host, $service, $color, $time, $sum, $duration,
+ $message );
}
$SIG{'CHLD'} = \&chld_handler;
# spong-message.
sub send_message {
- my ( $host, $service, $color, $time, $sum, $duration ) = @_;
+ my ( $host, $service, $color, $time, $sum, $duration, $message ) = @_;
if ( -f $smessage ) {
my @args;
push @args,$smessage;
if( $debug >= 3 ) { push @args,"--debug"; }
if( $test ) { push @args,"--test"; }
+ if( $message ) { push @args,"--message",$message; }
push @args, $color, $host, $service, $time, $sum, $duration;
system(@args);
} else {