From 1ae8423af06757ab643c099a07751e2b992d148c Mon Sep 17 00:00:00 2001 From: Michael Arndt Date: Tue, 15 Nov 2005 12:28:32 +0000 Subject: [PATCH] xhtml and more cleanups --- src/lib/Spong/AckList.pm | 3 +- src/lib/Spong/History.pm | 59 +++++++---- src/lib/Spong/HistoryList.pm | 27 +++++- src/lib/Spong/HistoryService.pm | 92 ++++++++++++------ src/lib/Spong/Host.pm | 154 ++++++++++++++++++----------- src/lib/Spong/HostGroups.pm | 167 ++++++++++++++++---------------- src/lib/Spong/HostList.pm | 128 +++++++++++++----------- src/lib/Spong/Service.pm | 85 ++++++++++------ src/lib/Spong/ServiceList.pm | 51 ++++++---- 9 files changed, 466 insertions(+), 300 deletions(-) diff --git a/src/lib/Spong/AckList.pm b/src/lib/Spong/AckList.pm index 786e094..0b5427c 100755 --- a/src/lib/Spong/AckList.pm +++ b/src/lib/Spong/AckList.pm @@ -14,6 +14,7 @@ # # History: # (1) Cleaned up (Ed July 30, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15) use Spong::Ack; @@ -116,7 +117,7 @@ sub display { $_->display( $format, $view ); if( $format eq "text" ) { print "\n"; } - if( $format eq "html" ) { print "

"; } + if( $format eq "html" ) { print "

"; } } } diff --git a/src/lib/Spong/History.pm b/src/lib/Spong/History.pm index 8e707c1..7b70d1f 100755 --- a/src/lib/Spong/History.pm +++ b/src/lib/Spong/History.pm @@ -19,8 +19,9 @@ # # 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; @@ -109,33 +110,51 @@ sub display_html { $shost = $self->host() if $main::HISTORY_FQDN; $shost = (split( /\./, $self->host() ))[0] unless $shost; - print ""; + # this is used to format every second row + # to make it better readable + if($view eq "contrast") { + print " \n"; + } + else { + print " \n"; + } + + print " \n"; if( $main::WWW_USE_IMAGES == 1 ) { - print "host() + print " host() . "/$service/$time\">" if ($main::STATUS_HISTORY); - print "$color"; - print "" if ($main::STATUS_HISTORY); + print " \"$color\""; + print "\n" if ($main::STATUS_HISTORY); } else { - print ""; - print "
"; - print "host() - . "/$service/$time\">" if ($main::STATUS_HISTORY); - print "      "; - print "" if $main::STATUS_HISTORY; - print "
"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
\n"; + + if($main::STATUS_HISTORY) { + print " host() + ."/$service/$time\">\n"; + print " \n"; + print "       \n"; + print " \n"; + print " \n"; + } + + print "
\n"; } - print "\n"; - print ""; + print " \n"; + print " "; my($type) = substr($self->type,0,1); $type =~ tr/a-z/A-Z/; print "$type\n"; - print ""; - printf ( "%2.2d:%2.2d", $hour, $min ); - print "$shost \n"; - print "$service\n"; - print "$other\n"; + print " "; + printf ( "%2.2d:%2.2d\n", $hour, $min ); + print " $shost \n"; + print " $service\n"; + print " $other\n"; + print " \n"; } 1; diff --git a/src/lib/Spong/HistoryList.pm b/src/lib/Spong/HistoryList.pm index c421239..708b9ba 100755 --- a/src/lib/Spong/HistoryList.pm +++ b/src/lib/Spong/HistoryList.pm @@ -16,6 +16,7 @@ # # History: # (1) Cleaned up (Ed July 31, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15); use Spong::History; @@ -135,6 +136,9 @@ sub display_html { 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() ) { @@ -144,13 +148,28 @@ sub display_html { my $dstr = POSIX::strftime( "%A, $main::DATEFMT", localtime($event->time()) ); if( $dstr ne $date ) { - if( $date ne "" ) { print "
"; } - print "$dstr\n


