From: Stephen L Johnson Date: Tue, 22 Feb 2000 05:22:36 +0000 (+0000) Subject: added display_problem() to displays problems for Host Groups X-Git-Tag: spong-2_7-alpha5~72 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a290926b41f51dec9ad6a6b74c39660da43ebc;p=spong.git added display_problem() to displays problems for Host Groups --- diff --git a/src/lib/Spong/HostGroups.pm b/src/lib/Spong/HostGroups.pm index 99c235e..e57bba8 100755 --- a/src/lib/Spong/HostGroups.pm +++ b/src/lib/Spong/HostGroups.pm @@ -18,8 +18,6 @@ # + add - adds a specific host group to the instance # -use Data::Dumper; - use Spong::Host; use Spong::HostList; @@ -48,6 +46,7 @@ sub new { } } elsif ( $grps eq "ALL" ) { foreach $group ( keys %main::GROUPS ) { + next if $group eq 'all' && ! $main::HOSTGROUPSALL; my $object = Spong::HostList->new( $group ); if( $object ) { $groups{$group} = $object; } } @@ -276,4 +275,67 @@ sub display_html { } } + +# These methods all display summary information about only those machines +# that are currently registering a problem, or that have services that have +# not been updated (showing purple) - it also relays information about +# services that have been acknowledged. +# +# brief Hostname and "one" color reflecting overall status of the host +# standard Table showing hosts vs services and the state of each service +# full Records for each host showing detailed info about the problems + +sub display_problems { + my( $self, $type, $format ) = @_; + my( $purple, $problem, $problems ); + + $purple = $problems = 0; + $badgroups = new Spong::HostGroups(""); + foreach my $group ( $self->groups() ) { + $problem = 0; + my $badhosts = new Spong::HostList(""); + foreach my $host ( $group->hosts() ) { + if ( $host->has_problem() ) { + $problem = $problems = 1; + $badhosts->add( $host ); + } elsif ( $host->has_color( "purple" )) { + $purple = 1; + } + } + if ( $problem ) { + $badhosts->name($group->name()); + $badgroups->add($badhosts); + } + } + + if ( $problems ) { + foreach my $group ( $badgroups->groups() ) { + my $name = $group->name(); + print "

" + if $type eq "html"; + print "Group: $name\n"; + print "

" if $type eq "html"; + $group->display( $type, $format ); + } + } else { + if( $format eq "full" ) { + if( $purple ) { + print "

" if( $type eq "html" ); + print "No known problems.\n"; + print "" if( $type eq "html" ); + print "

" if( $type eq "html" ); + print "Although some information is out of date which might "; + print "indicate a problem.\n"; + print "" if( $type eq "html" ); + } else { + print "

" if( $type eq "html" ); + print "No current problems.\n"; + print "" if( $type eq "html" ); + } + } + } + +} + + 1;