push( @{$self->{'hostnames'}}, $name );
}
+# Calculate summary color for a service
sub services_color {
my( $self, $service ) = @_;
my( $color ) = "";
return $color;
}
+# Calculate an overall summary color for the entire host list
+sub summary_color {
+ my( $self ) = @_;
+ my( $color ) = "";
+ my( $service, @names );
+
+ foreach $host ( $self->hosts() ) {
+ foreach $service (keys %main::SERVICES) {
+ my $servobj = $host->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.
#
$self->display_text( $view ) if $type eq "text";
$self->display_html( $view ) if $type eq "html";
+ $self->display_wml( $view ) if $type eq "wml";
}
# This displays a summary of all the hosts in this list in a text format
foreach $host ( $self->hosts() ) {
$host->display_problem( "text" ); print "\n";
}
+ } elsif( $format eq "brief" ) {
+
+ # This goes through each host, and has each one print a single summary
+ # line of the current status of the host. The consists of the overall
+ # status color and the host name.
+
+ foreach $host ( $self->hosts() ) {
+ printf "%-6s %s\n",$host->color(),$host->name();
+ }
+
}
}
}
}
+# This displays a summary of all the hosts in this list in an WML format
+# suitable for displaying on WAP enabled devices
+
+sub display_wml {
+ my( $self, $format ) = @_;
+
+ # Standard and brief view are equivalent for WML
+ if( $format eq "standard" || $format eq "brief") {
+
+ foreach $host ($self->hosts() ) {
+ my $color = substr($host->color(),0,2);
+ $color =~ tr/a-z/A-Z/;
+ my $name = $host->name();
+
+ print "<b><anchor title=\"$name\">$color";
+ print "<go href=\"!!WAPSPONG!!/services/$name\"/>";
+ print "</anchor></b> $name<br/>\n";
+ }
+ }
+
+}
+
+
1;
if( $type eq "text" ) { return $self->display_text( $view ); }
if( $type eq "html" ) { return $self->display_html( $view ); }
+ if( $type eq "wml" ) { return $self->display_wml( $view ); }
}
sub display_text {
}
}
+sub display_wml {
+ my( $self, $format ) = @_;
+
+ if ( $format eq "full" ) {
+ print "<br/><b>",$self->name(),"</b> ",$self->color(),"\n";
+ print "<br/>Updated: ",
+ POSIX::strftime($main::DATETIMEFMT,localtime($self->rtime())),"\n";
+ print "<br/>",$self->summary(),"\n";
+ print "<br/><br/>\n";
+ foreach $line ( split /\r?\n/s,$self->message() ) {
+ print "<br/>",$line,"\n";
+ if ( ++$i >= 15 ) { last; }
+ }
+ }
+
+}
+
# Returns a message that can be sent to the person who is on call for this
# machine which indicates the problem with this machine.
sub escape {
my($toencode) = @_;
- $toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
+ $toencode=~s/([^ a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
return $toencode;
}
if( $type eq "text" ) { return $self->display_text( $view ); }
if( $type eq "html" ) { return $self->display_html( $view ); }
+ if( $type eq "wml" ) { return $self->display_wml( $view ); }
}
sub display_text {
}
}
+# This displays all services in the database for a host in a WML format
+# suitable for displaying on a WAP enabled device
+
+sub display_wml {
+ my( $self, $format ) = @_;
+ my( $service );
+ my $host = $self->host();
+
+ if( $format eq "standard" ) {
+ foreach $service ( $self->services() ) {
+ my $name = $service->name();
+ my $color = substr($service->color(),0,2);
+ $color =~ tr/a-z/A-Z/;
+ print "<b><anchor title=\"$name\">$color";
+ print "<go href=\"!!WAPSPONG!!/service/$host/$name\"/>";
+ print "</anchor></b> $name<br/>\n";
+ }
+ }
+}
+
+
+
+
+
+
1;