\n"; - print "\n"; + if( $date ne "" ) { print "
\n
\n"; } + print "
$dstr
\n"; + + # TODO: leave
instead of
here? + # print "
\n"; + + print "
\n"; + print "\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 "
\n"; diff --git a/src/lib/Spong/HistoryService.pm b/src/lib/Spong/HistoryService.pm index 3b910a9..3c49d45 100755 --- a/src/lib/Spong/HistoryService.pm +++ b/src/lib/Spong/HistoryService.pm @@ -7,6 +7,7 @@ # History # (1) Created (Dec 27, 1999 Stephen L Johnson) +# (2) XHTML (Michael Arndt, 2005/11/15) package Spong::HistoryService; @@ -55,7 +56,6 @@ sub filename { } # Overridden html display function - sub display_html { my( $self, $format ) = @_; my $host = $self->host; @@ -68,32 +68,48 @@ sub display_html { print "\n"; if( $main::WWW_USE_IMAGES == 1 ) { - print "$color"; + print "\"$color\""; } else { - print ""; - print "
"; - print "___
\n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
\n"; + print " "; + print "___\n"; + print "
\n"; } print "
"; } elsif( $format eq "standard_table" ) { - print "\n"; - print "$name\n"; - print "\n"; + + # TODO: restore removed styles in etc. ... + # print "\n"; + print " \n"; + print " \n"; + print " \n"; - print "\n"; + print " \n"; - print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
\n"; + print " $name\n"; + print " \n"; if( $main::WWW_USE_IMAGES == 1 ) { print "\n"; - print "$color"; + print " \"$color\"\n"; + print "\n"; } else { - print ""; - print "
"; - print ""; - print "___"; - print "
\n"; + + print "\n"; + print " \n"; + print " \n"; + print " \n"; + # print "
\n"; + print " "; + print " "; + print "___\n"; + print " \n"; + print "
\n"; } - print "
"; + print " "; if( $d1 == $d2 && $m1 == $m2 && $y1 == $y2 ) { print POSIX::strftime( "%H:%M", localtime($self->rtime()) ), " "; @@ -101,31 +117,43 @@ sub display_html { print POSIX::strftime( "%D", localtime($self->rtime()) ), " "; } - print "", $self->summary(), "
", $self->summary(), "
\n"; + } elsif( $format eq "standard" ) { - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + + # TODO: where's that stuff coming from?? + print "
Service UpdatedSummary
\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; $self->display_html( "standard_table" ); print "
Service UpdatedSummary
\n"; + } elsif( $format eq "full" ) { - print "", $self->host(), "/", $self->name(); - print "\n"; - print ""; - print ""; - print "
 

"; + print "

", $self->host(), "/", $self->name(); + print "

\n"; + + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
 
\n"; + print "
\n"; - print "Date: "; + print "Date: "; print POSIX::strftime( "%H:%M, %D", localtime($self->rtime()) ); - print "
Summary: ", $self->summary(), "
\n"; - print "
", $self->message(), "
\n"; + print "
\n"; + print "Summary: ", $self->summary(), "
\n"; + print "
\n"; + print "
", $self->message(), "
\n"; } } diff --git a/src/lib/Spong/Host.pm b/src/lib/Spong/Host.pm index 123c4af..c82f7a5 100755 --- a/src/lib/Spong/Host.pm +++ b/src/lib/Spong/Host.pm @@ -27,6 +27,7 @@ # # History: # (1) Cleaned up (Ed July 31, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15); use Spong::AckList; use Spong::Ack; @@ -223,48 +224,70 @@ sub display_html { if( $format eq "brief" ) { my $color = $self->color(); - print "\n"; + print "\n"; if( $main::WWW_USE_IMAGES == 1 ) { - print "$color"; + print "\"$color\""; } else { - print ""; - print "
"; - print "___
\n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
\n"; + print " "; + print "___\n"; + print "
\n"; } print "
"; } elsif( $format eq "standard" || $format eq "full" ) { - print "$name\n"; - # This breaks the generic interactive vs non-interactive model - $self->add_action_bar(); - - my $color = $self->color(); - - print ""; - print ""; - print "
 

"; - - my $acklist = $self->acks(); - if( $acklist ) { - print "Acknowledgments


\n"; - $acklist->display( "html", $format ); } - - my $servicelist = $self->services(); - if( $servicelist ) { - print "

Services


\n"; - $servicelist->display( "html", $format ); } - - my $info = Spong::Info->new( $self->name() ); - if( $info ) { - print "

Information


\n"; - $info->display( "html", $format ); } - - my $historylist = $self->history(); - if( $historylist ) { - print "

History


\n"; - $historylist->display( "html", $format ); } + print "

$name

\n"; + + # This breaks the generic interactive vs non-interactive model + $self->add_action_bar(); + + my $color = $self->color(); + + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
 
\n\n"; + + + my $acklist = $self->acks(); + if( $acklist ) { + print "

Acknowledgments

\n"; + print "
\n"; + $acklist->display( "html", $format ); + print "
\n"; + } + + my $servicelist = $self->services(); + if( $servicelist ) { + print "

Services

\n"; + print "
\n"; + $servicelist->display( "html", $format ); + print "
\n"; + } + + my $info = Spong::Info->new( $self->name() ); + if( $info ) { + print "

Information

\n"; + print "
\n"; + $info->display( "html", $format ); + print "
\n"; + } + + my $historylist = $self->history(); + if( $historylist ) { + print "

Weekly History

\n"; + print "
\n"; + $historylist->display( "html", $format ); + print "
\n"; + } } } @@ -308,36 +331,43 @@ sub display_problem_html { 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 "$color"; - print "$name
"; + print "  "; + print "$name
\n"; } else { - print ""; - print "
  "; - print "$name"; - print "
\n"; + print "\n"; + print " \n"; +# does not look very nice: +# print " \n"; + print " \n"; + print " \n"; + print "
  "; + print " $name\n"; + print "
\n"; } - if( $prob eq "multiple problems" ) { - print "$spacer problem: $prob
\n"; + if( $prob eq "multiple" ) { + print "$spacer problem: $prob
\n"; } else { - print "$spacer problem: $prob
"; + print "$spacer problem: $prob
"; } - # if( $summ ) { print "$spacer summary: $summ
\n"; } + # if( $summ ) { print "$spacer summary: $summ
\n"; } if( $time ) { print "$spacer updated: "; - print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($time) ), "
\n"; + print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($time) ), "
\n"; } if ( $main::WWWCONTACT ) { print "$spacer contact: "; - print ""; + print ""; print "$human\n"; } @@ -347,12 +377,12 @@ sub display_problem_html { &main::error("add_action_bar: $@"); &main::error($main::WWW_PROB_ACTIONBAR); } else { - print "$spacer $text
\n"; + print "$spacer $text
\n"; } } - print "

\n"; + print "
\n"; } @@ -379,7 +409,7 @@ sub _problem_service { } elsif( $#problist == 0 ) { return( $problist[0], $summary, $probtime ); } else { - return( "multiple problems", "", $probtime ); + return( "multiple", "", $probtime ); } } @@ -419,13 +449,19 @@ sub add_action_bar { my $name = $self->name(); my $message = &escape( "Host: $name, " . $self->_problem_message() ); - print "


"; - print "Connect || "; - print "Acknowledge Problem "; + +# TODO: config option to remove "WWWACK"-link +# + print "
\n"; +# nobody uses telnet anymore, consider removing this completely: +# print "Connect || "; + print "Acknowledge Problem "; if( $main::WWWCONTACT ) { - print "|| "; - print "Contact Help"; + print "|| "; + print "Contact Help\n"; } if ($main::WWW_ACTIONBAR_CUSTOM) { @@ -438,7 +474,7 @@ sub add_action_bar { } } - print "
\n"; + print "
\n"; } sub escape { diff --git a/src/lib/Spong/HostGroups.pm b/src/lib/Spong/HostGroups.pm index 9a1b36c..ef1121c 100755 --- a/src/lib/Spong/HostGroups.pm +++ b/src/lib/Spong/HostGroups.pm @@ -17,8 +17,10 @@ # + 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; @@ -283,12 +285,11 @@ sub display_html { # Print the header of the table. - print "\n \n"; - print " \n"; - print " \n"; - print " \n"; + print "
Host GroupStatus
\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; # Now for each group, go through and find out overall status of that # host. @@ -297,8 +298,8 @@ sub display_html { my $name = $group->name(); my $grname = $main::GROUPS{$name}->{'name'}; - print " \n"; - print " \n"; + print " \n"; + print " \n"; my ($color); foreach $service ( @names ) { @@ -308,34 +309,23 @@ sub display_html { if( $color ) { if( $main::WWW_USE_IMAGES == 1 ) { - print " \n"; + print " \n"; } else { if( $main::WWW_USE_IMAGES == 1 ) { - print " \n"; + print " \n"; } else { - print " \n"; + print " \n"; } } - print " \n"; + print " \n"; } print "
Host GroupStatus
$grname
$grname"; - my $alt = ""; - print "\"$alt\""; - print ""; + print " \n"; + my $alt = ""; + print " \"$alt\"&nbps;"; + } else { - print " "; - print ""; - print "___"; + print " \n"; + print " ___\n"; } - print " - -   
\n"; @@ -351,17 +341,17 @@ sub display_html { # Print the horizontal axis of the table (names of the services) - print ""; - print "\n"; + print "
Host Group
\n"; + print " \n"; + print " \n"; foreach $service ( @names ) { - print "\n"; + print " \n"; } - print "\n\n"; + print " \n\n"; # Now go through each host group, and fill in the table. @@ -369,44 +359,37 @@ sub display_html { my $name = $group->name(); my $grname = $main::GROUPS{$name}->{'name'}; - print "\n"; + print " \n"; + print " \n"; foreach $service ( @names ) { my $color = $group->services_color( $service ); if( $color ) { if( $main::WWW_USE_IMAGES == 1 ) { - print ""; + print " \n"; } else { - if( $main::WWW_USE_IMAGES == 1 ) { - print "\n"; + if( $main::WWW_USE_IMAGES == 1 ) { + print " \n"; } else { - print "\n"; + print " \n"; } } } + + print " \n"; + } - print "
Host Group\n"; - print ""; - print "$service\n"; + print " "; + print "$service\n"; + print "
\n"; - print "$grname
\n"; + print " $grname\n"; + print " "; - my $alt = ""; - print "\"$alt\""; - print ""; + print " \n"; + print " \"$color\"\n"; } else { - print ""; - print ""; - print "___"; + print " \n"; + print " "; + print "___\n"; } - print " - -   
"; + print "\n"; } elsif( $format eq "full" ) { @@ -424,11 +407,11 @@ sub display_html { # Display the host group table # print ""; - print "Group - $grname"; + print "\n
Group - $grname

