addons:redboard

Xymon REDboard

Author Gudmundur Ingvarsson
Compatibility Xymon 4.2+
Requirements CGI
Download http://sourceforge.net/projects/xymonesxi/files/redboard-imagepack.tar.gz/download
Last Update 2012-04-11

Simple preview page to display only red alerts

Place in your xymon server cgi-bin directory. You may need to edit some of the variables to get it to work. Also you may need to install some perl modules the script requires.

Show Code ⇲

Hide Code ⇱

#!/usr/local/bin/perl

use strict;
use warnings;
use diagnostics;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Time::HiRes qw/gettimeofday/;
use Date::Manip;
use DBI;

my ($ackmsg,$acktime,$Banner,$board,$cgiUrl,$client,$color,$cookie,$critical,$disabletime,$dismsg,$GifURL,$green,$groupline,$host,$HostSVCUrl,$int,$lastchange,$lastgroup,$line,$logtime,$overall,$overalltext,$red,$results,$sender,$server,$sincetime,$statusline,$test,$testflags,$thisgroup,$timecalc,$Title,$validtime,$yellow,@ALARMSTATUS,@LINES,@REDDSTATUS,@redstatus,$date);

# Basic Config Variables

$date = localtime;
$Banner = "Some";
$Title = "My";
$HostSVCUrl = "http://hobbit/xymon-cgi/bb-hostsvc.sh";
$GifURL = "/gifs";
$cgiUrl = "/cgi-bin";

# Version should be hobbitboard or xymonboard
$board = "hobbitdboard";

$client = "/usr/local/xymon/server/bin/bb";
$server = "localhost";

#Thresholds
$critical = 21;
$red = 11;
$yellow = 1;
$green = 0;

# Basic HTML Code at the top

