]> git.etc.gen.nz Git - spong.git/commitdiff
added display_problem() to displays problems for Host Groups
authorStephen L Johnson <sjohnson@monsters.org>
Tue, 22 Feb 2000 05:22:36 +0000 (05:22 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Tue, 22 Feb 2000 05:22:36 +0000 (05:22 +0000)
src/lib/Spong/HostGroups.pm

index 99c235e946f21b3303fdc27480f625833a2f9d16..e57bba886adf9eb40163a5987e65791cd449ac2b 100755 (executable)
@@ -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 "<p><a href=\"$main::WWWSPONG/group/$name\"><b>" 
+            if $type eq "html";
+         print "Group: $name\n";
+         print "</b></a><p>"                   if $type eq "html";
+         $group->display( $type, $format );
+      }
+   } else {
+      if( $format eq "full" ) {
+         if( $purple ) {
+            print "<p><font color=green><b>"       if( $type eq "html" );
+            print "No known problems.\n";
+            print "</b></font>"                    if( $type eq "html" );
+            print "<p><font size=-1 color=purple>" if( $type eq "html" );
+            print "Although some information is out of date which might ";
+            print "indicate a problem.\n";
+            print "</font>"                        if( $type eq "html" );
+         } else {
+            print "<p><font color=green><b>"       if( $type eq "html" );
+            print "No current problems.\n";
+            print "</b></font>"                    if( $type eq "html" );
+         }
+      }
+   }
+
+}
+
+
 1;