regexp and check_nrpe

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
derivry
Posts: 6
Joined: Tue Jun 21, 2016 8:54 am

regexp and check_nrpe

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: regexp and check_nrpe

Post 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='
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
derivry
Posts: 6
Joined: Tue Jun 21, 2016 8:54 am

Re: regexp and check_nrpe

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: regexp and check_nrpe

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
derivry
Posts: 6
Joined: Tue Jun 21, 2016 8:54 am

Re: regexp and check_nrpe

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: regexp and check_nrpe

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
derivry
Posts: 6
Joined: Tue Jun 21, 2016 8:54 am

Re: regexp and check_nrpe

Post by derivry »

OK thanks for your response

:(
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: regexp and check_nrpe

Post by npolovenko »

@derivry, Not a problem. Let us know if we can close this thread.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked