Changeset 320


Ignore:
Timestamp:
Jul 20, 2018, 1:43:36 PM (6 years ago)
Author:
g7moreau
Message:
  • CHange alertcolor API
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nagios-velvice/velvice.cgi

    r319 r320  
    6565
    6666sub alertcolor {
    67    my ($color, $downtime) = @_;
     67   my ($status, $downtime) = @_;
     68
     69   my %STATUS_DB = (
     70      CRITICAL => {id => 3, color => '#F88888'}
     71      WARNING  => {id => 2, color => '#FFFF00'}
     72      PENDING  => {id => 1, color => '#E0E0E0'}
     73      );
     74
     75   my $color = '#0000FF';
     76   $color = $STATUS_DB{$status}->{'color'} if exists $STATUS_DB{$status};
    6877
    6978   $downtime = $downtime - $config->{'color-downtime'}{'day-min'}; # same color first days
     
    107116   
    108117      my $downtime = downtime($log->service($host, $srv)->last_state_change);
    109       my $color    = $status eq 'CRITICAL' ? '#F88888' : '#FFFF00';
    110       $color = alertcolor($color, $downtime);
    111 
    112       my %status_db = (
    113          CRITICAL => 3,
    114          WARNING  => 2,
    115          PENDING  => 1,
    116          );
     118      my $color    = alertcolor($status, $downtime);
    117119
    118120      my $status_id = 0;
    119       $status_id = $status_db{$status} if exists $status_db{$status};
     121      $status_id = $STATUS_DB{$status}->{'id'} if exists $STATUS_DB{$status};
    120122
    121123      #$hostcount{$host}++;
     
    201203      my $output   = HTML::Entities::encode($srv->plugin_output) =~ s/^[A-Z_\s]+?[:-]//r;
    202204
    203       my $color = $status eq 'CRITICAL' ? '#F88888' : '#FFFF00';
    204       $color = alertcolor($color, $downtime);
     205      my $color = alertcolor($status, $downtime);
    205206      my $stylecolor = "style='background:$color;'";
    206207      $htmlpage .= " <tr>\n";
     
    280281         my $hostname = $host_stat->host_name;
    281282         my $downtime = downtime($host_stat->last_state_change);
    282          my $color = alertcolor('#F88888', $downtime);
     283         my $color = alertcolor('CRITICAL', $downtime);
    283284         $htmlpage .= " <tr style='background:$color'>\n";
    284285         $htmlpage .= "  <td><a class='hoop' href=\"$config->{'nagios-server'}{'status-cgi'}?host=" . uri_encode($hostname) . "\">$hostname</a></td>\n";
Note: See TracChangeset for help on using the changeset viewer.