Page 1 of 1

folder_watch.pl with whitespace in path

Posted: Tue Dec 13, 2016 6:03 am
by chrisbooth
this works fine

Code: Select all

./folder_watch.pl -C 'ssh [email protected] ls -l /mnt/SAN_gskVideo/' -F '[^\0]+' -T 'dir'  -w 1 -c 5 -f
CRITICAL - [^\0]+ is 22 (more than 5) | '[^\0]+'=22;1;5;;;
but the sub-folder has whitespace in it's path

Code: Select all

./folder_watch.pl -C 'ssh [email protected] ls -l /mnt/SAN_gskVideo/Auto\ Archive/' -F '[^\0]+' -T 'dir'  -w 1 -c 5 -f
OK - 0 [^\0]+ files found | '[^\0]+'=0;1;5;;;
without the plugin this work

Code: Select all

[nagios@localhost libexec]$ ssh [email protected] ls -l '/mnt/SAN_gskVideo/Auto\ Archive/'
total 448
drwxr-xr-x 1866 root root 434176 Dec  5 22:07 Logs
drwxrwxrwx    3 root root      2 Dec 13 10:53 Problem Files
drwxrwxrwx    2 root root  24576 Dec  5 22:07 To Archive
but when i use that with the plugin it doesn't

Code: Select all

[nagios@localhost libexec]$ ./folder_watch.pl -C 'ssh [email protected] ls -l '/mnt/SAN_gskVideo/Auto\ Archive/'' -F '[^\0]+' -T 'dir'  -w 1 -c 5 -f
OK - 0 [^\0]+ files found | '[^\0]+'=0;1;5;;;
[nagios@localhost libexec]$

Re: folder_watch.pl with whitespace in path

Posted: Tue Dec 13, 2016 12:40 pm
by dwhitfield
Can you zip up the "/usr/local/nagios/libexec/folder_watch.pl" file, and upload it to the forum? I would like to compare it to the one we are using in house.

I already asked for your profile in one of your other threads, yes? The plugin won't be in the profile, so that's not a duplicate request. :)

Re: folder_watch.pl with whitespace in path

Posted: Tue Dec 13, 2016 3:39 pm
by chrisbooth
Here you go. I believe it came bundled with NagiosXI
folder_watch.pl

Re: folder_watch.pl with whitespace in path

Posted: Tue Dec 13, 2016 5:46 pm
by avandemore
That's because your quoting is different. Something like this should work:

Code: Select all

./folder_watch.pl -C 'ssh [email protected] ls -l "/mnt/SAN_gskVideo/Auto\ Archive/"' -F '[^\0]+' -T 'dir'  -w 1 -c 5 -f

Re: folder_watch.pl with whitespace in path

Posted: Wed Dec 14, 2016 5:07 am
by chrisbooth
ok that works great in the terminal

Code: Select all

./folder_watch.pl -C 'ssh [email protected] ls -l "/mnt/SAN_gskVideo/Auto\ Archive/Problem\ Files"' -F '[^\0]+' -T 'dir'  -w 0 -c 5 -f
but i'm noticing when i run a command test within nagios xi it's converting the "

Code: Select all

[[email protected] ~]# /usr/local/nagios/libexec/folder_watch.pl -C 'ssh [email protected] ls -l "/mnt/SAN_gskVideo/Auto\ Archive/Problem\ Files"'  -s 0,5 -f
Usage: /usr/local/nagios/libexec/folder_watch.pl [-v] [-t <timeout>] -D <directory> -F <files to check> -w <warn level(s)> -c <crit level(s)> [-a [<warn age>,<crit age>]] [-s [<warn size>,<crit size>]] [-S [<warn size>,<crit size>]] [-f] [-r] [-l] [-T files|dir] [-L label] [-V] [-H <hostaddress> | -I | -C <cmd that does &apos;ls -l>&apos;]
Screen Shot 2016-12-14 at 10.06.55.png
Screen Shot 2016-12-14 at 10.06.40.png

Re: folder_watch.pl with whitespace in path

Posted: Wed Dec 14, 2016 5:41 am
by chrisbooth
The service does work now tho!

it's just the check command seems to convert the "

..but that's not a deal breaker just something to note

Re: folder_watch.pl with whitespace in path

Posted: Wed Dec 14, 2016 8:05 am
by chrisbooth
Ok it now works as a check command also

thank you so much for the help

Re: folder_watch.pl with whitespace in path

Posted: Wed Dec 14, 2016 1:00 pm
by avandemore
Glad to hear it works. If you have further issues, please open a new thread.