Page 1 of 1

$ARGS1$ problem, using command's output as argument

Posted: Thu Nov 12, 2015 12:51 pm
by melmoth
I'm trying to figure out arguments substitution, but I don't seem to have found a solution to my problem.

Code: Select all

define command {
command_name             Command_A
command_line                /usr/local/nagios/libexec/check_snmp \
                                    -H '$HOSTADDRESS$' \
                                    -C public \
                                    -o 1.2.3.4.5.6.7.8 \
                                    -n \
                                     -w $ARG1$ \
			             -c $ARG2$
}

Code: Select all

define command {
command_name             Command_B
command_line                /usr/local/nagios/libexec/check_snmp \
                                    -H '$HOSTADDRESS$' \
                                    -C public \
                                    -o 1.2.3.4.5.6.7.9 \
                                    -n 
}

Code: Select all

define command {
command_name             Command_C
command_line                /usr/local/nagios/libexec/check_snmp \
                                    -H '$HOSTADDRESS$' \
                                    -C public \
                                    -o 1.2.3.4.5.6.7.10 \
                                    -n
}

Code: Select all

define service {
  service_description            MySuperservice
  hostgroup_name                MyHostgroup
  check_command                Command_A!Command_B!Command_C
}
Service MySuperservice should give me a warning if its value goes over that of Command_B, yet it doesn't!
Command_B and Command_C have been tested, and are giving numeric and correct values as output.

What I'm doing wrong?

Re: $ARGS1$ problem, using command's output as argument

Posted: Thu Nov 12, 2015 2:16 pm
by jdalrymple
melmoth wrote: check_command Command_A!Command_B!Command_C
While I can't find documentation that expressly forbids this type of check_command syntax - I've never seen it in use and would *NOT* expect it to work. Have you substituted numerical values in for Command_B and Command_C in your check_command? If you have and your check works I would say that the syntax of check_command is such that you can't do what you want.

Create a plugin.

Re: $ARGS1$ problem, using command's output as argument

Posted: Thu Nov 12, 2015 10:21 pm
by Box293
check_cluster is probably the closest thing that that will do that out of the box:

https://assets.nagios.com/downloads/nag ... sters.html

Re: $ARGS1$ problem, using command's output as argument

Posted: Fri Nov 13, 2015 6:42 am
by melmoth
Thank you both for the help.
I can confirm the Command_B and Command_C are both working stand alone and returning numerical value. I can confirm Command_A is working when fed with a numerical value.
I tried to look at check_cluster, but from what I've understood it only checks against a string ("OK", "WARNING" and so on), not a numeric value, am I wrong?

Re: $ARGS1$ problem, using command's output as argument

Posted: Fri Nov 13, 2015 2:55 pm
by jdalrymple
I'm not sure what you're doing specifically, but it appears to me that this application wreaks of facilitation of a custom plugin.

If not, writing a simple wrapper plugin to provide the modularity you're seeking would be trivial.

Re: check_cluster - I do believe it is just a big AND/OR wrapper for multiple services. I don't believe it will pass in thresholds like you're seeking.

Re: $ARGS1$ problem, using command's output as argument

Posted: Sun Nov 15, 2015 7:59 pm
by Box293
melmoth wrote:Thank you both for the help.
I can confirm the Command_B and Command_C are both working stand alone and returning numerical value. I can confirm Command_A is working when fed with a numerical value.
I tried to look at check_cluster, but from what I've understood it only checks against a string ("OK", "WARNING" and so on), not a numeric value, am I wrong?
It checks the current state of the other services (0,1,2,3). It is not a if A is greater than B.

Probably check_multi is your next option to look at.

Re: $ARGS1$ problem, using command's output as argument

Posted: Wed Nov 18, 2015 8:56 am
by melmoth
Thank you guys, I solved with a quick and dirty bash script.
I'll take a look at check_multi which sound promising.

Re: $ARGS1$ problem, using command's output as argument

Posted: Wed Nov 18, 2015 10:24 am
by rkennedy
Glad to hear! I'll close this thread out now, but if you have any other questions feel free to open a new one.