# (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;
# updates however, as we need to send back some information. Query
# requests are simple one line messages.
- my $header = <CLIENT>; chomp $header;
+ my $header = <CLIENT>; chomp $header; $header =~ s/\r//;
my( $query, $hosts, $type, $view, $other ) =
( $header =~ /^(\w+)\s+\[([^\]]*)\]\s+(\w+)\s+(\w+)\b\s*(.*)$/ );
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;
# 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" );
}
}
+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";
+ }
+}
+
my %opt;
my @options = ( "help", "summary:s", "problems:s", "history:s", "host=s",
"services=s", "stats=s", "config=s", "info=s", "service=s",
+ "histservice=s",
"brief", "standard", "full" );
$actionbar = 0;
$opt = 1;
}
+ if ( defined $opt{'histservice'} ) {
+ my( $host, $service, $time ) = split ( ':', $opt{'histservice'} );
+ &histservice( $host, "$service $time" );
+ $opt=1;
+ }
+
if( ! $opt ) { &summary( "all" ); }
exit(0);
if( $cmd =~ m!^/service/(.*)/(.*)$! ) { &service( $1, $2 ); exit; }
+if( $cmd =~ m!^/histservice/(.*)/(.*)/(.*)$! ) { &histservice( $1, "$2 $3" ); exit; }
+
# Need to do something when an invalid request comes through...
exit(0);
&footer();
}
+sub histservice {
+ my ($host, $service, $time ) = @_;
+ my $view = $main::view || "full";
+
+ &header( 0 );
+ print &query( $SPONGSERVER, "histservice", $host, "html", $view, $service,
+ $time );
+ &footer();
+}
+
+
# Just print a little message to stdout showing what valid options are to
# the command line interface to spong, and then exit the program.