package Spong::HostList;
+my %COLORS = ( 'blue', 10, 'red', 5, 'yellow', 4, 'green', 3, 'purple', 2 );
+
# This constructor expects one of four different types of options. Either an
# empty string specifying that no actual hosts will be loaded, the string
# "all" to load all the hosts, the string containing a group name that
push( @{$self->{'hostnames'}}, $name );
}
+sub services_color {
+ my( $self, $service ) = @_;
+ my( $color ) = "";
+
+ foreach( $self->hosts() ) {
+ my $servobj = $_->service($service);
+ my $hostcolor = $servobj->color() if $servobj;
+ $color = $hostcolor if $COLORS{$hostcolor} > $COLORS{$color};
+ }
+ return $color;
+}
+
# Display summary. Does both text and html, does rely on both the Host and
# Service objects for some help.
#
# Print the horizontal axis of the table (names of the services)
- print "<table border=1 cellspacing=0 cellpadding=1><tr>";
+ print "<table border=1 cellspacing=0 cellpadding=1";
+ print " bgcolor=" . $main::WWW_TITLE_COLOR if $main::WWW_TITLE_COLOR;
+ print "><tr>";
print "<td align=center width=80 nowrap><b>Host</b></td>\n";
foreach $service ( @names ) {
print "<td align=center valign=bottom width=25>\n";
foreach $host ( $self->hosts() ) {
my $hostname = $host->name();
- my $short = $main::HOSTS{$hostname}->{'display_name'};
- $short = (split( /\./, $hostname ))[0] unless $short;
+ if ( ! $main::WWW_FQDN ) { # If WWW_FQDN not set, use short hostname
+ my $short = $main::HOSTS{$hostname}->{'display_name'};
+ $short = (split( /\./, $hostname ))[0] unless $short;
+ $hostname = $short;
+ }
- print "<tr><td align=left nowrap>\n";
- print "<a href=\"!!WWWSPONG!!/host/$hostname\">$short</a></td>\n";
+ print "<tr><td align=left bgcolor=#ffffff nowrap>\n";
+ print "<a href=\"!!WWWSPONG!!/host/$hostname\">$hostname</a></td>\n";
foreach $service ( @names ) {
my $servobj = $host->service( $service );
my $col = $servobj->color();
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<td align=center><a href=\"!!WWWSPONG!!/service/";
+ print "<td align=center";
+ print " bgcolor=" . $main::WWW_CELL_COLOR
+ if $main::WWW_CELL_COLOR;
+ print "><a href=\"!!WWWSPONG!!/service/";
print "$hostname/$service\">";
my $alt = $servobj->summary();
print "<img src=\"!!WWWGIFS!!/$col.gif\" alt=\"$alt\" border=0>";
print "</td>";
} else {
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<td align=center width=25> - </td>\n";
+ print "<td align=center width=25";
+ print " bgcolor=" . $main::WWW_CELL_COLOR
+ if $main::WWW_CELL_COLOR;
+ print "> - </td>\n";
} else {
- print "<td align=center width=25> </td>\n";
+ print "<td align=center width=25";
+ print " bgcolor=" . $main::WWW_CELL_COLOR
+ if $main::WWW_CELL_COLOR;
+ print "> </td>\n";
}
}
}