\n"; # print "
\n"; $group->display_html("standard"); - print "\n
\n"; + print "\n
\n"; } } } @@ -469,33 +452,53 @@ sub display_problems { if ( $problems ) { foreach my $group ( $badgroups->groups() ) { my $name = $main::GROUPS{$group->name()}->{'name'}; - print "" - if $type eq "html"; - print "Group: $name\n"; - print "

" if $type eq "html"; + print "

Group: $name
\n"; + print "

\n" if $type eq "html"; $group->display( $type, $format ); - print "


\n"; + print "

\n"; + print "
\n"; } } 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" ); - } + output_problems($purple, $type); } } } +sub output_problems { + my $purple=shift; + my $type=shift; + + if( $purple ) { + print "

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

\n" + 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 "

\n" + if( $type eq "html" ); + + } + else { + print "

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

\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 diff --git a/src/lib/Spong/HostList.pm b/src/lib/Spong/HostList.pm index 6dba884..e446d54 100755 --- a/src/lib/Spong/HostList.pm +++ b/src/lib/Spong/HostList.pm @@ -20,6 +20,7 @@ # # History: # (1) Cleaned up (Ed July 31, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15); use Spong::Host; @@ -93,7 +94,6 @@ sub byname { } - # 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. @@ -107,6 +107,7 @@ sub hostnames { my $var = 'hostnames'; 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 @@ -121,7 +122,7 @@ sub hosts { return @tmp; } -sub sorted_hosts { +sub sorted_hosts { my $self = shift; my( @tmp ); @@ -129,6 +130,7 @@ sub sorted_hosts { return @tmp; } + sub add { my( $self, $host ) = @_; my $name = $host->name(); @@ -137,6 +139,8 @@ sub add { push( @{$self->{'hostnames'}}, $name ); push( @{ $self->{'sorted_hostnames'} }, $name); $self->{'sorted_hostnames'} = [ sort byname @{ $self->{'sorted_hostnames'} } ]; + + } # Calculate summary color for a service @@ -226,7 +230,7 @@ sub display_text { # 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 ) { @@ -247,7 +251,7 @@ sub display_text { # 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" ) { @@ -256,7 +260,7 @@ sub display_text { # 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(); } @@ -269,6 +273,32 @@ sub display_text { 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 "\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 " \n"; + print " \n"; + print " \n"; + } + print "
\n"; + print " $display\n"; + print "
\n"; + } + if( $format eq "standard" ) { my( %services, $host, $service, @names ); @@ -290,20 +320,20 @@ sub display_html { 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 ""; - print "\n"; + + print "
Host
\n"; + print " \n"; + print " \n"; foreach $service ( @names ) { - print "\n"; + print " \n"; } - print "\n\n"; + print " \n\n"; # Now go through each host, and fill in the table. @@ -316,8 +346,10 @@ sub display_html { $display = $main::WWW_FQDN ? $hostname : (split( /\./, $hostname ))[0]; } - print "\n"; + print " \n"; + print " \n"; foreach $service ( @names ) { my $servobj = $host->service( $service ); @@ -326,38 +358,36 @@ sub display_html { my $col = $servobj->color(); if( $main::WWW_USE_IMAGES == 1 ) { - print ""; + print " \n"; } else { if( $main::WWW_USE_IMAGES == 1 ) { - print "\n"; + print " \n"; } else { - print "\n"; + print " \n"; } } } - } - print "
Host\n"; - print ""; - print "$service\n"; + print " $service\n"; + print "
\n"; - print "$display
\n"; + print " $display\n"; + print " "; - my $alt = $servobj->summary(); - print "\"$alt\""; - print ""; + print " \n"; + print " "; + my $alt = $servobj->summary(); + print "\"$alt\""; + print " \n"; } else { - print ""; - print ""; - print ""; - print "___"; + print " \n"; + print " "; + print " "; + print "___"; + print " \n"; + print " \n"; } - print " - "; + print " -  "; + print " 
"; + + print " \n"; + + } + + print "\n"; } elsif( $format eq "full" ) { @@ -372,6 +402,7 @@ 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 @@ -398,21 +429,10 @@ sub display_problems { if( $problem ) { $badhosts->display( $type, $view ); } else { - if( $view 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" ); + + if( $view eq "full" ) { + Spong::HostGroups::output_problems($purple, $type); } - } } } diff --git a/src/lib/Spong/Service.pm b/src/lib/Spong/Service.pm index 3fd5951..988182e 100755 --- a/src/lib/Spong/Service.pm +++ b/src/lib/Spong/Service.pm @@ -22,6 +22,7 @@ # # History: # (1) Cleaned up (Ed July 31, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15); package Spong::Service; @@ -256,32 +257,44 @@ sub display_html { print "\n"; if( $main::WWW_USE_IMAGES == 1 ) { - print "$color"; + print "\"$color\"\n"; } else { - print ""; - print "
"; - print "___
\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print "
\n"; + print " "; + print "___\n"; + print "
\n"; } print "
"; } elsif( $format eq "standard_table" ) { - print "\n"; - print "$name\n"; - print "\n"; + print " \n"; + print " \n"; + print " $name\n"; + print " \n"; + + print " \n"; if( $main::WWW_USE_IMAGES == 1 ) { - print "\n"; - print "$color"; + print " \n"; + print " \"$color\"\n"; } else { - print ""; - print "
"; - print ""; - print "___"; - print "
\n"; + + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "
\n"; + print " "; + print "___\n"; + print "
\n"; + } - print "\n"; - print ""; + print " \n"; + print " \n"; if( $d1 == $d2 && $m1 == $m2 && $y1 == $y2 ) { print POSIX::strftime( $main::TIMEFMTNOSEC, localtime($self->rtime()) ), " "; @@ -289,8 +302,9 @@ sub display_html { print POSIX::strftime( $main::DATEFMT, localtime($self->rtime()) ), " "; } - print "\n"; - print "", $self->summary(), "\n"; + print " \n"; + print " ", $self->summary(), "\n"; + print " \n"; } elsif( $format eq "standard" ) { print "\n"; print "\n"; @@ -302,24 +316,30 @@ sub display_html { print "
Service
\n"; } elsif( $format eq "full" ) { - print "", $self->host(), "/", $self->name(); - print "\n"; + print "

", $self->host(), "/", $self->name(); + print "

\n"; # This breaks the generic interactive vs non-interactive model $self->add_action_bar(); - print ""; - print ""; - print "
 

"; + print "\n"; + print " \n"; + print " \n"; + print "\n"; + print "
 
\n"; + print "
\n"; - print "Updated: "; + print "Updated: "; print POSIX::strftime( "$main::TIMEFMTNOSEC, $main::DATEFMT", localtime($self->rtime()) ); - print "
Duration: "; + print "
\n"; + print "Duration: "; print $self->format_duration($self->stime(),$self->rtime()); - print "
Summary: ", $self->summary(), "
\n"; - print "


", $self->message(), "
\n"; + print "
\n"; + print "Summary: ", $self->summary(), "
\n"; + print "
\n"; + print "
", $self->message(), "
\n"; } } @@ -362,8 +382,11 @@ sub add_action_bar { my $service = $self->name(); my $message = &escape( "Host: $name, " . $self->_problem_message() ); - print "
"; - print "Connect to Host || "; +# TODO: config option to remove "WWWACK"-link +# -> see also Host.pm! + print "
\n"; +# nobody uses telnet anymore, consider removing this completely: +# print "Connect to Host || "; print "Acknowledge Problem "; if( $main::WWWCONTACT ) { @@ -371,7 +394,7 @@ sub add_action_bar { print "Contact Help"; } - print "
\n"; + print "
\n"; } # Escape non-standard HTML characters diff --git a/src/lib/Spong/ServiceList.pm b/src/lib/Spong/ServiceList.pm index 5cc0e2b..5011623 100755 --- a/src/lib/Spong/ServiceList.pm +++ b/src/lib/Spong/ServiceList.pm @@ -19,6 +19,7 @@ # # History: # (1) Cleaned up (Ed July 31, 1997); +# (2) XHTML (Michael Arndt, 2005/11/15); use Spong::Service; use Spong::AckList; @@ -56,12 +57,19 @@ sub new { 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 ); @@ -82,10 +90,14 @@ sub new { $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 ); } @@ -195,25 +207,30 @@ sub display_html { my( $event, $date ); if( $format eq "brief" ) { - print "\n"; + print "
\n"; foreach $service ( $self->services() ) { my $host = $service->host(); my $name = $service->name(); - print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; } print "
"; + print "
\n"; $service->display_html( "brief" ); - print ""; + print " \n"; print " $name"; - print "
\n"; } elsif( $format eq "standard" ) { - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print "
Service UpdatedSummary
\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; foreach( $self->services() ) { $_->display_html( "standard_table" ); } -- 2.30.2
Service UpdatedSummary