Page 1 of 1
Define ping severity for a Host Group
Posted: Tue Mar 30, 2021 3:34 am
by baietp
Hello everybody!
I just installed EyesOfNetwork and configured Nagios with my WorkStations, Servers, and added them in some Host Groups.
My intention is to define the ping check severity to OK => "UP" and TIMEOUT => "WARN" for the users computers, but keep the default severity (OK => "UP" and TIMEOUT => "DOWN") for all other Host Groups, including servers.
Is there a way to do so ?
Thank you in advance and have a great day!
Re: Define ping severity for a Host Group
Posted: Tue Mar 30, 2021 9:35 am
by benjaminsmith
Hi,
Welcome to the Nagios Community Forum!
You would have to change the exit codes in the plugin ( make your own custom version).
Nagios Plugins Development Guidelines
Nagios State Types
Hope that helps get you started.
Benjamin
Nagios Support Team
Re: Define ping severity for a Host Group
Posted: Wed Mar 31, 2021 4:54 am
by baietp
Hello!
Thanks for your answer. I located a plugin directory but I was not able to edit exit codes because "check_ping" is not a regular sh script but some compilated language, and in dev guidelines I didn't found infos about plugins directory so I'm quite stuck here..
Re: Define ping severity for a Host Group
Posted: Wed Mar 31, 2021 11:08 am
by mcapra
I don't know much about EyesOfNetwork, and how it handles Nagios Plugin outputs. A lot of what is below assumes you're configuring checks in Nagios Core.
The first thing to understand is the difference between service checks and host checks:
https://assets.nagios.com/downloads/nag ... hecks.html
https://assets.nagios.com/downloads/nag ... hecks.html
Per
the specification, Nagios plugins must output 1 of 4 possible numeric statuses (as a POSIX exit code):
- 0 (OK)
- 1 (WARNING)
- 2 (CRITICAL)
- 3 (UNKNOWN)
How those numeric statuses get mapped to a particular host status of UP/DOWN/UNREACHABLE depends on your Nagios Core configuration:
https://assets.nagios.com/downloads/nag ... ility.html
One thing that is for certain is a host check can never be in a "WARNING" state -- per
the spec, this numeric code of 1 is either interpreted by Nagios Core as either UP, DOWN, or UNREACHABLE depending on some top-level Nagios Core configurations that cannot be overwritten at the hostgroup level (to my knowledge). If you want to leverage a WARNING state for use in alerting logic, you would need to configure this check as a service check. This service check could be applied to an entire hostgroup if you wanted -- see more in this post:
https://support.nagios.com/forum/viewto ... 83#p327983
If you were to configure these checks as service checks, using those standard 0/1/2/3 exit codes, the check_ping plugin does allow you to specify what exit code you want when a timeout is reached:
http://nagios-plugins.org/doc/man/check_ping.html
Code: Select all
-t, --timeout=INTEGER:<timeout state>
Seconds before connection times out (default: 10)
Optional ":<timeout state>" can be a state integer (0,1,2,3) or a state STRING
In your case, if you wanted to "warn" after a 15 second timeout, the argument passed to the check_ping plugin might look something like this:
If you want check_ping to behave in some way not supported by its accepted arguments, you'd have to fiddle around with the C and
recompile it:
https://github.com/nagios-plugins/nagio ... eck_ping.c
Re: Define ping severity for a Host Group
Posted: Thu Apr 01, 2021 4:04 am
by baietp
Hello,
Thanks for your detailed answer and precisions. I created a new command named check_ping_warn and a new Template only for workstations. It works, as the new command is applied only for workstations, but it still displays "DOWN" for hosts unreachable and hosts timed out after 11 seconds, even with the parameter "--timeout=5:1". But it's already a good beginning!
The complete command :
Code: Select all
$USER1$/check_ping -H $HOSTADDRESS$ -w 500.0,150% -c 100000.0,150% -p 1 --timeout=5:1