#
# History:
# (1) Cleaned up (Ed July 30, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15)
use Spong::Ack;
$_->display( $format, $view );
if( $format eq "text" ) { print "\n"; }
- if( $format eq "html" ) { print "<p>"; }
+ if( $format eq "html" ) { print "<br /><br />"; }
}
}
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
-# $Id: History.pm,v 1.5 2000/12/15 21:01:10 sljohnson Exp $
+# $Id: History.pm,v 1.6 2005/11/15 12:28:32 scriptkiller Exp $
package Spong::History;
$shost = $self->host() if $main::HISTORY_FQDN;
$shost = (split( /\./, $self->host() ))[0] unless $shost;
- print "<tr><td width=5% align=left valign=top>";
+ # this is used to format every second row
+ # to make it better readable
+ if($view eq "contrast") {
+ print " <tr class=\"spong_history_contrast\">\n";
+ }
+ else {
+ print " <tr class=\"spong_history\">\n";
+ }
+
+ print " <td class=\"spong_history_image\">\n";
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<a href=\"" . $main::WWWSPONG . "/histservice/".$self->host()
+ print " <a href=\"" . $main::WWWSPONG . "/histservice/".$self->host()
. "/$service/$time\">" if ($main::STATUS_HISTORY);
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0>";
- print "</a>" if ($main::STATUS_HISTORY);
+ print " <img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />";
+ print "</a>\n" if ($main::STATUS_HISTORY);
} else {
- print "<table width=20 border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} . "\">";
- print "<a href=\"" . $main::WWWSPONG . "/histservice/".$self->host()
- . "/$service/$time\"><font color=\"" . $main::WWW_COLOR{$color}
- . "\">" if ($main::STATUS_HISTORY);
- print " ";
- print "</a>" if $main::STATUS_HISTORY;
- print "</td></tr></table>";
+ print "<table class=\"spong_history_noimage\">\n";
+ print " <tr class=\"spong_history_noimage\">\n";
+ print " <td class=\"spong_background_$color\">\n";
+
+ if($main::STATUS_HISTORY) {
+ print " <a href=\"" . $main::WWWSPONG . "/histservice/".$self->host()
+ ."/$service/$time\">\n";
+ print " <span class=\"spong_color_$color\">\n";
+ print " \n";
+ print " </span>\n";
+ print " </a>\n";
+ }
+
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
}
- print "</td>\n";
- print "<td width=5% align=center>";
+ print " </td>\n";
+ print " <td class=\"spong_history_type\">";
my($type) = substr($self->type,0,1); $type =~ tr/a-z/A-Z/;
print "$type</td>\n";
- print "<td width=10% align=center valign=top>";
- printf ( "%2.2d:%2.2d</td>", $hour, $min );
- print "<td width=15% align=left valign=top>$shost </td>\n";
- print "<td width=15% align=left valign=top>$service</td>\n";
- print "<td width=51% align=left valign=top>$other</td></tr>\n";
+ print " <td class=\"spong_history_time\">";
+ printf ( "%2.2d:%2.2d</td>\n", $hour, $min );
+ print " <td class=\"spong_history_host\">$shost </td>\n";
+ print " <td class=\"spong_history_service\">$service</td>\n";
+ print " <td class=\"spong_history_other\">$other</td>\n";
+ print " </tr>\n";
}
1;
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
use Spong::History;
my( $event, $date );
my( $day ) = 24*60*60;
+ # used to add contrast to every 2nd row in html output
+ my ( $i, $contrast ) = (0, 0);
+
sub bytime { return $b->time() <=> $a->time(); }
foreach $event ( sort bytime $self->events() ) {
my $dstr = POSIX::strftime( "%A, $main::DATEFMT", localtime($event->time()) );
if( $dstr ne $date ) {
- if( $date ne "" ) { print "</table><br>"; }
- print "$dstr\n<hr border=1 noshade>\n";
- print "<table width=100% border=0 cellspacing=1 cellpadding=0>\n";
+ if( $date ne "" ) { print "</table>\n<br />\n"; }
+ print "<div class=\"spong_historylist_date\">$dstr</div>\n";
+
+ # TODO: leave <br /> instead of <hr /> here?
+ # print "<hr class=\"spong_historylist\" />\n";
+
+ print "<br />\n";
+ print "<table class=\"spong_historylist\">\n";
$date = $dstr;
}
- $event->display_html();
+ # format every second row with style-attribute "contrast"
+ # so the table will be much better readable (-> History.pm)
+ if($i % 2) {
+ $contrast="";
+ }
+ else {
+ $contrast="contrast";
+ }
+
+ $event->display_html($contrast);
+ $i++;
}
}
print "</table>\n";
# History
# (1) Created (Dec 27, 1999 Stephen L Johnson)
+# (2) XHTML (Michael Arndt, 2005/11/15)
package Spong::HistoryService;
}
# Overridden html display function
-
sub display_html {
my( $self, $format ) = @_;
my $host = $self->host;
print "<a href=\"!!WWWSPONG!!/service/$host/$name\">\n";
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0>";
+ print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} ;
- print "\"><font color=\"" . $main::WWW_COLOR{$color} . "\">";
- print "___</font></td></tr></table>\n";
+ print "<table class=\"nospacing\">\n";
+ print " <tr>\n";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
}
print "</a>";
} elsif( $format eq "standard_table" ) {
- print "<tr><td align=left valign=top nowrap>\n";
- print "<a href=\"!!WWWSPONG!!/service/$host/$name\">$name</a></td>\n";
- print "<td align=center valign=top>\n";
+
+ # TODO: restore removed styles in <td> etc. ...
+ # print "<table class=\"spong_historyservice\">\n";
+ print " <tr>\n";
+ print " <td>\n";
+ print " <a href=\"!!WWWSPONG!!/service/$host/$name\">$name</a>\n";
+ print " </td>\n";
+ print " <td>\n";
if( $main::WWW_USE_IMAGES == 1 ) {
print "<a href=\"!!WWWSPONG!!/service/$host/$name\">\n";
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0></a>";
+ print " <img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />\n";
+ print "</a>\n";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} . "\">";
- print "<a href=\"!!WWWSPONG!!/service/$host/$name\">";
- print "<font color=\"" . $main::WWW_COLOR{$color} . "\">___</font>";
- print "</a></td></tr></table>\n";
+
+ print "<table class=\"nospacing\">\n";
+ print " <tr>\n";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <a href=\"!!WWWSPONG!!/service/$host/$name\">";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
+ print " </a>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ # print "</table>\n";
}
- print "</td>\n";
- print "<td align=center valign=top nowrap>";
+ print " </td>\n";
+ print " <td>";
if( $d1 == $d2 && $m1 == $m2 && $y1 == $y2 ) {
print POSIX::strftime( "%H:%M", localtime($self->rtime()) ), " ";
print POSIX::strftime( "%D", localtime($self->rtime()) ), " ";
}
- print "</td>\n";
- print "<td align=left valign=top>", $self->summary(), "</td></tr>\n";
+ print " </td>\n";
+ print " <td>", $self->summary(), "</td>\n";
+ print " </tr>\n";
+ print "</table>\n";
+
} elsif( $format eq "standard" ) {
- print "<table width=100% border=1 cellspacing=2 cellpadding=2><tr>\n";
- print "<td width=60 align=center><b>Service</b></td>\n";
- print "<td width=1%> </td>\n";
- print "<td width=60 align=center><b>Updated</b></td>\n";
- print "<td width=100% align=center><b>Summary</b></td></tr>\n";
+
+ # TODO: where's that stuff coming from??
+ print "<table width=\"100%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\"><tr>\n";
+ print "<td width=\"60\" align=\"center\"><b>Service</b></td>\n";
+ print "<td width=\"1%\"> </td>\n";
+ print "<td width=\"60\" align=\"center\"><b>Updated</b></td>\n";
+ print "<td width=\"100%\" align=\"center\"><b>Summary</b></td></tr>\n";
$self->display_html( "standard_table" );
print "</table>\n";
+
} elsif( $format eq "full" ) {
- print "<font size=+2><b>", $self->host(), "/", $self->name();
- print "</b></font>\n";
- print "<table width=100% cellspacing=0 cellpadding=0 border=0>";
- print "<tr><td bgcolor=\"" . $main::WWW_COLOR{$color} . "\"> </td>";
- print "</tr></table><p>";
+ print "<h2>", $self->host(), "/", $self->name();
+ print "</h2>\n";
+
+ print "<table class=\"spong_historyservice\">\n";
+ print " <tr class=\"spong_historyservice\">\n";
+ print " <td class=\"spong_background_$color\"> </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
+ print "<br />\n";
- print "<b>Date:</b> ";
+ print "<span class=\"form_property\">Date:</span> ";
print POSIX::strftime( "%H:%M, %D", localtime($self->rtime()) );
- print "<br><b>Summary:</b> ", $self->summary(), "<br>\n";
- print "<hr noshade><pre>", $self->message(), "</pre>\n";
+ print "<br />\n";
+ print "<span class=\"form_property\">Summary:</span> ", $self->summary(), "<br />\n";
+ print "<hr class=\"spong_historyservice\" />\n";
+ print "<pre>", $self->message(), "</pre>\n";
}
}
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
use Spong::AckList;
use Spong::Ack;
if( $format eq "brief" ) {
my $color = $self->color();
- print "<a href=\"!!WWWSPONG!!/host/$name\">\n";
+ print "<a href=\"!!WWWSPONG!!/host/$name\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">\n";
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0>";
+ print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} ;
- print "\"><font color=\"" . $main::WWW_COLOR{$color} . "\">";
- print "___</font></td></tr></table>\n";
+ print "<table class=\"nospacing\">\n";
+ print " <tr>\n";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
}
print "</a>";
} elsif( $format eq "standard" || $format eq "full" ) {
- print "<font size=+2><b>$name</b></font>\n";
- # This breaks the generic interactive vs non-interactive model
- $self->add_action_bar();
-
- my $color = $self->color();
-
- print "<table width=100% cellspacing=0 cellpadding=0 border=0>";
- print "<tr><td bgcolor=\"" . $main::WWW_COLOR{$color} . "\"> </td>";
- print "</tr></table><p>";
-
- my $acklist = $self->acks();
- if( $acklist ) {
- print "<font size=+1><b>Acknowledgments</b></font><br><hr>\n";
- $acklist->display( "html", $format ); }
-
- my $servicelist = $self->services();
- if( $servicelist ) {
- print "<p><font size=+1><b>Services</b></font><br><hr>\n";
- $servicelist->display( "html", $format ); }
-
- my $info = Spong::Info->new( $self->name() );
- if( $info ) {
- print "<p><font size=+1><b>Information</b></font><br><hr>\n";
- $info->display( "html", $format ); }
-
- my $historylist = $self->history();
- if( $historylist ) {
- print "<p><font size=+1><b>History</b></font><br><hr>\n";
- $historylist->display( "html", $format ); }
+ print "<h2>$name</h2>\n";
+
+ # This breaks the generic interactive vs non-interactive model
+ $self->add_action_bar();
+
+ my $color = $self->color();
+
+ print "\n";
+ print "<table class=\"spong_host_colorbar\">\n";
+ print " <tr class=\"spong_host_colorbar\">\n";
+ print " <td class=\"spong_background_$color\"> </td>\n";
+ print " </tr>\n";
+ print "</table>\n\n";
+
+
+ my $acklist = $self->acks();
+ if( $acklist ) {
+ print "<h3>Acknowledgments</h3>\n";
+ print "<hr class=\"spong_host_sub\" />\n";
+ $acklist->display( "html", $format );
+ print "<br />\n";
+ }
+
+ my $servicelist = $self->services();
+ if( $servicelist ) {
+ print "<h3>Services</h3>\n";
+ print "<hr class=\"spong_host_sub\" />\n";
+ $servicelist->display( "html", $format );
+ print "<br />\n";
+ }
+
+ my $info = Spong::Info->new( $self->name() );
+ if( $info ) {
+ print "<h3>Information</h3>\n";
+ print "<hr class=\"spong_host_sub\" />\n";
+ $info->display( "html", $format );
+ print "<br />\n";
+ }
+
+ my $historylist = $self->history();
+ if( $historylist ) {
+ print "<h3>Weekly History</h3>\n";
+ print "<hr class=\"spong_host_sub\" />\n";
+ $historylist->display( "html", $format );
+ print "<br />\n";
+ }
}
}
my $color = $self->color();
my $name = $self->name();
my $message = &escape( "Host: $name, " . $self->_problem_message() );
- my $spacer = "      ";
+ my $spacer = " ";
my( $prob, $summ, $time ) = $self->_problem_service();
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0>";
- print "<b><a href=\"!!WWWSPONG!!/host/$name\">$name</a></b><br> ";
+ print "<img src=\"!!WWWGIFS!!/$color.gif\" name=\"$color\" /> ";
+ print "<a class=\"spong_host_problem_host\" href=\"!!WWWSPONG!!/host/$name\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">$name</a><br />\n";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} ;
- print "\"> </td><td> ";
- print "<b><a href=\"!!WWWSPONG!!/host/$name\">$name</a></b>";
- print "</td></tr></table>\n";
+ print "<table class=\"spong_host_problems\">\n";
+ print " <tr>\n";
+# does not look very nice:
+# print " <td class=\"spong_background_$color\"> </td>\n";
+ print " <td class=\"spong_host_problems\"> ";
+ print " <a href=\"!!WWWSPONG!!/host/$name\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">$name</a>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
}
- if( $prob eq "multiple problems" ) {
- print "$spacer problem: $prob<br>\n";
+ if( $prob eq "multiple" ) {
+ print "$spacer problem: $prob<br />\n";
} else {
- print "$spacer problem: <a href=\"!!WWWSPONG!!/service/$name/";
- print "$prob\">$prob</a><br>";
+ print "$spacer problem: <a href=\"!!WWWSPONG!!/service/$name/";
+ print "$prob\" target=\"$main::WWW_MAIN_DISPLAY_FRAME\">$prob</a><br />";
}
- # if( $summ ) { print "$spacer summary: $summ<br>\n"; }
+ # if( $summ ) { print "$spacer summary: $summ<br />\n"; }
if( $time ) {
print "$spacer updated: ";
- print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($time) ), "<br>\n";
+ print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($time) ), "<br />\n";
}
if ( $main::WWWCONTACT ) {
print "$spacer contact: ";
- print "<a href=\"$main::WWWCONTACT?host=$name&message=$message\">";
+ print "<a href=\"$main::WWWCONTACT?host=$name&message=$message\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">";
print "$human</a>\n";
}
&main::error("add_action_bar: $@");
&main::error($main::WWW_PROB_ACTIONBAR);
} else {
- print "$spacer $text<br>\n";
+ print "$spacer $text<br />\n";
}
}
- print "<p>\n";
+ print "<br />\n";
}
} elsif( $#problist == 0 ) {
return( $problist[0], $summary, $probtime );
} else {
- return( "multiple problems", "", $probtime );
+ return( "multiple", "", $probtime );
}
}
my $name = $self->name();
my $message = &escape( "Host: $name, " . $self->_problem_message() );
- print "<hr>";
- print "<a href=\"telnet://$name\">Connect</a> || ";
- print "<a href=\"$main::WWWACK/$name\">Acknowledge Problem</a> ";
+
+# TODO: config option to remove "WWWACK"-link
+#
+ print "<hr />\n";
+# nobody uses telnet anymore, consider removing this completely:
+# print "<a href=\"telnet://$name\">Connect</a> || ";
+ print "<a href=\"$main::WWWACK/$name\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">Acknowledge Problem</a> ";
if( $main::WWWCONTACT ) {
- print "|| <a href=\"$main::WWWCONTACT?host=$name&message=$message\">";
- print "Contact Help</a>";
+ print "|| <a href=\"$main::WWWCONTACT?host=$name&message=$message\" ".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">";
+ print "Contact Help</a>\n";
}
if ($main::WWW_ACTIONBAR_CUSTOM) {
}
}
- print "<hr>\n";
+ print "<hr />\n";
}
sub escape {
# + groups - used to get back a generic list of groups that are stored
# + add - adds a specific host group to the instance
#
+# History:
+# (1) XHTML (Michael Arndt, 2005/11/15)
-# $Id: HostGroups.pm,v 1.11 2001/01/10 16:29:41 sljohnson Exp $
+# $Id: HostGroups.pm,v 1.12 2005/11/15 12:28:32 scriptkiller Exp $
use Spong::Host;
use Spong::HostList;
# Print the header of the table.
- print "<table border=1 cellspacing=0 cellpadding=1";
- print " bgcolor=" . $main::WWW_TITLE_COLOR if $main::WWW_TITLE_COLOR;
- print ">\n <tr>\n";
- print " <td align=center>Host Group</td>\n";
- print " <td>Status</td>\n";
- print " </tr>\n";
+ print "<table class=\"spong_hostgroups\">\n";
+ print " <tr class=\"spong_hostgroups\">\n";
+ print " <td class=\"spong_hostgroups\">Host Group</td>\n";
+ print " <td class=\"spong_hostgroups\">Status</td>\n";
+ print " </tr>\n";
# Now for each group, go through and find out overall status of that
# host.
my $name = $group->name();
my $grname = $main::GROUPS{$name}->{'name'};
- print " <tr>\n";
- print " <th align=left bgcolor=#ffffff nowrap><a href=\"!!WWWSPONG!!/group/$name\" target=\"view\">$grname</a></th>\n";
+ print " <tr class=\"spong_hostgroups\">\n";
+ print " <th class=\"spong_hostgroups\"><a href=\"!!WWWSPONG!!/group/$name\" target=\"_top\">$grname</a></th>\n";
my ($color);
foreach $service ( @names ) {
if( $color ) {
if( $main::WWW_USE_IMAGES == 1 ) {
- print " <td align=center";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print ">";
- my $alt = "";
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$alt\" border=0>";
- print "";
+ print " <td class=\"spong_hostgroups\">\n";
+ my $alt = "";
+ print " <img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$alt\" />&nbps;";
+
} else {
- print " <td align=center bgcolor=\"";
- print $main::WWW_COLOR{$color} . "\" width=25>";
- print "<font color=\"" . $main::WWW_COLOR{$color} . "\">";
- print "___</font>";
+ print " <td class=\"spong_hostgroups\">\n";
+ print " <span class=\"spong_text_$color\">___</span>\n";
}
- print "</td>\n";
+ print " </td>\n";
} else {
if( $main::WWW_USE_IMAGES == 1 ) {
- print " <td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> - </td>\n";
+ print " <td class=\"spong_hostgroups\"> - </td>\n";
} else {
- print " <td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> </td>\n";
+ print " <td class=\"spong_hostgroups\"> </td>\n";
}
}
- print " </tr>\n";
+ print " </tr>\n";
}
print "</table>\n";
# Print the horizontal axis of the table (names of the services)
- 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 Group</b></td>\n";
+ print "<table class=\"spong_hostgroups\">\n";
+ print " <tr class=\"spong_hostgroups\">\n";
+ print " <th class=\"spong_hostgroups_left\">Host Group</th>\n";
foreach $service ( @names ) {
- print "<td align=center valign=bottom width=25>\n";
- print "<font size=-1><a href=\"!!WWWSPONG!!/help/$service\">";
- print "$service</a></font></td>\n";
+ print " <th class=\"spong_hostgroups_service\">\n";
+ print " <a href=\"!!WWWSPONG!!/help/$service\" title=\"Help\">";
+ print "$service</a>\n";
+ print " </th>\n";
}
- print "</tr>\n\n";
+ print " </tr>\n\n";
# Now go through each host group, and fill in the table.
my $name = $group->name();
my $grname = $main::GROUPS{$name}->{'name'};
- print "<tr><td align=left bgcolor=#ffffff nowrap>\n";
- print "<a href=\"!!WWWSPONG!!/group/$name\" target=\"view\">$grname</a></td>\n";
+ print " <tr class=\"spong_hostgroups\">\n";
+ print " <td class=\"spong_hostgroups_left\">\n";
+ print " <a href=\"!!WWWSPONG!!/group/$name\" target=\"_top\">$grname</a>\n";
+ print " </td>\n";
foreach $service ( @names ) {
my $color = $group->services_color( $service );
if( $color ) {
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<td align=center";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print ">";
- my $alt = "";
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$alt\" border=0>";
- print "";
+ print " <td class=\"spong_hostgroups_service\">\n";
+ print " <img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />\n";
} else {
- print "<td align=center bgcolor=\"";
- print $main::WWW_COLOR{$color} . "\" width=25>";
- print "<font color=\"" . $main::WWW_COLOR{$color} . "\">";
- print "___</font>";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
}
- print "</td>";
+ print " </td>\n";
} else {
- if( $main::WWW_USE_IMAGES == 1 ) {
- print "<td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> - </td>\n";
+ if( $main::WWW_USE_IMAGES == 1 ) {
+ print " <td class=\"spong_hostgroups_service\"> - </td>\n";
} else {
- print "<td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> </td>\n";
+ print " <td class=\"spong_hostgroups_service\"> </td>\n";
}
}
}
+
+ print " </tr>\n";
+
}
- print "</tr></table>";
+ print "</table>\n";
} elsif( $format eq "full" ) {
# Display the host group table
# print "<a href=\"$main::WWWSPONG/group/$name\">";
- print "<strong>Group - $grname</strong>";
+ print "\n<div class=\"spong_hostgroups_groupname\">Group - $grname</div><br />\n";
# print "</a>\n";
$group->display_html("standard");
- print "\n<HR>\n";
+ print "\n<hr />\n";
}
}
}
if ( $problems ) {
foreach my $group ( $badgroups->groups() ) {
my $name = $main::GROUPS{$group->name()}->{'name'};
- print "<b>"
- if $type eq "html";
- print "<strong>Group: $name</strong>\n";
- print "</b><p>" if $type eq "html";
+ print "<div class=\"spong_hostgroups_problems_groupname\">Group: $name</div>\n";
+ print "<p>\n" if $type eq "html";
$group->display( $type, $format );
- print "<hr align=left width=25%>\n";
+ print "</p>\n";
+ print "<hr class=\"spong_hostgroups_problems\" />\n";
}
} 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" );
- }
+ output_problems($purple, $type);
}
}
}
+sub output_problems {
+ my $purple=shift;
+ my $type=shift;
+
+ if( $purple ) {
+ print "<p class=\"spong_hostgroups_no_problems\">\n"
+ if( $type eq "html" );
+
+ print "No known problems.\n";
+
+ print "</p>\n"
+ if( $type eq "html" );
+ print "<p class=\"spong_hostgroups_outdated\">"
+ if( $type eq "html" );
+
+ print "Although some information is out of date which might ";
+ print "indicate a problem.\n";
+
+ print "</p>\n"
+ if( $type eq "html" );
+
+ }
+ else {
+ print "<p class=\"spong_hostgroups_no_problems\">"
+ if( $type eq "html" );
+
+ print "No current problems.\n";
+
+ print "</p>\n"
+ if( $type eq "html" );
+ }
+
+}
# This displays a summary of all the hosts in this list in an WML format
# suitable for displaying on WAP enabled devices
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
use Spong::Host;
}
-
# Get/Set methods, hostnames() is a little fancy in that it return a list
# rather then just the list reference (easier for others to deal with). The
# hosthash function returns a reference however.
sub sorted_hostnames { my $var = 'sorted_hostnames';
if( defined $_[1] ) { $_[0]->{$var} = $_[1]; } return @{$_[0]->{$var}}; }
+
# Some specific functions that get at and manipulate the data in the instance
# vars in more convenient ways
return @tmp;
}
-sub sorted_hosts {
+sub sorted_hosts {
my $self = shift;
my( @tmp );
return @tmp;
}
+
sub add {
my( $self, $host ) = @_;
my $name = $host->name();
push( @{$self->{'hostnames'}}, $name );
push( @{ $self->{'sorted_hostnames'} }, $name);
$self->{'sorted_hostnames'} = [ sort byname @{ $self->{'sorted_hostnames'} } ];
+
+
}
# Calculate summary color for a service
# Now go through each host, and fill in the table.
- foreach $host ( $self->hosts() ) {
+ foreach $host ( $self->sorted_hosts() ) {
print substr( $host->name(), 0, 29 );
print " "x(30-length(substr($host->name(), 0, 29)));
foreach $service ( @names ) {
# of the problem services, date/time the problem occurred, and contact
# information (as well as acknowledgments if they are available).
- foreach $host ( $self->hosts() ) {
+ foreach $host ( $self->sorted_hosts() ) {
$host->display_problem( "text" ); print "\n";
}
} elsif( $format eq "brief" ) {
# line of the current status of the host. The consists of the overall
# status color and the host name.
- foreach $host ( $self->hosts() ) {
+ foreach $host ( $self->sorted_hosts() ) {
printf "%-6s %s\n",$host->color(),$host->name();
}
sub display_html {
my( $self, $format ) = @_;
+ # output only the names of the hosts,
+ # no other information like services etc.
+ if($format eq "names_only" ) {
+
+ my $host;
+
+ print "<table class=\"spong_host_names_only\">\n";
+ foreach $host ( $self->hosts() ) {
+ my $hostname = $host->name();
+ # Use display-name attrib if defined
+ my $display = $main::HOSTS{$hostname}->{'display_name'};
+ if ( ! $display ) {
+ # Otherwise use the hostname if $WWW_FQDN or short name
+ $display = $main::WWW_FQDN ? $hostname :
+ (split( /\./, $hostname ))[0];
+ }
+ print " <tr class=\"spong_host_names_only\">\n";
+ print " <td class=\"spong_host_names_only\">\n";
+ print " <a href=\"!!WWWSPONG!!/host/$hostname\"".
+ "target=\"$main::WWW_MAIN_DISPLAY_FRAME\">$display</a>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ }
+ print "</table>\n";
+ }
+
if( $format eq "standard" ) {
my( %services, $host, $service, @names );
if( grep( /^ping$/, (@s) ) ) { push( @names, "ping" ); }
foreach $service ( sort (@s) ) {
push( @names, $service ) unless $service eq "ping"; }
+
# Print the horizontal axis of the table (names of the services)
-
- 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";
+
+ print "<table class=\"spong_host\">\n";
+ print " <tr class=\"spong_host\">\n";
+ print " <th class=\"spong_host\">Host</th>\n";
foreach $service ( @names ) {
- print "<td align=center valign=bottom width=25>\n";
- print "<font size=-1><a href=\"!!WWWSPONG!!/help/$service\">";
- print "$service</a></font></td>\n";
+ print " <th class=\"spong_host_service\">\n";
+ print " <a href=\"!!WWWSPONG!!/help/$service\">$service</a>\n";
+ print " </th>\n";
}
- print "</tr>\n\n";
+ print " </tr>\n\n";
# Now go through each host, and fill in the table.
$display = $main::WWW_FQDN ? $hostname :
(split( /\./, $hostname ))[0];
}
- print "<tr><td align=left bgcolor=#ffffff nowrap>\n";
- print "<a href=\"!!WWWSPONG!!/host/$hostname\">$display</a></td>\n";
+ print " <tr class=\"spong_host\">\n";
+ print " <td class=\"spong_host\">\n";
+ print " <a href=\"!!WWWSPONG!!/host/$hostname\">$display</a>\n";
+ print " </td>\n";
foreach $service ( @names ) {
my $servobj = $host->service( $service );
my $col = $servobj->color();
if( $main::WWW_USE_IMAGES == 1 ) {
- 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 "</a>";
+ print " <td class=\"spong_host_service\">\n";
+ print " <a href=\"!!WWWSPONG!!/service/$hostname/$service\">";
+ my $alt = $servobj->summary();
+ print "<img src=\"!!WWWGIFS!!/$col.gif\" alt=\"$alt\" title=\"$alt\" />";
+ print " </a>\n";
} else {
- print "<td align=center bgcolor=\"";
- print $main::WWW_COLOR{$col} . "\" width=25>";
- print "<a href=\"!!WWWSPONG!!/service/$hostname/$service\">";
- print "<font color=\"" . $main::WWW_COLOR{$col} . "\">";
- print "___</font></a>";
+ print " <td class=\"spong_background_$col\">\n";
+ print " <a href=\"!!WWWSPONG!!/service/$hostname/$service\">";
+ print " <span class=\"spong_text_$col\">";
+ print "___";
+ print " </span>\n";
+ print " </a>\n";
}
- print "</td>";
+ print " </td>\n";
} else {
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> - </td>\n";
+ print " <td class=\"spong_host_service\">";
+ print " - </td>\n";
} else {
- print "<td align=center width=25";
- print " bgcolor=" . $main::WWW_CELL_COLOR
- if $main::WWW_CELL_COLOR;
- print "> </td>\n";
+ print " <td class=\"spong_host_service\">";
+ print " </td>\n";
}
}
}
- }
- print "</tr></table>";
+
+ print " </tr>\n";
+
+ }
+
+ print "</table>\n";
} elsif( $format eq "full" ) {
}
}
+
# 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
if( $problem ) {
$badhosts->display( $type, $view );
} else {
- if( $view 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" );
+
+ if( $view eq "full" ) {
+ Spong::HostGroups::output_problems($purple, $type);
}
- }
}
}
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
package Spong::Service;
print "<a href=\"!!WWWSPONG!!/service/$host/$name\">\n";
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0>";
+ print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" />\n";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} ;
- print "\"><font color=\"" . $main::WWW_COLOR{$color} . "\">";
- print "___</font></td></tr></table>\n";
+ print "<table class=\"nospacing\">\n";
+ print "<tr>\n";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
}
print "</a>";
} elsif( $format eq "standard_table" ) {
- print "<tr><td align=left valign=top nowrap>\n";
- print "<a href=\"!!WWWSPONG!!/service/$host/$name\">$name</a></td>\n";
- print "<td align=center valign=top>\n";
+ print " <tr class=\"spong_service\">\n";
+ print " <td class=\"spong_service\">\n";
+ print " <a href=\"!!WWWSPONG!!/service/$host/$name\">$name</a>\n";
+ print " </td>\n";
+
+ print " <td class=\"spong_service_image\">\n";
if( $main::WWW_USE_IMAGES == 1 ) {
- print "<a href=\"!!WWWSPONG!!/service/$host/$name\">\n";
- print "<img src=\"!!WWWGIFS!!/$color.gif\" alt=$color border=0></a>";
+ print " <a href=\"!!WWWSPONG!!/service/$host/$name\">\n";
+ print " <img src=\"!!WWWGIFS!!/$color.gif\" alt=\"$color\" /></a>\n";
} else {
- print "<table border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} . "\">";
- print "<a href=\"!!WWWSPONG!!/service/$host/$name\">";
- print "<font color=\"" . $main::WWW_COLOR{$color} . "\">___</font>";
- print "</a></td></tr></table>\n";
+
+ print "<table class=\"nospacing\">\n";
+ print " <tr>\n";
+ print " <td class=\"spong_background_$color\">\n";
+ print " <span class=\"spong_text_$color\">";
+ print "___</span>\n";
+ print " </td>\n";
+ print " </tr>\n";
+ print "</table>\n";
+
}
- print "</td>\n";
- print "<td align=center valign=top nowrap>";
+ print " </td>\n";
+ print " <td class=\"spong_service\">\n";
if( $d1 == $d2 && $m1 == $m2 && $y1 == $y2 ) {
print POSIX::strftime( $main::TIMEFMTNOSEC, localtime($self->rtime()) ), " ";
print POSIX::strftime( $main::DATEFMT, localtime($self->rtime()) ), " ";
}
- print "</td>\n";
- print "<td align=left valign=top>", $self->summary(), "</td></tr>\n";
+ print " </td>\n";
+ print " <td class=\"spong_service\">", $self->summary(), "</td>\n";
+ print " </tr>\n";
} elsif( $format eq "standard" ) {
print "<table width=100% border=1 cellspacing=2 cellpadding=2><tr>\n";
print "<td width=60 align=center><b>Service</b></td>\n";
print "</table>\n";
} elsif( $format eq "full" ) {
- print "<font size=+2><b>", $self->host(), "/", $self->name();
- print "</b></font>\n";
+ print "<h2>", $self->host(), "/", $self->name();
+ print "</h2>\n";
# This breaks the generic interactive vs non-interactive model
$self->add_action_bar();
- print "<table width=100% cellspacing=0 cellpadding=0 border=0>";
- print "<tr><td bgcolor=\"" . $main::WWW_COLOR{$color} . "\"> </td>";
- print "</tr></table><p>";
+ print "<table class=\"spong_service_detailed\">\n";
+ print " <tr class=\"spong_service_detailed\">\n";
+ print " <td class=\"spong_background_$color\"> </td>\n";
+ print "</tr>\n";
+ print "</table>\n";
+ print "<br />\n";
- print "<b>Updated:</b> ";
+ print "<span class=\"form_property\">Updated:</span> ";
print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($self->rtime()) );
- print "<br><b>Duration:</b> ";
+ print "<br />\n";
+ print "<span class=\"form_property\">Duration:</span> ";
print $self->format_duration($self->stime(),$self->rtime());
- print "<br><b>Summary:</b> ", $self->summary(), "<br>\n";
- print "<hr noshade><pre>", $self->message(), "</pre>\n";
+ print "<br />\n";
+ print "<span class=\"form_property\">Summary:</span> ", $self->summary(), "<br />\n";
+ print "<hr class=\"spong_service_detailed\" />\n";
+ print "<pre>", $self->message(), "</pre>\n";
}
}
my $service = $self->name();
my $message = &escape( "Host: $name, " . $self->_problem_message() );
- print "<hr>";
- print "<a href=\"telnet://$name\">Connect to Host</a> || ";
+# TODO: config option to remove "WWWACK"-link
+# -> see also Host.pm!
+ print "<hr />\n";
+# nobody uses telnet anymore, consider removing this completely:
+# print "<a href=\"telnet://$name\">Connect to Host</a> || ";
print "<a href=\"$main::WWWACK/$name/$service\">Acknowledge Problem</a> ";
if( $main::WWWCONTACT ) {
print "Contact Help</a>";
}
- print "<hr>\n";
+ print "<hr />\n";
}
# Escape non-standard HTML characters
#
# History:
# (1) Cleaned up (Ed July 31, 1997);
+# (2) XHTML (Michael Arndt, 2005/11/15);
use Spong::Service;
use Spong::AckList;
my( $rtime ) = (stat( "$main::SPONGDB/$host/services/$_" ))[9];
my $service = Spong::Service->new( $host, $name );
+ $service->rcolor( $color );
+ $service->color( $color );
+
$service->rtime( $rtime );
- if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
- $service->rcolor( $color ); $service->color( "purple" );
- } else {
- $service->rcolor( $color ); $service->color( $color );
- }
+
+ # Config option to get rid of (sometimes annoying)
+ # purple colors (maybe this should be an optional patch ...)
+ if(! $main::SPONG_NO_PURPLE) {
+ if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
+ $service->color( "purple" );
+ }
+ }
+
$service_hash{$name} = $service;
}
closedir( DIR );
$got_one = 1;
my( $rtime ) = (stat( "$main::SPONGDB/$host/services/$_" ))[9];
my $service = Spong::Service->new( $host, $name );
-
+
+ # Even more purple here ... see above
$service->rtime( $rtime );
- if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
- $service->rcolor( $color ); $service->color( "purple" );
+ if( ($rtime < ( time() - (3 * $main::SPONGSLEEP) ))
+ && (!$main::SPONG_NO_PURPLE)
+ ) {
+
+ $service->rcolor( $color ); $service->color( "purple" );
} else {
$service->rcolor( $color ); $service->color( $color );
}
my( $event, $date );
if( $format eq "brief" ) {
- print "<table border=0 cellspacing=1 cellpadding=1>\n";
+ print "<table class=\"spong_servicelist_brief\">\n";
foreach $service ( $self->services() ) {
my $host = $service->host();
my $name = $service->name();
- print "<tr><td align=center valign=center>";
+ print " <tr>\n";
+ print " <td class=\"spong_servicelist_brief_left\">\n";
$service->display_html( "brief" );
- print "</td><td align=left valign=center>";
+ print " </td>\n";
+ print " <td class=\"spong_servicelist_brief_right\">\n";
print " <a href=\"!!WWWSPONG!!/service/$host/$name\">$name</a>";
- print "</td></tr>\n";
+ print " </td>\n";
+ print " </tr>\n";
}
print "</table>\n";
} elsif( $format eq "standard" ) {
- print "<table width=100% border=1 cellspacing=1 cellpadding=1><tr>\n";
- print "<td width=60 align=center nowrap><b>Service</b></td>\n";
- print "<td width=1% nowrap> </td>\n";
- print "<td width=60 align=center nowrap><b>Updated</b></td>\n";
- print "<td width=100% align=center><b>Summary</b></td></tr>\n";
+ print "<table class=\"spong_servicelist\">\n";
+ print " <tr class=\"spong_servicelist\">\n";
+ print " <th class=\"spong_servicelist_service\">Service</th>\n";
+ print " <th class=\"spong_servicelist_image\"> </th>\n";
+ print " <th class=\"spong_servicelist_updated\">Updated</th>\n";
+ print " <th class=\"spong_servicelist_summary\">Summary</th>\n";
+ print " </tr>\n";
foreach( $self->services() ) { $_->display_html( "standard_table" ); }