====== Xymon REDboard ====== ^ Author | [[ gudm00@gmail.com | 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 | ===== Description ===== Simple preview page to display only red alerts ===== Installation ===== 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. ===== Source ===== ==== redboard.cgi ==== #!/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 $Title RED Dashboard "; # Fetch latest RED Statistics @redstatus = `$client $server \"$board\" | egrep -v \"trends|info|purple|blue|clear|green|yellow\"`; $int = 1; $results = 0; sub header() { print " "; } 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 = "\n\n\n\n"; } else { $line = "\n\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 "
$date
$overalltext
Host Test Last Change Host Test Last Change Host Test Last Change
".$host."".$test."$sincetime ".$host."".$test."$sincetime 
";
===== Known Bugs and Issues ===== ===== To Do ===== ===== Credits ===== ===== Changelog ===== * **2012-04-11** * Initial release