Hard State Only

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
marky1986
Posts: 6
Joined: Thu Feb 18, 2016 6:48 am

Hard State Only

Post 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.
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: Hard State Only

Post by rhassing »

If you configure the max_check_attempts to be just 1 it should go to hard state at the first attempt
Rob Hassing
Image
marky1986
Posts: 6
Joined: Thu Feb 18, 2016 6:48 am

Re: Hard State Only

Post 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.
User avatar
nozlaf
Posts: 172
Joined: Sun Nov 09, 2014 9:50 pm
Location: Victoria, Australia

Re: Hard State Only

Post by nozlaf »

Looking forward to seeing you all at #NagiosCon2019?
-Dedicated Lover of Nconf,PNP4Nagios and Nagvis
marky1986
Posts: 6
Joined: Thu Feb 18, 2016 6:48 am

Re: Hard State Only

Post by marky1986 »

It says I'm not authorised to view that forum. Any chance you can repost the answer?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Hard State Only

Post 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 :)
Former Nagios Employee
marky1986
Posts: 6
Joined: Thu Feb 18, 2016 6:48 am

Re: Hard State Only

Post 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.
User avatar
nozlaf
Posts: 172
Joined: Sun Nov 09, 2014 9:50 pm
Location: Victoria, Australia

Re: Hard State Only

Post 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/
Looking forward to seeing you all at #NagiosCon2019?
-Dedicated Lover of Nconf,PNP4Nagios and Nagvis
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Hard State Only

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked