From 5017edd3aa19fe94202e8845074bcc047262ce2c Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Tue, 19 Dec 2000 22:50:01 +0000 Subject: [PATCH] added code to send message field of status message to spong-message when noficitions are sent --- src/spong-server.pl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/spong-server.pl b/src/spong-server.pl index 3a76c0e..fb214bf 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.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@@"; @@ -593,7 +593,8 @@ sub save_status { # 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. @@ -720,7 +721,7 @@ sub save_page { # 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. @@ -1065,7 +1066,7 @@ sub init_logging { # 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; } @@ -1078,7 +1079,8 @@ sub message_user { # 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; } @@ -1087,7 +1089,8 @@ sub message_user { 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 @@ -1102,7 +1105,8 @@ sub message_user { 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 @@ -1114,12 +1118,14 @@ sub message_user { 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; @@ -1129,13 +1135,14 @@ sub message_user { # 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 { -- 2.30.2