Same check, different parameters

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
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Same check, different parameters

Post by JohnFLi »

I think I know the answer to this already.....I just hope I'm wrong.

I am monitoring close to 200 hosts with Nagios..... depending on the system, a check that I do for every system may be different.
for example..... for some systems, a ping check needs to fail 5 times before alerting, on others, ping can fail 10 times, others, it will start alerting at 1 fail, etc, etc, etc.....
I really don't want to create seperate ping checks for each host......

(btw...using ping is just an example, but you get the idea.)

(on a side note, for my host alive....i check the WMI service instead of ping)
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same check, different parameters

Post by eloyd »

Try defining each host with a custom object macro (http://nagios.sourceforge.net/docs/3_0/ ... tvars.html) and you can then use that in the service definition to change the threshold based on the host.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Same check, different parameters

Post by JohnFLi »

Wouldn't that pretty much as creating a separate service definition for each one?
For example
Host1…… ping checks every 5 min, c drive check at 5 min, warn at 80%
Host2…. Ping checks every 1 min, c drive check at 1 min, warn at 90%

From what I understand, I need to make a service that defines ping for 5 min, a service that checks the c drive at 5 min, and the warning at 80%, a service that checks ping at 1 min, and another one for c drive every min and warn at 90%
I don’t see how the custom object macro’s are any different.
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same check, different parameters

Post by eloyd »

This may not specifically apply to you, but I offer it as a suggestion. So here's one way it might work:

(Note, these examples are Nagios "pseudo-code" style configs, not real configuration examples)

Code: Select all

define host {
  hostname x.domain.com
  _PING_EVERY 5
  _DRIVE_EVERY 5
  _DRIVE_WARN 80%
  hostgroup ping_hosts
}
define host {
  hostname y.domain.com
  _PING_EVERY 1
  _DRIVE_EVERY 1
  _DRIVE_WARN 90%
  hostgroup ping_hosts, drive_hosts
}

define service {
  service_name check_ping
  check_interval $_HOSTPING_EVERY
  hostgroups ping_hosts
}
define service {
  service_name check_disk
  check_interval $_HOSTDRIVE_EVERY
  check_command check_disk!$_HOSTDRIVE_WARN
  hostgroups drive_hosts
}

define command {
  command_name check_disk
  command $USER1$/libexec/check_disk <parameters> -w $ARG1$
}
define hostgroup {
hostgroup_name ping_hosts
members host1, host2
}
define hostgroup {
hostgroup_name drive_hosts
members host2
}
[/code]

This VERY NOT LEGAL CONFIGURATION example would make two hosts, assign one the the "ping_hosts" group and the second to the "ping_hosts" and "drive_hosts" group, create a service for ping and check_drive that are assigned to their respective groups, and use macros to determine how often things get pinged and what the values are for warning thresholds.

Edit: So no, you do not have to create a separate service for each one. What you DO have to do, though, is make sure you define the MACROS for each host that you will use in the service definitions. Much easier, overall. And once you start using hostgroups to determine what services run on which servers, you greatly simplify things as well.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Same check, different parameters

Post by JohnFLi »

I do use host groups, and have tried to group similar checks to be asigned to the hosts that they would apply to.

Thank you for your assistance.
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same check, different parameters

Post by eloyd »

You are welcome. Custom macros can be very powerful for doing different things for different hosts without the need for different service definitions.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Same check, different parameters

Post by JohnFLi »

I'm sure they are...... I am just not getting the concept of how they are different.

I might just need to think it through more.
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same check, different parameters

Post by eloyd »

Let me know if I can be of any further assistance. Perhaps with actual, real-world examples for you.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Same check, different parameters

Post by tmcdonald »

JohnFLi, are we clear to lock this thread up?
Former Nagios employee
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Same check, different parameters

Post by JohnFLi »

Yes, please close this
thank you
Everybody is somebody else’s weirdo
Locked