Page 1 of 1

How to pass parameters properly to a command?

Posted: Mon Jul 25, 2016 2:05 pm
by henryhollow
Hi friends!

I'm wondering on how to pass arguments to a command properly.

Currently my service entry looks like this;

Code: Select all

define service {
        hostgroup_name                 production-sidekiq-worker
        service_description             Busy sidekiq workers
        servicegroups                     sidekiq-servers
        check_command	         check-sidkiq-json-stats!example.com!USER!PASSWORD
	use                                    generic-service
        notification_interval           0 ; set > 0 if you want to be renotified
}
And the command (which works fine on command line passing the params directly)

Code: Select all

# Check Sidkiq JSON stats
define command {
	command_name check-sidkiq-json-stats
	command_line $USER1$/check_http_json.py -B $ARG2$:$ARG3$ -H $ARG1$ -s -p sidekiq/stats -c "sidekiq.busy,@25:"
}
However this does not seem to work I get some "null" output.

Does anyone see the mistake maybe? Or can give me a hint on how to debug this?

Thank you very much in advance!

Re: How to pass parameters properly to a command?

Posted: Mon Jul 25, 2016 3:52 pm
by tmcdonald
What happens if you run the following?

Code: Select all

su nagios
cd /usr/local/nagios/libexec/
./check_http_json.py -B USER:PASSWORD -H example.com -s -p sidekiq/stats -c "sidekiq.busy,@25:"
making sure of course to substitute the path to the plugin, as well as the appropriate host, user, and password? I just want to make sure it is run correctly as the right user when done from the CLI. Please be sure to post the exact command you are running as well as the output. Blur out sensitive info if needed.

Re: How to pass parameters properly to a command?

Posted: Tue Jul 26, 2016 9:27 am
by henryhollow
Oh I didn't know that when I change my post above it would need to get re-approved by a moderator. Now I see the thread again. :-)

I think I simply made a typo somewhere. I restarted Nagios again and it just worked the way I showed it in the above code! Thank you very much for your help!

Re: How to pass parameters properly to a command?

Posted: Tue Jul 26, 2016 9:38 am
by tmcdonald
Great to hear! Mind if we close this out?