open( FILE, "$main::SPONGDB/$host/history/current" );
while( <FILE> ) {
chomp;
- if( /^status (\d+) (\S+) (green|yellow|red) (.*)$/ ) {
+ if( /^status (\d+) (\S+) (green|yellow|red|purple|clear) (.*)$/ ) {
push( @list,
Spong::History->new( $host, "status", $1, $2, $3, $4 ) );
} elsif( /^ack (\d+) (\S+) (.*)$/ ) {
# + add - adds a specific host group to the instance
#
-# $Id: HostGroups.pm,v 1.10 2000/12/14 21:18:40 sljohnson Exp $
+# $Id: HostGroups.pm,v 1.11 2001/01/10 16:29:41 sljohnson Exp $
use Spong::Host;
use Spong::HostList;
package Spong::HostGroups;
-my %COLORS = ( 'blue', 4, 'red', 5, 'yellow', 3, 'green', 1, 'purple', 2 );
+my %COLORS = ( 'blue', 4, 'red', 5, 'yellow', 3, 'green', 1, 'purple', 2, 'clear', 0 );
# This constructor expects one of four different types of options. Either an
# empty string specifying that no actual hostlist will be loaded, the string
foreach my $cnt ( 0..5 ) {
if( $cnt == 0 ) { print "Key: . = green, ? = purple "; }
if( $cnt == 1 ) { print " Y = yellow, R = red "; }
- if( $cnt == 2 ) { print " B = blue "; }
+ if( $cnt == 2 ) { print " B = blue, o = clear "; }
if( $cnt == 3 ) { print " "x30; }
if( $cnt == 4 ) { print " "x30; }
if( $cnt == 5 ) { print "Group:", " "x24; }
if( $color eq "yellow" ) { print "Y "; }
if( $color eq "red" ) { print "R "; }
if( $color eq "blue" ) { print "B "; }
+ if( $color eq "clear" ) { print "o "; }
} else {
print " ";
}
foreach my $cnt ( 0..4 ) {
if( $cnt == 0 ) { print "Key: . = green, ? = purple "; }
if( $cnt == 1 ) { print " Y = yellow, R = red "; }
- if( $cnt == 2 ) { print " B = blue "; }
+ if( $cnt == 2 ) { print " B = blue, o = clear "; }
if( $cnt == 3 ) { print " "x30; }
if( $cnt == 4 ) { print "Group:", " "x24; }
foreach $service ( @names ) {
if( $color eq "yellow" ) { print "Y "; }
if( $color eq "red" ) { print "R "; }
if( $color eq "blue" ) { print "B "; }
+ if( $color eq "clear" ) { print "o "; }
} else {
print " ";
}
package Spong::HostList;
-my %COLORS = ( 'blue', 4, 'red', 5, 'yellow', 3, 'green', 1, 'purple', 2 );
+my %COLORS = ( 'red', 5, 'blue', 4, 'yellow', 3, 'purple', 2, 'green', 1,
+ 'clear', 0 );
# This constructor expects one of four different types of options. Either an
# empty string specifying that no actual hosts will be loaded, the string
foreach $cnt ( 0..4 ) {
if( $cnt == 0 ) { print "Key: . = green, ? = purple "; }
if( $cnt == 1 ) { print " Y = yellow, R = red "; }
- if( $cnt == 2 ) { print " B = blue "; }
+ if( $cnt == 2 ) { print " B = blue, o = clear "; }
if( $cnt == 3 ) { print " "x30; }
if( $cnt == 4 ) { print "Host:", " "x25; }
foreach $service ( @names ) {
if( $self->color() eq "yellow" ) { print "Y "; }
if( $self->color() eq "red" ) { print "R "; }
if( $self->color() eq "blue" ) { print "B "; }
+ if( $self->color() eq "clear" ) { print "o "; }
} elsif( $format eq "brief" ) {
print $self->color(), "\n";
} elsif( $format eq "standard_table" ) {
if ( ! $main::SERVICELISTFIX ) {
opendir( DIR, "$main::SPONGDB/$host/services" );
while( defined( $_ = readdir( DIR ) ) ) {
- next unless /^(.*)-(green|yellow|red)$/ ;
+ next unless /^(.*)-(green|yellow|red|purple|clear)$/ ;
my( $name, $color ) = ($1, $2);
# A hack to get around a local problem.
}
foreach ( @files ) {
chomp;
- next unless /^(.*)-(green|yellow|red)$/ ;
+ next unless /^(.*)-(green|yellow|red|purple|clear)$/ ;
my( $name, $color ) = ($1, $2);
# A hack to get around a local problem.
} else {
$service->rcolor( $color ); $service->color( $color );
}
+
$service_hash{$name} = $service;
}
}
sub color {
my $self = shift;
- my( %state_hash ) = qw( blue 3 red 4 yellow 2 purple 1 green 0 );
+ my( %state_hash ) = qw( red 5 blue 4 yellow 3 purple 2 green 1 clear 0);
my $state = "green";
foreach $service ( $self->services() ) {
# (2) Added rules based paging (Stephen Johnson Nov 14, 1998)
# (3) Added checks against Acks and downtime (Stephen Johnson Mar 17, 1999)
#
-# $Id: spong-message.pl,v 1.25 2000/12/31 22:59:58 sljohnson Exp $
+# $Id: spong-message.pl,v 1.26 2001/01/10 16:29:41 sljohnson Exp $
use lib "@@LIBDIR@@";
use English;
use POSIX qw(strftime);
+local @con;
my %opt;
@options = ( "help", "host=s", "service=s", "time=i", "color|status=s",
"summary=s", "duration=i", "message=s", "file=s", "debug",
my($color, $host, $service, $time, $summary, $duration) = @ARGV;
if ( ! $color && defined $opt{'color'} ) { $color = $opt{'color'}; }
-if ( $color !~ /red|yellow|green/ ) {
+if ( $color !~ /red|yellow|green|purple|clear/ ) {
&error( "Invalid status color. Must be green, yellow, or red."); exit 1;
}
if ( ! $host && defined $opt{'host'} ) { $host = $opt{'host'}; }
# If we got a match and rule match is first only, exit loop
if ($match and $RULES_MATCH eq 'FIRST-MATCH') {
- &debug("Matched a rule, exiting rules scan");
+ &debug("Matched a rule, exiting rules scan\n\n\n\n\n");
last;
}
# There are one or more update processes that listen for status updates
# from client programs.
-# $Id: spong-server.pl,v 1.36 2000/12/19 22:50:01 sljohnson Exp $
+# $Id: spong-server.pl,v 1.37 2001/01/10 16:29:41 sljohnson Exp $
use lib "@@LIBDIR@@";
};
# Set up the socket to listen to
+ my( $localTimeOut ) = 15 ;
my( $sock, $client );
$sock = IO::Socket::INET->new( Listen => SOMAXCONN,
LocalPort => $main::SPONG_QUERY_PORT,
);
if (! defined $sock ) { die "socket: $!"; }
- my( $next_update ) = time() + (15 * 60);
+ my( $next_update ) = 0;
&debug( "query server socket setup, listening for connections" );
while( 1 ) {
# Update the service list from the database every 15 minutes
- if ( $time >= $next_update ) {
+ if ( time() >= $next_update ) {
+ debug("Scanning for stale data to convert to purple status",5);
foreach $host ( Spong::HostList->new( "all" )->hosts() ) {
foreach $service ( $host->service_names() ) {
- $main::SERVICES{$service}=1;}}
- $next_update =+ 15 * 60;
+ $main::SERVICES{$service}=1;
+ my ($color )=($host->service($service))->color();
+ my ($summary)=($host->service($service))->summary();
+ my ($message)=($host->service($service))->message();
+ my ($stime) = time();
+ my ($hostname)=$host->name();
+ if ( $color eq 'purple' ) {
+ &save_status("status $hostname $service $color $stime $summary"
+ ,"$message") ;
+ }
+ }
+ }
+ $next_update =+ $localTimeOut * 60;
+ } else {
+ &debug(time() . " < $next_update");
}
&error( "save_status: 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" ) {
+ if( $color !~ m/red|yellow|green|purple|clear/ ) {
&error( "save_status: invalid color [$color]" ); return;}
if ( $time =~ /(\d+):(\d+)/ ) { $time = $1; $ttl = $2; }
if( $time !~ m/^\d+$/ ) {
&debug( "[$$] updating status for $host/$service/$color", 3 );
$path = "$SPONGDB/$host/services";
- foreach( "red", "yellow", "green", "purple" ) { unlink "$path/$service-$_"; }
+ foreach( "red", "yellow", "green", "purple", "clear" )
+ { unlink "$path/$service-$_"; }
$data = "timestamp $start $time\n$time $sum\n$message\n";
my($expire) = ($ttl == 0) ? 0 : $time + $ttl;
$data = "$user $service\n$message\n";
$file = "$SPONGDB/$host/acks/" . int(rand($$)) . "-$now-$time";
&save_data( ">>", $file, $data );
+
+ if ( STATUS_HISTORY ) {
+ # Save the status update information
+ $untiltime = POSIX::strftime( "%H:%M, %D", localtime($time) );
+ $data = "timestamp $now $time\ncolor blue\n$now $user ack $service Until $untiltime \nack: $service by $user \n$message\n";
+ &save_data( ">>", "$SpongConf::SPONGDB/$host/history/status/$now-$service", $data);
+
+ }
+
}
# Take the incoming acknowledgment message, run it through some error checking
} elsif ( $SEND_MESSAGE eq "CHANGE" ) {
# If status has changed
my $firstrun = 1;
- foreach my $c ('red','yellow','green') {
+ foreach my $c ('red','yellow','green','clear','purple') {
if( -f "$SPONGDB/$host/$service.$c" ) { $firstrun = 0; }
}
if ( ! -f "$SPONGDB/$host/services/$service.$color"