Page 1 of 2
File Age Check
Posted: Fri Jul 07, 2017 2:28 pm
by kadaw978
Hi
I'm currently using NagiosXi 5.2.9 and NSCLIENT++ 0.5.0.62.
I'm trying to monitor a directory for a certain file type that is older than "X" minutes. The check that I'm currently using is, but it looks like the pattern option is deprecated and ignored. Is there another way for me to monitor this?
Code: Select all
$USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFiles -a path=$ARG1$ pattern=$ARG2$ 'filter=written < $ARG3$' MaxCrit=1 'syntax=%filename%: %write%'
I also tried this, but looks like it only checks for a single file.
Code: Select all
$USER1$/check_nt -H 192.168..... -s "$ARG1$" -p 12489 -v FILEAGE -l "C:\test.txt" -w 45 -c 60
Re: File Age Check
Posted: Fri Jul 07, 2017 3:11 pm
by tgriep
Try this example and see if it works for you.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -t 30 -c check_files -a path='C:\\Temp\\' pattern=*.* 'filter=written < -5m' 'critical=count>0' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
I am running a fairly new version of the 4.x.x and not 5.x but you can see if it works for you.
Re: File Age Check
Posted: Fri Jul 07, 2017 3:19 pm
by kadaw978
tgriep wrote:Try this example and see if it works for you.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -t 30 -c check_files -a path='C:\\Temp\\' pattern=*.* 'filter=written < -5m' 'critical=count>0' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
I am running a fairly new version of the 4.x.x and not 5.x but you can see if it works for you.
I tried that command and its not returning any output. Nothing in the nsclient error log either.
Re: File Age Check
Posted: Fri Jul 07, 2017 3:28 pm
by tgriep
That is strange, it should return something.
Can you post what you ran?
Re: File Age Check
Posted: Mon Jul 10, 2017 10:28 am
by kadaw978
tgriep wrote:That is strange, it should return something.
Can you post what you ran?
This is what I ran. No output. Is it possible that my nsclient.ini file configurations is incorrect?
Code: Select all
COMMAND: check_nrpe -H xxx.xxx.xx.xxx-t 30 -c check_files -a path='E:\Apps\Test\' pattern=*.xml 'filter=written > -5m' 'critical=count>0' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
OUTPUT:
Code: Select all
; TODO
[/settings/default]
allowed hosts = xxx.xxx.xx.xxx
; TODO
[/settings/NRPE/server]
;ssl options = no-sslv2,no-sslv3
;verify mode = peer-cert
insecure = true
allow arguments = 1
allow nasty characters = 1
port = 5666
; TODO
[/modules]
CheckExternalScripts = 1
CheckHelpers = 1
CheckEventLog = 1
CheckNSCP = 1
CheckDisk = 1
CheckSystem = 1
NRPEServer = 1
NRPEClient = 1
NSClientServer = 1
Re: File Age Check
Posted: Mon Jul 10, 2017 10:59 am
by tgriep
Even it the NSClient++ agent is not running or misconfigured, the plugin should return some sort of output.
Also, in your command, you are missing some escaping needed for the path definition.
Try running this command like below
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -t 30 -c check_files -a path='E:\\Apps\Test\\' pattern=*.xml 'filter=written > -5m' 'critical=count>0' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
If it fails, post the output from it as well as the output from the following 2 commands.
Code: Select all
/usr/local/nagios/libexec/check_nrpe
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx
Re: File Age Check
Posted: Mon Jul 10, 2017 1:03 pm
by kadaw978
So, running it from the command line yields expected results. However, when I test this check/command through NagiosXI GUI I get no output and the following error, which doesn't make sense since the plugin does exist.
(Return code of 127 is out of bounds - plugin may be missing)
Code: Select all
./check_nrpe -H xxx.xxx.xx.xxx -t 30 -c check_files -a path='E:\\Apps\\Test\\' pattern=*.xml 'filter=written < -5m' 'critical=count>0' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
CRITICAL: 0/60 files|'count'=60;0;0
Code: Select all
./check_nrpe -H xxx.xxx.xx.xxx
I (0.5.0.62 2016-09-14) seem to be doing fine...
Re: File Age Check
Posted: Mon Jul 10, 2017 1:09 pm
by kadaw978
Nvm, I had to add the full path to the plugin for that command to get it to work. Let me see if the check is what I want. Close to closing this ticket.
I'm currently using this command, but it is recursively checking sub folder as well. Can you have a check that only checks a specific directory for a file type of *.txt that is >5 minutes old? Also, the output is returning something like CRITICAL CRITICAL: 0/3 files, shouldn't it be CRITICAL: 3/3 files?
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xx.xxx -t 30 -c check_files -a path='E:\\Apps\\Test\\' pattern=*.txt 'filter=written < -5m' 'critical=count>0' 'empty-state=critical'
Thanks
Re: File Age Check
Posted: Mon Jul 10, 2017 1:54 pm
by tgriep
When using the Test Check command button, sometimes it adds too much escaping to the command causing it to fail so create the command and check it under the Home > Service Details screen to see if it works.
I found this on the NSClient++ web site. Add the following to the command
that will limit the recursion for the folders to 1.
https://docs.nsclient.org/0.5.0/samples/index.html
Re: File Age Check
Posted: Mon Jul 10, 2017 2:07 pm
by kadaw978
Thanks for all your help.