Revisiting - not show soft states
Posted: Tue Feb 09, 2016 3:50 pm
As the usage on Nagios XI evolves where I work, we are investigating the idea of having our Data Center make use of the Operations Screen.
As I was looking at the screen, I see it jumping around. Items appearing and vanishing often. It seems that the Soft and Hard states are both displayed.
Since our Data Center would go bonkers with that, as they only want to see when a Hard State has happened. I started looking at the forum for answers and found an older post. https://support.nagios.com/forum/viewto ... 0&p=159376
In my opinion (and we all have one) a Data Center screen should only reflect Hard States. Soft States come and go. Until they are Hard we do not do anything with them. Hard states prevent false alarms, we hope.
So, to deal with this since adding to the URL in this case does not work... (...adding &serviceattr=262144 to any URLs) I dug in to see what I could do. I noticed in the opscreen component directory a file named merlin.php that had the SQL queries used to display the columns. That is where I made a change.
I changed the Host and Service Select statements (I took some liberties in cleaning them up and making them human readable)
For the Host to only show Hard States - somewhere near line 50 - change the select.
I added the following line
$query .= "AND nagios_hoststatus.current_check_attempt = nagios_hoststatus.max_check_attempts ";
For the Services to only show Hard States - somewhere near line 265 - change the select.
I added the following line
$query .= "AND nagios_servicestatus.current_check_attempt = nagios_servicestatus.max_check_attempts ";
Now, by adding 2 lines, when I look at the Operations Screen I only see Hard States
Just thought I'd share this one as I saw in a previous post that there was some interest, and the solution was kinda easy.
This works for my site as I only want hard states. I would expect an actual implementation in Nagios XI to give a hard/soft state option much like the 'Show Handled' option for Acked items.
Thanks
Steve B
As I was looking at the screen, I see it jumping around. Items appearing and vanishing often. It seems that the Soft and Hard states are both displayed.
Since our Data Center would go bonkers with that, as they only want to see when a Hard State has happened. I started looking at the forum for answers and found an older post. https://support.nagios.com/forum/viewto ... 0&p=159376
In my opinion (and we all have one) a Data Center screen should only reflect Hard States. Soft States come and go. Until they are Hard we do not do anything with them. Hard states prevent false alarms, we hope.
So, to deal with this since adding to the URL in this case does not work... (...adding &serviceattr=262144 to any URLs) I dug in to see what I could do. I noticed in the opscreen component directory a file named merlin.php that had the SQL queries used to display the columns. That is where I made a change.
Code: Select all
cd /usr/local/nagiosxi/html/includes/components/opscreen
vi merlin.php
For the Host to only show Hard States - somewhere near line 50 - change the select.
I added the following line
$query .= "AND nagios_hoststatus.current_check_attempt = nagios_hoststatus.max_check_attempts ";
Code: Select all
$query = "SELECT ";
$query .= " obj1.name1 AS host_name, ";
$query .= " nagios_hosts.alias, ";
$query .= " current_state, ";
$query .= " problem_has_been_acknowledged ";
$query .= "FROM nagios_hoststatus ";
$query .= "LEFT JOIN nagios_objects AS obj1 ";
$query .= " ON nagios_hoststatus.host_object_id=obj1.object_id ";
$query .= "LEFT JOIN nagios_hosts ";
$query .= " ON nagios_hoststatus.host_object_id=nagios_hosts.host_object_id ";
$query .= "WHERE current_state!='0' ";
$query .= "AND nagios_hoststatus.current_check_attempt = nagios_hoststatus.max_check_attempts ";
if ($hide_ack_down) {
$query .= "AND problem_has_been_acknowledged='0' ";
$query .= "AND scheduled_downtime_depth='0' ";
}
I added the following line
$query .= "AND nagios_servicestatus.current_check_attempt = nagios_servicestatus.max_check_attempts ";
Code: Select all
$query = "SELECT ";
$query .= " obj1.name1 AS host_name, ";
$query .= " obj1.name2 AS service_name, ";
$query .= " nagios_servicestatus.current_state, ";
$query .= " nagios_servicestatus.last_hard_state, ";
$query .= " nagios_servicestatus.output, ";
$query .= " nagios_servicestatus.last_hard_state_change, ";
$query .= " nagios_servicestatus.last_check, ";
$query .= " nagios_servicestatus.problem_has_been_acknowledged, ";
$query .= " nagios_hosts.address as ha, ";
$query .= " nagios_hoststatus.problem_has_been_acknowledged AS hack, ";
$query .= " nagios_services.service_id as sid, ";
$query .= " nagios_servicestatus.servicestatus_id as ssid, ";
$query .= " nagios_hosts.host_object_id AS hid ";
$query .= "FROM nagios_servicestatus ";
$query .= "LEFT JOIN nagios_objects AS obj1 ";
$query .= " ON nagios_servicestatus.service_object_id=obj1.object_id ";
$query .= "LEFT JOIN nagios_services ";
$query .= " ON nagios_servicestatus.service_object_id=nagios_services.service_object_id ";
$query .= "LEFT JOIN nagios_hosts ";
$query .= " ON nagios_services.host_object_id=nagios_hosts.host_object_id ";
$query .= "LEFT JOIN nagios_hoststatus ";
$query .= " ON nagios_hosts.host_object_id=nagios_hoststatus.host_object_id ";
$query .= "WHERE 1 ";
$query .= "AND nagios_servicestatus.current_check_attempt = nagios_servicestatus.max_check_attempts ";
$query .= "AND nagios_servicestatus.current_state!='0' ";
if ($hide_ack_down) {
$query .= "AND nagios_servicestatus.scheduled_downtime_depth='0' ";
$query .= "AND nagios_servicestatus.problem_has_been_acknowledged='0' ";
$query .= "AND nagios_hoststatus.problem_has_been_acknowledged='0' ";
$query .= "AND nagios_hoststatus.last_hard_state='0' ";
$query .= "AND nagios_hoststatus.current_state='0' ";
}
Just thought I'd share this one as I saw in a previous post that there was some interest, and the solution was kinda easy.
This works for my site as I only want hard states. I would expect an actual implementation in Nagios XI to give a hard/soft state option much like the 'Show Handled' option for Acked items.
Thanks
Steve B