Page 1 of 1

NRPE and templates

Posted: Wed Mar 11, 2015 1:19 pm
by bbailey6
Hi,

I am trying to wrap my head around nrpe. I currently have it working but I feel like I am doing something wrong. I cant get any data back from hosts I am trying to monitor without adding flags to my nrpe.cfg.

What I have right now, which works is:

Code: Select all

command[check_swap]=/usr/local/nagios/libexec/check_swap -w $ARG1$ -c $ARG2$
is it possible to just have a generic nrpe.cfg on all the clients I want to monitor? i.e.:

Code: Select all

command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$ $ARG2$
and then just pass the arguments through the defined service on my nagios? What the heck am I doing wrong? Do I need to create a custom template for each plugin?

Thanks

Re: NRPE and templates

Posted: Wed Mar 11, 2015 1:22 pm
by tmcdonald
It is entirely possible to use arbitrary args, but be warned this can be a security risk:

http://www.thegeekstuff.com/2010/12/ena ... arguments/

Re: NRPE and templates

Posted: Wed Mar 11, 2015 1:54 pm
by bbailey6
Hi Donald,

I've set the don't blame nrpe flag to 1 and also compiled with the --enable-command-args option.

Actually, since its been a few weeks of playing with it, is there a way to see if I did in fact run ./configure --enable-command-args
?

thanks

Re: NRPE and templates

Posted: Wed Mar 11, 2015 2:13 pm
by jdalrymple

Code: Select all

[jdalrymple@localhost nrpe-2.15]$ grep "enable-command-args" config.status
  with options \"'--enable-command-args'\"
  echo "running /bin/sh ./configure " '--enable-command-args' $ac_configure_extra_args " --no-create --no-recursion" >&6
  exec /bin/sh ./configure '--enable-command-args' $ac_configure_extra_args --no-create --no-recursion
If there is no output, you did not compile with the --enable-command-args flag

Re: NRPE and templates

Posted: Wed Mar 11, 2015 2:37 pm
by bbailey6
hi,
looks like its there

nrpe-2.15]# grep "enable-command-args" config.status
with options \"'--enable-command-args'\"
echo "running /bin/sh ./configure " '--enable-command-args' $ac_configure_extra_args " --no-create --no-recursion" >&6
exec /bin/sh ./configure '--enable-command-args' $ac_configure_extra_args --no-create --no-recursion

is it not possible to not add flags to my nrpe.cfg? id like to write all the custom services from the nagios side and all necessary flags there

I didn't install nrpe on the nagios side, only the client side. Do you have to install it on the nagios side with --enable-command-args?

Re: NRPE and templates

Posted: Wed Mar 11, 2015 3:58 pm
by jdalrymple
It's very possible - have you tried?

Code: Select all

[jdalrymple@localhost libexec]$ ./check_nrpe -H localhost -c check_disk -a '-w 20 -c 10 -p /'
DISK OK - free space: / 13338 MB (79% inode=92%);| /=3471MB;17689;17699;0;17709
[jdalrymple@localhost libexec]$ ./check_nrpe -H localhost -c check_disk -a '-w 20 -c 10 -p /boot'
DISK OK - free space: /boot 427 MB (93% inode=99%);| /boot=31MB;464;474;0;484

Re: NRPE and templates

Posted: Thu Mar 12, 2015 1:37 am
by Box293
I've struggled before with what you are trying to do.

This is how your generic command needs to be defined:

Code: Select all

command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$
Here's how you execute it from the nagios host:

Code: Select all

./check_nrpe -H remoteserver -c check_swap -a '-w 50 -c 20'
The key here is enclosing the arguments in single quotes. This means it is sent as one argument.

Re: NRPE and templates

Posted: Thu Mar 12, 2015 12:19 pm
by bbailey6
Box293:

Thank you very much. That was driving me mad!

Re: NRPE and templates

Posted: Thu Mar 12, 2015 12:31 pm
by jdalrymple
Sounds like this is resolved for you bbailey6?

Can we lock the thread?

Re: NRPE and templates

Posted: Thu Mar 12, 2015 12:33 pm
by bbailey6
Sure. And thanks!