print "Content-type: text/html\n\n
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<TITLE>$Title RED Dashboard</TITLE>
<META HTTP-EQUIV=REFRESH CONTENT=60>
<HEAD>
<STYLE type=\"text/css\">
body {font-family: Century Gothic, Verdana, Arial, SunSans-Regular, Sans-Serif;background-color: #000000;color:#FFFFFF;padding:0px;margin:0px;text-align: center;white-space: nowrap;vertical-align: center;}
.table{background-color: #007BFF;color:#FFFFFF;font-family: Century Gothic,Verdana;font-size: 12pt;border-collapse: collapse;border-style: solid;border-width: 1px;margin-top: 0px;text-align: center;white-space: nowrap;position:absolute;}
th{background-image: url(/img/bgHeaderS.png);background-repeat: repeat-x;background-color: #000000;white-space: nowrap;text-align: center;font-family: Century Gothic;color:#FFFFFF;font-size: 9pt;padding:4px;margin-left:auto;margin-right:auto;position:relative;vertical-align: center;z-index:0;}
td{font-size: 9pt;vertical-align: top;z-index:0;}
img{border: 0px solid;}
.table_header{background-image: url(/img/bgHeaderR.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic, Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:0px;margin:0px;margin-left:auto;margin-right:auto;margin-top: 0px;position:relative;width:100%;white-space: nowrap;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;z-index:0;}
.table_footer{background-image: url(/img/bgHeaderR.png);background-repeat: repeat-x;background-color: #FFFFFF;font-family: Century Gothic, Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:0px;margin:0px;margin-left:auto;margin-right:auto;margin-top: 0px;position:relative;width:100%;white-space: nowrap;vertical-align: center;z-index:0;}
.page_header{background-image: url(/img/bgHeaderR.png);background-repeat: repeat-x;background-color: #000000;font-size: 22px ;white-space: nowrap;text-align: center;font-family: Century Gothic;color:#FFFFFF;padding:4px;margin-left:auto;margin-right:auto;margin-top: 0px;position:relative;vertical-align: center;z-index:0;}
.host{background-image: url(/img/bgHeaderS.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic;color:#FFFFFF;padding:4px;text-align: center;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;}
.lighter{background-repeat: repeat-x;background-color: #777777;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;z-index:0;font-family: Century Gothic,Verdana;font-size: 9pt;white-space: nowrap;}
.darker{background-repeat: repeat-x;background-color: #444444;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;z-index:0;font-family: Century Gothic,Verdana;font-size: 9pt;white-space: nowrap;}
.tableheader{background-color: #798BA1;font-family: Candara,Verdana;font-size: 11pt;font-style: bold;text-align: center;white-space: nowrap;vertical-align: center;}
input{color: #781351;background: #fee3ad;border: 1px solid #781351}
.submit input{color: #000;background: #ffa20f;border: 2px outset #d7b9c9}
.green{background-image: url(/img/bgHeaderSG.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#000000;text-align: center;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;z-index:0;}
.red{background-image: url(/img/bgHeaderSR.png);background-repeat: repeat-x;background-color: #000000;text-align: center;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#000000;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;}
.critical{background-image: url(/img/bgHeaderSC.gif);background-repeat: repeat-x;background-color: #000000;text-align: center;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#000000;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;}
.yellow{background-image: url(/img/bgHeaderSY.png);background-repeat: repeat-x;background-color: #000000;text-align: center;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#000000;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;}
.purple{background-image: url(/img/bgHeaderSP.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#000000;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;text-align: center;white-space: nowrap;vertical-align: center;}
.blue{background-image: url(/img/bgHeaderSB.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;text-align: center;vertical-align: center;}
.none{background-image: url(/img/bgHeaderSN.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:4px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;width: 0px;z-index:0;}
.normal{background-image: url(/img/bgHeaderSN.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: left;padding:4px;margin:0px auto;margin-left:auto;margin-right:auto;vertical-align: left;width: 0px;z-index:0;}
.v-ellip{text-overflow: ellipsis;-o-text-overflow: ellipsis;-moz-binding: url( 'bindings.xml#ellipsis' );white-space: nowrap;overflow: hidden;display: inline-block;max-width: 400px;text-align: left;line-height: .01em;}
p {text-align: left;margin: .2em;line-height: .01em;padding: .5em;}
.footer{line-height: .002em;background-image: url(/img/bgHeaderR.png);background-repeat: repeat-x;background-color: #000000;font-family: Century Gothic,Verdana, Arial, SunSans-Regular, Sans-Serif;color:#FFFFFF;text-align: center;padding:10px;margin:0px;margin-left:auto;margin-right:auto;position:relative;white-space: nowrap;vertical-align: center;z-index:0;}
A:link    { text-decoration: none; color: #000000; padding: 0px; }
A:visited { text-decoration: none; color: #000000; padding: 0px; }
A:active  { text-decoration: none; color: #000000; padding: 0px; }
A:hover   { text-decoration: none; color: #000000; padding: 0px; }
A.white:link    { text-decoration: none; color: #FFFFFF; padding: 0px; border: 0px solid; }
A.white:visited { text-decoration: none; color: #FFFFFF; padding: 0px; border: 0px solid;}
A.white:active  { text-decoration: none; color: #FFFFFF; padding: 0px; border: 0px solid;}
A.white:hover   { text-decoration: none; color: #FFFFFF; padding: 0px; border: 0px solid;}
</STYLE>
</HEAD>
<BODY>
<TABLE BORDER=0>
<TR>
<TD COLSPAN=11 CLASS=page_header>$Banner REDboard</TD>
<TR><TD COLSPAN=11><FONT SIZE=-1>$date</FONT></TD></TR>";

# Fetch latest RED Statistics

@redstatus = `$client $server \"$board\" | egrep -v \"trends|info|purple|blue|clear|green|yellow\"`; 

$int = 1;
$results = 0;

sub header() {

print "
<TR><TH COLSPAN=11 CLASS=$overall HEIGHT=25><FONT SIZE=+1>$overalltext</TH></TR>
<TH>Host</TH>
<TH WIDTH=65>Test</TH>
<TH WIDTH=65>Last Change</TH>
<TD></TD>
<TH>Host</TH>
<TH WIDTH=65>Test</TH>
<TH WIDTH=65>Last Change</TH>
<TD></TD>
<TH>Host</TH>
<TH WIDTH=65>Test</TH>
<TH WIDTH=65>Last Change</TH>
";
}

sub convert_time { 
  my $time = shift; 
  my $days = int($time / 86400); 
  $time -= ($days * 86400); 
  my $hours = int($time / 3600); 
  $time -= ($hours * 3600); 
  my $minutes = int($time / 60); 
  my $seconds = $time % 60; 
  
  $days = $days < 1 ? '' : $days .'d '; 
  $hours = $hours < 1 ? '' : $hours .'h '; 
  $minutes = $minutes < 1 ? '' : $minutes . 'm '; 
  $time = $days . $hours . $minutes . $seconds . 's'; 
  return $time; 
}

sub main() {
foreach $statusline (@redstatus) {
        push(@ALARMSTATUS, "$statusline");
}
foreach (@ALARMSTATUS) {
        ($host,$test,$color,$testflags,$lastchange,$logtime,$validtime,$acktime,$disabletime,$sender,$cookie,$ackmsg,$dismsg) = split("\\|", $_);
        push (@REDDSTATUS, "$lastchange|$host|$test|$color|$acktime|$disabletime");
        }
@REDDSTATUS = sort @REDDSTATUS;
$thisgroup = "none";
foreach (@REDDSTATUS) {
        ($lastchange,$host,$test,$color,$acktime,$disabletime) = split("\\|", $_);
        if ($acktime lt 1) {
        $timecalc = time - $lastchange;
        $sincetime = convert_time($timecalc);
        if ($int > 3) { $int = 1; }
        if ($int eq 1) {
        $line = "</TR>\n<TR>\n<TD CLASS=none>".$host."<TD CLASS=".$color."><A HREF=".$HostSVCUrl."?HOST=".$host."&SERVICE=$test>".$test."</A></TD><TD CLASS=none>$sincetime</TD>\n<TD>&nbsp;</TD>\n";
        } else {
        $line = "<TD CLASS=none>".$host."<TD CLASS=".$color."><A HREF=".$HostSVCUrl."?HOST=".$host."&SERVICE=$test>".$test."</A></TD><TD CLASS=none>$sincetime</TD>\n<TD>&nbsp;</TD>\n";
        }
        if ($lastgroup ne $thisgroup) {
        push(@LINES, $groupline);
        }
        push(@LINES, $line);
        $int++;
        $results++;
        $thisgroup = $lastgroup;
}
}
return $results;
}

main();

if ($results >= $critical) { $overall = "critical"; $overalltext = "CRITICAL - THROW EVERYTHING AWAY AND FIX THIS!!!!! - $results ALARMS"; }
elsif ($results >= $red) { $overall = "red"; $overalltext = "ALERT - URGENT ATTENTION NEEDED - $results ALARMS"; }
elsif ($results >= $yellow) { $overall = "yellow"; $overalltext = "WARNING - ACTION NEEDED - $results ALARMS"; }
elsif ($results eq $green) { $overall = "green";  $overalltext = "ALL OK"; }

header();
foreach (@LINES) { print $_; }

# Close the HTML Page
print "</TABLE></TD></TR>
</TD></TABLE>
</BODY>
</HTML>";
  • 2012-04-11
    • Initial release
  • addons/redboard.txt
  • Last modified: 2012/04/12 08:46
  • by 127.0.0.1