Page 1 of 1

Using NRPE to execute command with variables

Posted: Mon Apr 10, 2017 3:17 pm
by fsbeaunix
I have the following command I want to run on several remote servers using NRPE. Something similar to the following:

command[check_http_json-int]=/usr/lib64/nagios/plugins/check_http_json --user administrator --pass foopass -u http://<some_url>.flagstar.com:4502/system/sling/monitoring/mbeans/java/lang/Memory.infinity.json -e {noname}.mbean:attributes.HeapMemoryUsage.mbean:attributes.used.mbean:value -w 1000000000 -c 3000000000

Of course, each server has different settings. The variables I want to set are:

_JSON_USER
_JSON_PW
_JSON_URL
_JSON_ELEMENT
_JSON_WARN
_JSON_CRIT

I know this is incorrect, but I imagine the configuration would look something like (assuming I can set soome Free Variables on the Host?):

command[check_http_json-int]=/usr/lib64/nagios/plugins/check_http_json --user $JSON_USER --pass $JSON_PW -u $JSON_URL -e $JSON_ELEMENT -w $JSON_WANR -c $JSON_CRITICAL

Is there some documentation you can direct me to how to use pass some variables to a remote host? I'm not having much luck finding much.

Re: Using NRPE to execute command with variables

Posted: Mon Apr 10, 2017 3:50 pm
by ssax
Please see here:

Code: Select all

https://assets.nagios.com/downloads/nagiosxi/docs/Monitoring_Hosts_Using_NRPE.pdf
Basically you can run:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 192.168.232.22 -c check_http_json-int -a JSON_USER JSON_PW JSON_URL JSON_ELEMENT JSON_WARN JSON_CRITICAL
/usr/local/nagios/libexec/check_nrpe -H 192.168.232.22 -c check_http_json-int -a dave davespw www91 unsurewhatthisis 1000000000 3000000000
Then just set them up in the command:

Code: Select all

command[check_http_json-int]=/usr/lib64/nagios/plugins/check_http_json --user '$ARG1$' --pass '$ARG2$' -u http://$ARG3$.flagstar.com:4502/system/sling/monitoring/mbeans/java/lang/Memory.infinity.json -e {noname}.mbean:attributes.HeapMemoryUsage.mbean:attributes.used.mbean:value -w $ARG5$ -c $ARG6$

Re: Using NRPE to execute command with variables

Posted: Tue Apr 11, 2017 9:36 am
by fsbeaunix
Thank you for the reply.

I was pushing some variables using something similar to:

Code: Select all

command[check_http_json-int]=/usr/lib64/nagios/plugins/check_http_json --user '$ARG1$' --pass '$ARG2$' -u http://$ARG3$.flagstar.com:4502/system/sling/monitoring/mbeans/java/lang/Memory.infinity.json -e {noname}.mbean:attributes.HeapMemoryUsage.mbean:attributes.used.mbean:value -w $ARG5$ -c $ARG6$
Then setting up the command similar to:

Code: Select all

command[check_http_json-int]=/usr/lib64/nagios/plugins/check_http_json --user '$ARG1$' --pass '$ARG2$' -u http://$ARG3$.flagstar.com:4502/system/sling/monitoring/mbeans/java/lang/Memory.infinity.json -e {noname}.mbean:attributes.HeapMemoryUsage.mbean:attributes.used.mbean:value -w $ARG5$ -c $ARG6$
It worked as expected. I had nasty characters {}/ which I had to tweak, but otherwise it worked.

Thanks

Re: Using NRPE to execute command with variables

Posted: Tue Apr 11, 2017 10:01 am
by cdienger
Hi fsbeaunix,

It looks like you posted the same thing twice but had some success. Can you confirm and let us know if this thread can be locked?

Re: Using NRPE to execute command with variables

Posted: Wed Apr 12, 2017 9:12 am
by fsbeaunix
Yes, this thread can be locked.

My two takeaways were a) I was using incorrect syntax for the check_nrpe command, and b) the awareness of the NRPE "Nasty Characters" {}\/

Thanks