How to pass parameters properly to a command?

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
User avatar
henryhollow
Posts: 4
Joined: Mon Jul 25, 2016 1:25 pm
Location: Austria
Contact:

How to pass parameters properly to a command?

Post 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!
Last edited by henryhollow on Tue Jul 26, 2016 2:37 am, edited 1 time in total.
Calculations and conversions on CalculatePlus
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to pass parameters properly to a command?

Post 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.
Former Nagios employee
User avatar
henryhollow
Posts: 4
Joined: Mon Jul 25, 2016 1:25 pm
Location: Austria
Contact:

Re: How to pass parameters properly to a command?

Post 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!
Calculations and conversions on CalculatePlus
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to pass parameters properly to a command?

Post by tmcdonald »

Great to hear! Mind if we close this out?
Former Nagios employee
Locked