Page 1 of 1

Escaping plus

Posted: Tue Apr 15, 2014 9:15 am
by WillemDH
Hello,

I'm trying to use checkfilesize to check if the nsclient log grows.
How would I have to escape the plus sign?

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_nrpe -H servername -t 120 -c Checkfilesize -a ShowAll MaxWarn=10B MaxCrit=1M 'File=c:/Program Files/Nsclient\+\+ /nsclient.log'
OUTPUT: OK: c:/Program Files/Nsclient\\ \\ /nsclient.log: 0B|'c:/Program Files/Nsclient\\ \\ /nsclient.log'=0B;10;1048576
The command outputs OK, but in fact it doesn't find the file and thinks the size is zero bytes.

So I need to check c:/Program Files/Nsclient++/nsclient.log

Thanks for any advice

Willem

Re: Escaping plus

Posted: Tue Apr 15, 2014 9:56 am
by lmiltchev
I haven't been able to make this work with passing arguments on the nagios side of things, but maybe you can try setting up an alias in the NSC.ini (nsclient.ini) as such:

Code: Select all

; Check File Size
check_file_size=CheckFileSize ShowAll MaxWarn=10B  MaxCrit=1M "File=c:/program files/nsclient++/nsclient.log"
then run from the CLI:

Code: Select all

./check_nrpe -H servername -t 120 -c check_file_size
Here's what I got on my test box:

Code: Select all

[root@testbox libexec]# ./check_nrpe -H servername -t 120 -c check_file_size
CRITICAL: c:/program files/nsclient++/nsclient.log: 64.2M > critical|'c:/program files/nsclient++/nsclient.log'=67309773B;10;1048576

Re: Escaping plus

Posted: Wed Apr 16, 2014 4:24 am
by WillemDH
Hi Ludmil,

An alias does indeed seem to work. As I'd like to be able to give the maxwarn and maxcrit as a parameter, I tested also with:

Code: Select all

; alias_check_file_size_nsclientlog
alias_check_file_size_nsclientlog=CheckFileSize ShowAll $ARG2$ "File=c:/program files/nsclient++/nsclient.log"
But when testing I get

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_nrpe -H servername -t 120 -c alias_check_file_size_nsclientlog MaxWarn=25B  MaxCrit=1M
OUTPUT: Unknown argument: $ARG2$
Any tips on how to pass the maxwarn and maxcrit as $arg2$ to the alias?

Grtz

Willem

Re: Escaping plus

Posted: Wed Apr 16, 2014 4:43 am
by WillemDH
Ludmill,

Ok, I seem to have found it:

Made a command

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c alias_check_file_size_nsclientlog -a $ARG1$ $ARG2$
Changed the alias into

Code: Select all

; alias_check_file_size_nsclientlog
alias_check_file_size_nsclientlog=CheckFileSize ShowAll $ARG1$ $ARG2$ "File=c:/program files/nsclient++/nsclient.log"
And then pass MaxWarn as $ARG1$ and maxCrit as $ARG2$

And it seems to work fine. Thread can be closed!

Tx