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

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
melmoth
Posts: 10
Joined: Thu Feb 19, 2015 12:03 pm

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

Post 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?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

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

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
melmoth
Posts: 10
Joined: Thu Feb 19, 2015 12:03 pm

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

Post 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?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

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

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
melmoth
Posts: 10
Joined: Thu Feb 19, 2015 12:03 pm

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

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

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

Post 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.
Former Nagios Employee
Locked