I am migrating some other checks from Nagios Core where I was using a check_wsc_filecount to alert if a file was present in a specific directory. I found a couple of examples but it isn't working. This directory should always be empty and if a file exists we need to be alerted. Here was my check from the Nagios Core:
# checks filecount - filename+path ! warn (-1 = < 1) ! critical (-1 = < 1)
define command {
command_name check_wsc_filecount
command_line $USER1$/check_wsc.pl -H $HOSTADDRESS$ -r <wmi_proxy_server> -t "filecount" -p "$ARG1$,$ARG2$,$ARG3$"
}
./check_wsc.pl -H <host> p -r <wmi_proxy_server> -t "filecount" -p D:\\ClassPathFiles\\webservices\\EAppSubmissionServices\\FileNotifications\\*.TXT,0,0
Result: OK; 0 files found|nbfiles=0;0;0;;
Here is what I am trying with Nagios XI:
check_nrpe -H <host> -t 30 -c CheckFiles -a path='D:\\ClassPathFiles\\webservices\\EAppSubmissinoServices\\FileNotificaitons\\*.TXT' pattern=*.TXT 'master-syntax={%total% Files Found}' MaxWarn=0 MaxCrit=0
No drives found|'count'=0;0;0
Not sure why I am getting No drives found.
./check_nrpe -H <host> -t 30 -c CheckDriveSize -a ShowAll
OK A:\: Total: 0B - Used: 0B (100%) - Free: 0B (0%), C:\: Total: 49.899GB - Used: 26.734GB (54%) - Free: 23.166GB (46%), D:\: Total: 124.997GB - Used: 86.868GB (70%) - Free: 38.129GB (30%), E:\: Total: 0B - Used: 0B (100%) - Free: 0B (0%), : Total: 99.996MB - Used: 30.789MB (31%) - Free: 69.207MB (69%)|'A:\ used'=0B;0;0;0;0 'C:\ used'=26.73367GB;39.91952;44.90946;0;49.89941 'C:\ used %'=53%;79;89;0;100 'D:\ used'=86.8682GB;99.99765;112.49736;0;124.99706 'D:\ used %'=69%;79;89;0;100 'E:\ used'=0B;0;0;0;0 '\\?\Volume{248ea391-cced-11e1-a507-806e6f6e6963}\ used'=30.78906MB;79.99687;89.99648;0;99.99609 '\\?\Volume{248ea391-cced-11e1-a507-806e6f6e6963}\ used %'=30%;79;89;0;100
I basically just need to check a directory and alert if a file is present. Is the NRPE client the best way to accomplish this with Nagios XI?
NRPE Check File count
Re: NRPE Check File count
The following command should work for you, assuming that you're running NSClient on your Windows machine.
Replace 192.168.x.x with the IP address of the Windows machine in question. Replace 'c:/emptydir' with the path that you'll be checking. This check will go into a critical status if it sees one or more files.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 192.168.x.x -c check_files -a path=c:/emptydir warning=count=1 critical=count=1Re: NRPE Check File count
Alternatively, you can achieve the same results with the "old" NSClient++ syntax (example):
Code: Select all
[root@localhost libexec]# ./check_nrpe -H 192.168.x.x -c CheckFiles -a path=C:/tmp MaxCrit=0
No files found|'count'=0;0;0
[root@localhost libexec]# echo $?
0
[root@localhost libexec]# ./check_nrpe -H 192.168.x.x -c CheckFiles -a path=C:/tmp MaxCrit=0
test.txt|'count'=1;0;0
[root@localhost libexec]# echo $?
2Be sure to check out our Knowledgebase for helpful articles and solutions!
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: NRPE Check File count
Just to extend on both answers provided I have several examples listed on my page here which shows the many ways CheckFiles works in NSClient++.
http://sites.box293.com/nagios/guides/c ... es-folders
http://sites.box293.com/nagios/guides/c ... es-folders
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: NRPE Check File count
Thanks you can close this one.