Pass in varaible to nrpe

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
djs
Posts: 9
Joined: Tue Jan 06, 2015 11:12 am

Pass in varaible to nrpe

Post by djs »

Hi all,

I am trying to pass in a variable to an nrpe agent through nagios.

I have a nagios server and have defined a global environment variable e.g

Code: Select all

test_var=Hi
I can manually check that this varaible can be called by doing a

Code: Select all

./check_nrpe -H 123.456.7.8 -c pass_arg -a $test_var
However when I try and pass in arguments into the command e.g

Code: Select all

define service{
    use                        test-service
    host_name                  d3t
    service_description        Pass arg 1
    check_command              pass_arg_h!$test_var
}
It displpays "$" on the nagios webpage, does anybody know why this is and how variables can be passed in?

One aditional question if variables can be defined and called, is there any way to pass in a varaible that performs an action .eg

Code: Select all

define service{
test_var=`ls -l /etc/nagios/ | wc -l`

    use                        test-service
    host_name                  d3t
    service_description        Pass arg 1
    _YahooID    john32
    check_command              pass_arg_h!$test_var
}

Thanks in advance,
djs
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Pass in varaible to nrpe

Post by ssax »

Are you defining it in /usr/local/nagios/etc/resource.cfg?

If you are you should use:

Code: Select all

define service{
    use                        test-service
    host_name                  d3t
    service_description        Pass arg 1
    check_command              pass_arg_h!$test_var$
}
Instead of:

Code: Select all

define service{
    use                        test-service
    host_name                  d3t
    service_description        Pass arg 1
    check_command              pass_arg_h!$test_var
}
As far as it performing an action you would need to write a wrapper script that would perform the action that you would want to happen and then call the check command that you would want it to run.
Locked