Page 1 of 1
Hard State Only
Posted: Mon Apr 11, 2016 7:16 am
by marky1986
Hi,
I have done a lot of searching but haven't found a way of doing it...
I want to only know about hosts/services with hard states. Is there a way for the CGI to ignore soft state status's?
Thanks.
Re: Hard State Only
Posted: Mon Apr 11, 2016 7:22 am
by rhassing
If you configure the max_check_attempts to be just 1 it should go to hard state at the first attempt
Re: Hard State Only
Posted: Mon Apr 11, 2016 7:46 am
by marky1986
I should of explained...
I still want soft states in the background so for example max_check_attempts=3 and then go to hard state. But I don't want to know about the soft states, I'm only interested if there has been 3 "none OK" checks in a row and I don't want it displayed anywhere unless it hits hard state.
Re: Hard State Only
Posted: Mon Apr 11, 2016 9:09 am
by nozlaf
Re: Hard State Only
Posted: Mon Apr 11, 2016 9:59 am
by marky1986
It says I'm not authorised to view that forum. Any chance you can repost the answer?
Re: Hard State Only
Posted: Mon Apr 11, 2016 10:36 am
by rkennedy
It's because it falls under our customer forum. This is usually something only our customers do have access to. As it's a useful post by @Box293, here's a copy -
-----
I can tell you how to do it but it's a tad confusing.
Basically the URLs contain the key to it all. For example:
Code: Select all
http://xiproduction/nagiosxi/includes/components/xicore/status.php?show=services&servicestatustypes=28
This
&servicestatustypes=28 makes the page display with the filters
Service=Warning,Unknown,Critical.
If you look in this file
/usr/local/nagiosxi/html/includes/constants.inc.php you'll find this:
Code: Select all
// PSEUDO-STATES (USED IN LINKS, ETC)
define("SERVICESTATE_PENDING", 1);
define("SERVICESTATE_OK", 2);
define("SERVICESTATE_WARNING", 4);
define("SERVICESTATE_UNKNOWN", 8);
define("SERVICESTATE_CRITICAL", 16);
define("SERVICESTATE_ANY", 31);
4 (Warning) + 8 (Unknown) + 16 (Critical) = 28
So it should be a matter of defining an extra filter to only display hard states. You'll see this in the file:
Code: Select all
define("SERVICESTATUSATTR_HARDSTATE", 262144);
So you should be able to add
&serviceattr=262144 to any URL and it will only show you HARD states. However you still need the other filter, so it would be something like:
Code: Select all
http://xitest/nagiosxi/includes/components/xicore/status.php?show=services&servicestatustypes=28&serviceattr=262144
Which should show a filter like
Service=Warning,Unknown,Critical,Hard State,Hard State
/usr/local/nagiosxi/html/includes/constants.inc.php is a handy file to go digging in

Re: Hard State Only
Posted: Tue Apr 12, 2016 3:37 am
by marky1986
This is brilliant and sounds like exactly what I'm after...
However, I can't locate the above files/config in Nagios Core. Is this only applicable to XI?
Thanks.
Re: Hard State Only
Posted: Tue Apr 12, 2016 6:24 am
by nozlaf
Apologies I posted that just as I went to bed and didnt pay attention to the fact it was out of the XI forum and it was XI
you certainly can do the same thing with core using the status.cgi etc..
to show hosts with issues but not soft states use this
http://nagiosserver/nagios/cgi-bin/stat ... ops=262144
for services use &serivceprops=262144
this will work for any page which is generated by status.cgi
for a really good blog post about the status.cgi check out
http://roshamboot.org/main/guide-nagios-statuscgi/
Re: Hard State Only
Posted: Tue Apr 12, 2016 2:20 pm
by scottwilkerson
Thanks nozlaf!
for easy reading I'm going to put the URL in code
Code: Select all
http://<nagiosserver>/nagios/cgi-bin/status.cgi?hostgroup=all&style=hostdetail&hoststatustypes=12&hostprops=262144