&debug( "[$$] showing $query information for $hosts [$type:$view]" );
if( $query eq "problems" ) { &show_problems( @args ); }
+# Disabled for now into all of Herbies web enchanges are added
+# if( $query eq "warnings" ) { &show_warnings( @args ); }
if( $query eq "summary" ) { &show_summary( @args ); }
if( $query eq "history" ) { &show_history( @args ); }
if( $query eq "host" ) { &show_host( @args ); }
my( $hosts, $type, $view ) = @_;
Spong::HostList->new( hostlist($hosts) )->display_problems( $type, $view );}
+sub show_warnings {
+ my( $hosts, $type, $view ) = @_;
+ Spong::HostList->new( hostlist($hosts) )->display_problems( $type, $view );
+ Spong::HostList->new( hostlist($hosts) )->display_warnings( $type, $view );}
+
sub show_summary {
my( $hosts, $type, $view ) = @_;
Spong::HostList->new( hostlist( $hosts ) )->display( $type, $view ); }
sub show_host {
my( $hosts, $type, $view ) = @_;
- Spong::Host->new( $hosts )->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts ); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts does not exist"),"\n";
+ }
+}
sub show_services {
my( $hosts, $type, $view ) = @_;
- Spong::Host->new( $hosts )->services()->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts )->services(); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts services does not exist"),
+ "\n";
+ }
+}
sub show_stats {
my( $hosts, $type, $view ) = @_;
- Spong::Host->new( $hosts )->stats_list()->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts )->stats_list(); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts stats does not exist"),
+ "\n";
+ }
+}
sub show_config {
my( $hosts, $type, $view ) = @_;
- Spong::Host->new( $hosts )->config()->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts )->config(); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts config does not exist"),
+ "\n";
+ }
+}
sub show_info {
my( $hosts, $type, $view ) = @_;
- Spong::Host->new( $hosts )->info()->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts )->info(); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts info does not exist"),
+ "\n";
+ }
+}
sub show_service {
my( $hosts, $type, $view, $other ) = @_;
- Spong::Host->new( $hosts )->service( $other )->display( $type, $view ); }
+ my( $h );
+ eval { $h = Spong::Host->new( $hosts )->service($other); };
+ if ( $h ) {
+ $h->display( $type, $view );
+ } else {
+ print &fmt_error($type,"Invalid request, object $hosts $other does not exist"),
+ "\n";
+ }
+}
sub error { warn scalar localtime(), " Error: ", $_[0], "\n"; }
+# Formatting function for query error reports
+sub fmt_error {
+ my( $type, $text ) = @_;
+
+ # Add HTML tags if view is html
+ if ($type eq 'html') {
+ $text = "<b id=red>" . $text . "</b>";
+ }
+
+ return $text;
+}
+
+
# Signal handlers...
sub exit_handler {