NRPE argument syntax

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
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

NRPE argument syntax

Post by gmills »

Hello,
I am sorry, once I think I get it, well.... boom, slammed down :)

Everytime I have a new NRPE command to implement I go through a heck of a time discoverying what works.
esp in the sense of using ' and " .

here is an exaple: ( works on both Nagios and NRPE )
on the Nagios server and the NRPE server I can issue the command line and get a successful return.

Code: Select all

./check_jmx4perl --user passthru --password B@dC0mpany --url http://localhost:9090/jolokia --mbean 'org.apache.camel:context=passthrumt1.inboundfile-com.ge.digital.passthru.mt1.inboundFile.CamelContext,type=context,name="com.ge.digital.passthru.mt1.inboundFile.CamelContext"' --attribute StartTimestamp
please notice the " " around the name in the MBean. now to get this to work on the local nagios server I need to encapsulate the entire MBean in single quotes ' .

Code: Select all

define service{
        use                             local-service
        host_name                       localhost
        service_description             Container Delta FADEC Context StartedRoutes
        check_command                   check_local_container_context!deltafadec!B@dM0nk3y!http://localhost:9093/jolokia!'org.apache.camel:context=delta-fadec-prod-fadec.Blueprint.Context,type=context,name="fadec.Blueprint.Context"'!StartedRoutes
        }
but this doesn't work for NRPE? I can't seem to get the correct syntax down for NRPE command service using quoting. I've tried so many variations.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_remote_container_route -a '--user passthru --password B@dC0mpany --url http://localhost:9090/jolokia --mbean 'org.apache.camel:context=passthrumt1.core-com.ge.digital.passthru.coreCamelContext,type=context,name="com.ge.digital.passthru.coreCamelContext"' --attribute ExchangesCompleted'

UNKNOWN - Error: 404 javax.management.InstanceNotFoundException : org.apache.camel:context=passthrumt1.core-com.ge.digital.passthru.coreCamelContext,type=context,name=com.ge.digital.passthru.coreCamelContext
This one below gets closer but still a miss

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_remote_container_route -a "-user passthru --password B@dC0mpany --url http://localhost:9090/jolokia --mbean 'org.apache.camel:context=passthrumt1.core-com.ge.digital.passthru.coreCamelContext,type=context,name="com.ge.digital.passthru.coreCamelContext" --attribute ExchangesCompleted"

CHECK_NRPE: Receive header underflow - only 0 bytes received (4 expected).

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_remote_container_route -a "-user passthru --password B@dC0mpany --url http://localhost:9090/jolokia --mbean 'org.apache.camel:context=passthrumt1.core-com.ge.digital.passthru.coreCamelContext,type=context,name='com.ge.digital.passthru.coreCamelContext' --attribute ExchangesCompleted"

CHECK_NRPE: Receive header underflow - only 0 bytes received (4 expected).
what am I missing, and again, I'm sorry this seems such a simple thing, I'm not getting.

It appears the NRPE server is stripping off the quote characters needed on the MBean - How do you maintain the quotes?
I've tried escaping \ \\ \\\ \\\\ this doesn't work, these are stripped out also. I see in the config that these are nasty characters.
ON the NRPE Server
here is the log on the NRPE server, shows it stripped off the quotes

Code: Select all

[1563400532] Host 3.239.245.209 is asking for command 'check_remote_container_context' to be run...

[1563400532] Running command: /usr/local/nagios/libexec/check_jmx4perl --user iprcmtx --password B@dC0mpany --url http://localhost:9091/jolokia --mbean org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name=com.ge.digital.fleet.coreCamelContext --attribute StartedRoutes ''
on the NRPE server if I take that command and run it as is, it fails because the MBean needs the quotes, If I put quotes back on the MBean, It works???
how do you pass such needed characters?

Code: Select all

/usr/local/nagios/libexec/check_jmx4perl --user iprcmtx --password B@dC0mpany --url http://localhost:9091/jolokia --mbean 'org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="com.ge.digital.fleet.coreCamelContext"' --attribute StartedRoutes
OK - [org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="com.ge.digital.fleet.coreCamelContext",StartedRoutes] : Value 11 in range | [org.apache.camel:context#fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type#context,name#"com.ge.digital.fleet.coreCamelContext",StartedRoutes]=11;;
thank you
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NRPE argument syntax

Post by gmills »

There must be a better way :) however, I've managed to get it to work, figured out.

if I split up the args passed and define them in NRPE as such, it forms the appropriate command.

this is what I did to get it to work.

here is the command I split up and run on the command line for testing purposes first.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_remote_container_context -a "--user iprcmtx" "--password B@dC0mpany" "--url http://localhost:9091/jolokia" "--mbean" "org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="  "com.ge.digital.fleet.coreCamelContext" "--attribute StartedRoutes"

OK - [org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="com.ge.digital.fleet.coreCamelContext",StartedRoutes] : Value 11 in range | [org.apache.camel:context#fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type#context,name#"com.ge.digital.fleet.coreCamelContext",StartedRoutes]=11;;
on NRPE

Code: Select all

command[check_remote_container_context]=/usr/local/nagios/libexec/check_jmx4perl $ARG1$ $ARG2$ $ARG3$ $ARG4$ '$ARG5$"$ARG6$"' $ARG7$
this executed this statement on the NRPE server and formed the correct command.

Code: Select all

[1563403774] Host 3.239.245.209 is asking for command 'check_remote_container_context' to be run...
[1563403774] Running command: /usr/local/nagios/libexec/check_jmx4perl --user iprcmtx --password B@dC0mpany --url http://localhost:9091/jolokia --mbean 'org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="com.ge.digital.fleet.coreCamelContext"' --attribute StartedRoutes
[1563403775] Command completed with return code 0 and output: OK - [org.apache.camel:context=fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type=context,name="com.ge.digital.fleet.coreCamelContext",StartedRoutes] : Value 11 in range | [org.apache.camel:context#fleet.mt1.core-com.ge.digital.fleet.coreCamelContext,type#context,name#"com.ge.digital.fleet.coreCamelContext",StartedRoutes]=11;;
So, I will configure this way. thanks so much again!!!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NRPE argument syntax

Post by scottwilkerson »

I'm glad you got it sorted out, I would have thought this would have worked as well (escaping the inner single quotes)

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_remote_container_route -a '--user passthru --password B@dC0mpany --url http://localhost:9090/jolokia --mbean \'org.apache.camel:context=passthrumt1.core-com.ge.digital.passthru.coreCamelContext,type=context,name="com.ge.digital.passthru.coreCamelContext"\' --attribute ExchangesCompleted'
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NRPE argument syntax

Post by gmills »

yeah, me too, it is the Security of NRPE I think, NRPE doesn't allow special or meta characters in the arguments, like \!?<> etc.. I found out. I think it is related to the dirty characters in argument macros.

so, to keep the dirty chars out, and keep the security manipolating the arguments passed to NRPE is good for me.

thanks again,

please close this case. have a great day, and just want to say you guys are great, the support and info offerings you provide are EXCELLENT !!!
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NRPE argument syntax

Post by mbellerue »

Thank you for posting your solution!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked