diff --git a/index.php b/index.php index 7fc0a56..2c4d137 100755 --- a/index.php +++ b/index.php @@ -39,6 +39,7 @@ # All the hard work is done in here. require 'inc.php'; +$services_dt=0; ?>
@@ -67,7 +68,7 @@ 0) + { + $downtimedhosts++; + $listofdt[] .= $hlist[$hkey]["host"]["host_name"]; + } // Now the mess begins. - if( $hlist[$hkey]["host"]["status"] != "UP" && $hlist[$hkey]["host"]["status"] != "PENDING" && $hlist[$hkey]["host"]["status"] != "BLOCK" && $hlist[$hkey]["host"]["problem_has_been_acknowledged"] != "1") { + if( $hlist[$hkey]["host"]["status"] != "UP" && $hlist[$hkey]["host"]["status"] != "PENDING" && $hlist[$hkey]["host"]["status"] != "BLOCK" && $hlist[$hkey]["host"]["problem_has_been_acknowledged"] != "1" && $hlist[$hkey]["host"]["scheduled_downtime_depth"] < 1) { + if ($hlist[$hkey]["host"]["scheduled_downtime_depth"] >0) + { + $downtime=" [downtimed]"; + } + $hostsout .= sprintf("\n"); - $hostsout .= sprintf("\t%s ", $hlist[$hkey]["host"]["host_name"]); + $hostsout .= sprintf("\t%s%s ", $hlist[$hkey]["host"]["host_name"] , $downtime); if($hlist[$hkey]["host"]["status"] == "BLOCK") { - $hostsout .= sprintf("%s", $hlist[$hkey]["host"]["status"]); + $hostsout .= sprintf("%s%s", $hlist[$hkey]["host"]["status"], $downtime); } else if($hlist[$hkey]["host"]["problem_has_been_acknowledged"] == "1") { - $hostsout .= sprintf("%s (a)", $hlist[$hkey]["host"]["status"]); + $hostsout .= sprintf("%s (a)%s", $hlist[$hkey]["host"]["status"], $downtime); } else { - $hostsout .= sprintf("%s", $hlist[$hkey]["host"]["status"]); + $hostsout .= sprintf("%s%s", $hlist[$hkey]["host"]["status"], $downtime); } $hostsout .= sprintf("%s", $hlist[$hkey]["host"]["duration"]); // if you want to see when the last notificaiton was, uncomment this. @@ -124,19 +136,54 @@ if(is_array($services) && $hlist[$hkey]["host"]["status"] == "UP") { foreach( $services as $service => $svalue) { + $downtime=""; + if ($hlist[$hkey]["host"]["scheduled_downtime_depth"] >0) + { + $downtime=" [downtimed host]"; + } + elseif ($services[$service]["scheduled_downtime_depth"] >0) + { + $downtime=" [downtimed service]"; + } - // Warnings are special cased to make them orange. - if($services[$service]["status"] == "WARNING") { - $servicesout_warning .= "\n"; + //already downtimed, segregate + if (($hlist[$hkey]["host"]["scheduled_downtime_depth"] >0) || ($services[$service]["scheduled_downtime_depth"] >0)) + { + $thisalert="dt"; + $servicesout_dt .= "\n"; + if(($hlist[$hkey]["host"]["host_name"] != $lasthost) || ($thisalert != $lastalert)) { + $servicesout_dt .= sprintf("%s%s", $hlist[$hkey]["host"]["host_name"], $downtime); + } else { + $servicesout_dt .= sprintf(" "); + } + $servicesout_dt .= sprintf("%s", $services[$service]["description"]); + + if($services[$service]["status"] == "Unknown") { + $servicesout_dt .= sprintf("%s%s", $services[$service]["status"], $downtime); + } else { + $servicesout_dt .= sprintf("%s (ack)", $services[$service]["status"]); } + + # $servicesout_error .= sprintf("%s", $services[$service]["last_check"]); + #$servicesout_dt .= sprintf("%s", $services[$service]["last_state_change"]); + $servicesout_dt .= sprintf("%s", $services[$service]["duration"]); + $servicesout_dt .= sprintf("%s/%s", $services[$service]["current_attempt"], $services[$service]["max_attempts"]); + #$servicesout_error .= sprintf("%s", $services[$service]["plugin_output"]); + $servicesout_dt .= sprintf("\n"); + $lastalert="dt"; + $services_dt++; + } // Warnings are special cased to make them orange. + elseif($services[$service]["status"] == "WARNING") { + $servicesout_warning .= "\n"; + if($hlist[$hkey]["host"]["host_name"] == $lasthost && $lastalert == "warning") { $servicesout_warning .= sprintf(" "); } else { - $servicesout_warning .= sprintf("%s", - $hlist[$hkey]["host"]["host_name"]); + $servicesout_warning .= sprintf("%s%s", + $hlist[$hkey]["host"]["host_name"], $downtime); } - $servicesout_warning .= sprintf("%s", $services[$service]["description"]); + $servicesout_warning .= sprintf("%s%s", $services[$service]["description"],$downtime); $servicesout_warning .= sprintf("%s", $services[$service]["status"]); # $servicesout_warning .= sprintf("%s", $services[$service]["last_check"]); # $servicesout_warning .= sprintf("%s", $services[$service]["last_state_change"]); @@ -151,7 +198,7 @@ $servicesout_ack .= "\n"; if(($hlist[$hkey]["host"]["host_name"] != $lasthost) || ($thisalert != $lastalert)) { - $servicesout_ack .= sprintf("%s", $hlist[$hkey]["host"]["host_name"]); + $servicesout_ack .= sprintf("%s%s", $hlist[$hkey]["host"]["host_name"], $downtime); } else { $servicesout_ack .= sprintf(" "); } @@ -182,7 +229,7 @@ // Finally, stuff that is actually Critical. if(($hlist[$hkey]["host"]["host_name"] != $lasthost) || ($thisalert != $lastalert)) { - $servicesout_error .= sprintf("%s", $hlist[$hkey]["host"]["host_name"]); + $servicesout_error .= sprintf("%s%s", $hlist[$hkey]["host"]["host_name"], $downtime); } else { $servicesout_error .= sprintf(" "); } @@ -263,6 +310,11 @@ $ackedout .= ""; } +if(count ($listofacked) > 0) { + $ackedout = "Acknowledged:"; + $ackedout .= implode(", ", $listofacked); + $ackedout .= ""; +} if(strlen($hostsout)) { echo "\n"; @@ -325,6 +377,20 @@ echo "\n"; } +// Downtimed services get a seperate line to save space +if(strlen($servicesout_dt)) { + + echo ""; + echo "
Downtimed Services    "; + echo "$services_dt Downtimed "; + echo "
\n"; + echo "\n"; + echo "\t\n"; + echo "\n"; + echo $servicesout_dt; + echo "
HostServiceStatusDurationA
\n"; +} + // Show hosts with notifications off. if(strlen($notifications_off)) { echo "

\n";