# service - service name this history is associated with
# color - color of the service at time history event was created
# other - summary information about the history event
+# service - service object that cause status change
#
# + new() - constructor (sets instance vars to arguments passed in)
# + gets/sets() - magical set/get functions (autoloaded based on func name)
package Spong::History;
+use Spong::HistoryService;
+
# Constructor. A simple constructor that just sets all of the instance vars
# according to what was passed in. All vars should be set on creation.
sub new {
- my( $class, $host, $type, $time, $service, $color, $other ) = @_;
+ my( $proto, $host, $type, $time, $service, $color, $other ) = @_;
+ my( $class ) = ref($proto) || $proto;
my $self = {};
$self->{'host'} = $host;
$self->{'service'} = $service;
$self->{'color'} = $color;
$self->{'other'} = $other;
+ $self->{'status'} = new Spong::HistoryService($host, $service, $time );
- bless $self;
+ bless ($self,$class);
return $self;
}
sub other { my $var = 'other';
if( defined $_[1] ) { $_[0]->{$var} = $_[1]; } return $_[0]->{$var}; }
+# Simple Set method for the status object
+sub status {
+ return $self->{'status'}
+}
# Display summary. Does both text and html, doesn't make any calls to
# sub-objects or other helper objects, just spits out the data that it has.
my $color = $self->color();
my $service = $self->service();
my $other = $self->other();
+ my $time = $self->time();
$shost = (split( /\./, $self->host() ))[0] unless $shost;
print "<tr><td width=7% align=left valign=top>";
if( $main::WWW_USE_IMAGES == 1 ) {
+ 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);
} else {
print "<table width=20 border=0 cellspacing=0 cellpadding=0><tr>";
- print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} . "\">";
- print " </td></tr></table>";
+ print "<td width=20 bgcolor=\"" . $main::WWW_COLOR{$color} . "\">";
+ print "<a href=\"" . $main::WWWSPONG . "/histservice/".$self->host()
+ . "/$service/$time\">" if ($main::STATUS_HISTORY);
+ print " ";
+ print "</a>" if $main::STATUS_HISTORY;
+ print "</td></tr></table>";
}
print "</td><td width=12% align=center valign=top>";