Concentrating command definitions

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
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Concentrating command definitions

Post by amprantino »

define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 10
}

# 'check-host-alive' command definition
define command{
command_name check-host-alive-ip
command_line $USER1$/check_ping -H $ARG1$ -w 3000.0,80% -c 5000.0,100% -p 10
}
Instead of defining two different commands , just for enabling $ARG1$ would it be feasible or easier to define something like:
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ | $ARG1$ -w 3000.0,80% -c 5000.0,100% -p 10
}

whatever is null would be ignored.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Concentrating command definitions

Post by tmcdonald »

I'm not sure what the use case is here - can you please clarify?
Former Nagios employee
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: Concentrating command definitions

Post by amprantino »

This is just an idea.

In my current nagios installation I have define the following command:
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 10
}
Suddenly i have to check host using a different IP that the $HOSTADDRESS$
So I have to define a different command replacing $HOSTADDRESS$ with $ARG1$
# 'check-host-alive' command definition
define command{
command_name check-host-alive-ip
command_line $USER1$/check_ping -H $ARG1$ -w 3000.0,80% -c 5000.0,100% -p 10
}
Wouldn't it be great if I could merge the above in a single definition as following:
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ | $ARG1$ -w 3000.0,80% -c 5000.0,100% -p 10
}
The null one should be ignored.
If both have value, the $ARG1$ should be preferred.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Concentrating command definitions

Post by tmcdonald »

I would think in that case it should be a separate host object, if it has a different IP. Otherwise just use $ARG1$ and drop $HOSTADDRESS$ altogether. I think this would be too much work for a problem that, at least in my opinion, can be solved by different host definitions.
Former Nagios employee
Locked