Define ping severity for a Host Group

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
baietp
Posts: 3
Joined: Fri Mar 19, 2021 5:15 am

Define ping severity for a Host Group

Post 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!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Define ping severity for a Host Group

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
baietp
Posts: 3
Joined: Fri Mar 19, 2021 5:15 am

Re: Define ping severity for a Host Group

Post 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..
Attachments
nagios_ping.png
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Define ping severity for a Host Group

Post 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:

Code: Select all

--timeout=15:1
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
Former Nagios employee
https://www.mcapra.com/
baietp
Posts: 3
Joined: Fri Mar 19, 2021 5:15 am

Re: Define ping severity for a Host Group

Post 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
Locked