Page 1 of 1

Concentrating command definitions

Posted: Fri Sep 30, 2016 7:08 am
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.

Re: Concentrating command definitions

Posted: Fri Sep 30, 2016 9:49 am
by tmcdonald
I'm not sure what the use case is here - can you please clarify?

Re: Concentrating command definitions

Posted: Fri Sep 30, 2016 12:19 pm
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.

Re: Concentrating command definitions

Posted: Fri Sep 30, 2016 12:32 pm
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.