Using NRPE to execute command with variables

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
fsbeaunix
Posts: 31
Joined: Mon Apr 20, 2015 2:58 pm
Location: Michigan, USA

Using NRPE to execute command with variables

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Using NRPE to execute command with variables

Post 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$
User avatar
fsbeaunix
Posts: 31
Joined: Mon Apr 20, 2015 2:58 pm
Location: Michigan, USA

Re: Using NRPE to execute command with variables

Post 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Using NRPE to execute command with variables

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
fsbeaunix
Posts: 31
Joined: Mon Apr 20, 2015 2:58 pm
Location: Michigan, USA

Re: Using NRPE to execute command with variables

Post 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
Locked