From fcbd3a0dff912f356bf94bd2b78974820cae9332 Mon Sep 17 00:00:00 2001 From: zapotah Date: Tue, 7 Nov 2017 17:19:18 +0200 Subject: [PATCH] Fix ".status services" to show properly possible status codes (#7663) * Fix ".status services" to show properly possible status codes Nagios plugins return 0-3 as the status-code for a check. This adds "warning" and "unknown" to the output as well as hierarchical color for the total. * Fix ".status services" to show properly possible status codes Nagios plugins return 0-3 as the status-code for a check. This adds "warning" and "unknown" to the output as well as hierarchical color for the total. --- LibreNMS/IRCBot.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/LibreNMS/IRCBot.php b/LibreNMS/IRCBot.php index e6c6df6056..f55184d21e 100644 --- a/LibreNMS/IRCBot.php +++ b/LibreNMS/IRCBot.php @@ -851,19 +851,34 @@ class IRCBot case 'srv': $srvcount = array_pop(dbFetchRow('SELECT count(service_id) FROM services'.$d_w)); $srvup = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '0' AND service_ignore ='0'".$d_a)); - $srvdown = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '1' AND service_ignore = '0'".$d_a)); + $srvdown = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '2' AND service_ignore = '0'".$d_a)); + $srvwarn = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '1' AND service_ignore = '0'".$d_a)); + $srvunknown = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '3' AND service_ignore = '0'".$d_a)); $srvign = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_ignore = '1'".$d_a)); $srvdis = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_disabled = '1'".$d_a)); + $srvcountcolor = array($srvdown, $srvwarn, $srvunknown); if ($srvup > 0) { $srvup = $this->_color($srvup, 'green'); } if ($srvdown > 0) { $srvdown = $this->_color($srvdown, 'red'); + } + if ($srvwarn > 0) { + $srvwarn = $this->_color($srvwarn, 'yellow'); + } + if ($srvunknown > 0) { + $srvunknown = $this->_color($srvunknown, 'lightblue'); + } + if ($srvcountcolor[0] > 0) { + $srvcount = $this->_color($srvcount, 'red', null, 'bold'); + } elseif ($srvcountcolor[1] > 0) { $srvcount = $this->_color($srvcount, 'yellow', null, 'bold'); + } elseif ($srvcountcolor[2] > 0) { + $srvcount = $this->_color($srvcount, 'lightblue', null, 'bold'); } else { $srvcount = $this->_color($srvcount, 'green', null, 'bold'); } - $msg = 'Services: '.$srvcount.' ('.$srvup.' up, '.$srvdown.' down, '.$srvign.' ignored, '.$srvdis.' disabled'.')'; + $msg = 'Services: '.$srvcount.' ('.$srvup.' up, '.$srvdown.' down, '.$srvwarn.' warning, '.$srvunknown.' unknown, '.$srvign.' ignored, '.$srvdis.' disabled'.')'; break; default: