From 5d61614e18d450c528c80a12160e3a45e8cbfba0 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Mon, 10 Jan 2000 23:35:37 +0000 Subject: [PATCH] Bug with contacts with only delay attribute fixed (contacts repeatedly notified insteast of once). Move np file remove code in spong-server to $SEND_MESSAGE = "RED" routine. It's only need in that routine. --- src/spong-message.pl | 5 +++-- src/spong-server.pl | 41 +++++++++++------------------------------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/spong-message.pl b/src/spong-message.pl index dd8a6e0..6058261 100755 --- a/src/spong-message.pl +++ b/src/spong-message.pl @@ -507,8 +507,9 @@ RULE: # Remove the old npfile and fall thru to send messages unlink $np_file; # If last page time + repeat time still in the future - # or if no delay specified - } elsif ( $pagetime + $repeat > time() || $delay == 0 ) + # or if no repeat specified, or status is not red + } elsif ( $pagetime + $repeat > time() || $repeat == 0 + || $color ne 'red' ) { next; } # next contact else { # Update np-file and fall thru to send message diff --git a/src/spong-server.pl b/src/spong-server.pl index f8f6b11..80f6af9 100755 --- a/src/spong-server.pl +++ b/src/spong-server.pl @@ -12,7 +12,6 @@ # (1) Rewritten so that it answered both updates and queries (Ed Jul 22, 1997) # (2) Added code to handle "*-purple" named status files (Stephen L Johnson Jun 03, 1999) - use lib "@@LIBDIR@@"; use Spong::HostList; @@ -231,7 +230,7 @@ sub listen_for_queries { # updates however, as we need to send back some information. Query # requests are simple one line messages. - my $header = ; chomp $header; $header =~ s/\r//; + my $header = ; chomp $header; my( $query, $hosts, $type, $view, $other ) = ( $header =~ /^(\w+)\s+\[([^\]]*)\]\s+(\w+)\s+(\w+)\b\s*(.*)$/ ); @@ -255,7 +254,6 @@ sub listen_for_queries { if( $query eq "config" ) { &show_config( @args ); } if( $query eq "info" ) { &show_info( @args ); } if( $query eq "service" ) { &show_service( @args, $other ); } - if( $query eq "histservice" ) { &show_hist_service( @args, $other ); } close( CLIENT ); select $output; @@ -320,16 +318,8 @@ sub save_status { # color, then update the history table and state file as well. if( ! -f "$SPONGDB/$host/services/$service-$color" ) { - # Update the history file $data = "status $time $service $color $sum\n"; &save_data( ">>", "$SPONGDB/$host/history/current", $data); - - if ( $STATUS_HISTORY ) { - # Save the status update information - $data = "timestamp $start $time\ncolor $color\n$time $sum\n$message\n"; - &save_data( ">>", "$SPONGDB/$host/history/status/$time-$service", - $data); - } } &debug( "[$$] updating status for $host/$service/$color" ); @@ -607,19 +597,6 @@ sub show_service { } } -sub show_hist_service { - my( $hosts, $type, $view, $other ) = @_; - my( $service, $time ) = split(/ /,$other); - my( $h ); - eval { $h = Spong::HistoryService->new( $hosts, $service, $time ); }; - if ( $h ) { - $h->summary(); - $h->display( $type, $view ); - } else { - print &fmt_error($type,"Invalid request, object $hosts $other does not exist"),"\n"; - } -} - @@ -644,11 +621,6 @@ sub message_user { if ( $cmd eq "status" ) { - # Remove current np files if event is a change in status (i.e. dur = 0) - if ( $duration == 0 ) { - &remove_np_files($host,$service); - } - if ($color eq 'red' && $duration != 0) { if ( -f $smessage ) { &debug("color is red, calling smessage for escalations"); @@ -669,7 +641,16 @@ sub message_user { } else { &error( "could not send message, $smessage not found" ); } - } } elsif ( $SEND_MESSAGE eq "RED-CHANGE" ) { + } + + # Remove current np file if service has recovered + # Normally this would be done in spong-message, but spong-messsage + # is not called when $SEND_MESSAGE = "RED" for recovery events + if ( $duration == 0 && $color ne 'red' ) { + &remove_np_files($host,$service); + } + + } elsif ( $SEND_MESSAGE eq "RED-CHANGE" ) { # If status has changed and either color is red, call spong-message if ( ( -f "$SPONGDB/$host/services/$service-red" or $color eq "red" ) -- 2.30.2