Page 1 of 1

regexp and check_nrpe

Posted: Wed Dec 06, 2017 11:21 am
by derivry
Hello
I use check_nrpe version 3.2.0
and I want to use centreon plugin with regexp in the name of a process

When I use locally the plug-in it is working
./centreon_plugins.pl --plugin=os::linux::local::plugin --mode=process --warning= --critical=1: --warning-time= --critical-time= --filter-command='oacore|ov[a-z]d' --filter-arg= --filter-state=
OK: Number of current processes: 2 | 'nbproc'=2;;1:;0;

but when I try , even locally it is not working
./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins -a 'os::linux::local::plugin' 'process' " --warning= --critical=1: --warning-time= --critical-time= --filter-command='oacore|ov[a-z]d' --filter-arg= --filter-state="
CHECK_NRPE: Receive header underflow - only 0 bytes received (4 expected).

with no | and ' it is working
./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins -a 'os::linux::local::plugin' 'process' " --warning= --critical=1: --warning-time= --critical-time= --filter-command=oacore --filter-arg= --filter-state="
OK: Number of current processes: 1 | 'nbproc'=1;;1:;0;


In nrpe.cfg I have
command[check_centreon_plugins]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$

Is somebody have an idea
Thank for your help

Re: regexp and check_nrpe

Posted: Wed Dec 06, 2017 3:11 pm
by npolovenko
Hello, @derivry.

On your nrpe server please open: /usr/local/nagios/nrpe.cfg. Please make sure that the following config is enabled:

Code: Select all

dont_blame_nrpe=1
If you had to make a chnage don't forget to restart nrpe daemon:

Code: Select all

service nrpe restart
or 
service xinetd restart
Depending on your system.

Have you tried adding a backslash around the single qoutes that you want to pass as an argument?

Code: Select all

./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins -a 'os::linux::local::plugin' 'process' " --warning= --critical=1: --warning-time= --critical-time= --filter-command=\'oacore|ov[a-z]d\' --filter-arg= --filter-state="

If the above does not help you may split the command even further to avoid having quotes within quotes:

Code: Select all

command[check_centreon_plugins]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$ --filter-command='$ARG4$' $ARGS5$

Code: Select all

./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins -a 'os::linux::local::plugin' 'process' ' --warning= --critical=1: --warning-time= --critical-time=' 'oacore|ov[a-z]d' '--filter-arg= --filter-state='

Re: regexp and check_nrpe

Posted: Thu Dec 07, 2017 3:05 am
by derivry
merci de ces pistes, mais malheureusement aucunes ne fonctionnent

grep dont_blame_nrpe ../etc/nrpe.cfg
dont_blame_nrpe=1


1ere
/outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=os::linux::local::plugin --mode=process --warning= --critical=1: --warning-time= --critical-time= --filter-command=\'oacore|ov[a-z]d\' --filter-arg= --filter-state= --verbose
-bash: ov[a-z]d': command not found

2nde
grep check_centreon_plugin ../etc/nrpe.cfg
command[check_centreon_plugins]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$
command[check_centreon_plugins_process]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$ --filter-command='$ARG4$' $ARGS5$

./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins_process -a 'os::linux::local::plugin' 'process' ' --warning= --critical=1: --warning-time= --critical-time=' 'oacore|ov[a-z]d' '--filter-arg= --filter-state='
CHECK_NRPE: Receive header underflow - only 0 bytes received (4 expected).


[root@pritopn01 libexec]# ./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins_process -a 'os::linux::local::plugin' 'process' ' --warning= --critical=1: --warning-time= --critical-time=' \'oacore|ov[a-z]d\' '--filter-arg= --filter-state='
-bash: ov[a-z]d': command not found

Re: regexp and check_nrpe

Posted: Thu Dec 07, 2017 2:39 pm
by npolovenko
@derivry, The problem lays with this part: "oacore|ov[a-z]d". NRPE doesn't allow certain arguments, here's a list:"|`&><'\\[]{};\r\n".
So your options are to either hardcode the whole command in the command definition:

Code: Select all

command[check_centreon_plugins]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=os::linux::local::plugin --mode=process --warning= --critical=1: --warning-time= --critical-time= --filter-command='oacore|ov[a-z]d' --filter-arg= --filter-state=

./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins
Or split the command further, but leaving oacore|ov[a-z]d hardcoded.

Code: Select all

command[check_centreon_plugins]=/outillage/oi2centagent/perl/bin/perl /outillage/oi2centagent/plugins/centreon_plugins.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$ --filter-command='oacore|ov[a-z]d' $ARG4$

./check_nrpe -H 127.0.0.1 -p 15666 -t 300 -u -c check_centreon_plugins -a 'os::linux::local::plugin' 'process' ' --warning= --critical=1: --warning-time= --critical-time='  '--filter-arg= --filter-state='
*You may split the command in a different way, this is just an example.

PS: If you reply in English you'll save me some time on google translate :D

Re: regexp and check_nrpe

Posted: Fri Dec 08, 2017 3:53 am
by derivry
Sorry on my response in french

But for me it is impossible to split the command or to hardcode, the argument are different for each monitored server

There is not a possibility that nrpe let pass an unverified argument to a plugin with some special border characters, so I could pass a regexp to the plugin

Best regards

Re: regexp and check_nrpe

Posted: Fri Dec 08, 2017 2:25 pm
by npolovenko
@derivry, You can't, unfortunately, escape square brackets or a pipe sign with NRPE. Can you share the other command you're planning to run on the second server? Perhaps, we can come up with some pattern, maybe even instead of oacore|ov[a-z]d ---> $ARG3$|ov[$ARG4$]d, or something similar.

Re: regexp and check_nrpe

Posted: Mon Dec 11, 2017 2:41 am
by derivry
OK thanks for your response

:(

Re: regexp and check_nrpe

Posted: Mon Dec 11, 2017 2:33 pm
by npolovenko
@derivry, Not a problem. Let us know if we can close this thread.