Page 2 of 2

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 2:33 am
by cocoyanouck
Hum, I'm working on Nagios 4.1.1 on a Debian Jessie, i think it's different to Nagios XI server no ??

So, today, i've in command.cfg :

Code: Select all

define command{
       command_name        check_nrpe
       command_line          $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

define command{
        command_name      CheckNumberFiles
        command_line         $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}
In windows.cfg, I've tested 2 services, the first like my colleague used it on our old Nagios Windows, the second like this is written on check_files.vbs in the directory script to NSCLIENT++ 0.4.4 :

Code: Select all

define service{
     use                              generic-service
     host_name                   NAME OF MY SERVER
     notification_interval     20
     service_description      Number of files on Request
     check_command          CheckNumberFiles!check_files!/path:"c:\\GESTION\\REQUEST" /searchdepth:1 /selage:ignore /warning:5 /critical:10
}

define service{
     use                              generic-service
     host_name                   NAME OF MY SERVER
     notification_interval     20
     service_description      Number of files on Request 2
     check_command          check_nrpe!check_files!/path:"c:\\GESTION\\REQUEST" /searchdepth:1 /selage:ignore /warning:5 /critical:10
}
====> When i restart nagios and test it : I've on the both services,
Number of files on Request
UNKNOWN 12-04-2016 09:27:19 0d 0h 17m 15s 3/3 Invalid command line: unrecognised option '/path:c:GESTIONREQUEST'
Number of files on Request 2
UNKNOWN 12-04-2016 09:22:12 0d 0h 12m 22s 3/3 Invalid command line: unrecognised option '/path:c:GESTIONREQUEST'

So, when i run the command in /usr/local/nagios/libexec : ./check_nrpe -H @IPofmyserver -c check_files -a path=c:/GESTION/REQUEST
for the FIRST TIME, it works !!! and the output is :
OK: All 2 files are ok.

But i still not understand what I need to wrote on path in the descriptions of the service :(

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 2:39 am
by Box293
cocoyanouck wrote:In windows.cfg, I've tested 2 services, the first like my colleague used it on our old Nagios Windows, the second like this is written on check_files.vbs in the directory script to NSCLIENT++ 0.4.4 :
You don't need any special scripts to check files, NSClient++ has a module built in.

Check the amount of files in a folder (and sub-folders). Generate a warning if more that 500 files exist, critical if more than 1000 files exist.

Code: Select all

Command:
check_nrpe -H 192.168.142.1 -t 30 -c check_files -a path='C:\\NO BACKUP' pattern=*.* 'warning=count>500' 'critical=count>1000' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'

Output:
CRITICAL: 21778/22278 files|'count'=22278;500;1000
Lots of examples here:
http://sites.box293.com/nagios/guides/c ... es-folders

:!: Tip: before trying to make it working in a nagios config, make sure it works from the command line first. It'll make troubleshooting much easier.

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 4:55 am
by cocoyanouck
Thank you. I've ever seen this website and used this example.
check_nrpe -H 192.168.142.1 -t 30 -c check_files -a path='C:\\NO BACKUP' pattern=*.* 'warning=count>500' 'critical=count>1000' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'

So, when i test this command, it's perfect ! :
check_nrpe -H @IPmyserver -t 30 -c check_files -a path='C:\\GESTION\\REQUEST' pattern=*.* 'warning=count>5' 'critical=count>10' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
I also can modify the path like this, and it's works too :
check_nrpe -H @IPmyserver -t 30 -c check_files -a path='C:/GESTION/REQUEST' pattern=*.* 'warning=count>5' 'critical=count>10' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'

But when i modify windows.cfg to inser this command like a service :

Code: Select all

define service{
     use                              generic-service
     host_name                   NAME OF MY SERVER
     notification_interval     20
     service_description      Number of files on Request
     check_command          check_nrpe!check_files!/path='c:\\GESTION\\REQUEST' pattern=*.* 'warning=count>5' 'critical=count>10' top-syntax='${status}: ${problem_count}/${count} files' 'empty-state=ok'
}
I see in my web nagios interface this return : Number of files on Request
UNKNOWN 12-04-2016 11:47:19 0d 2h 40m 37s 3/3 Invalid command line: unrecognised option '/path=c:\GESTION\REQUEST'


It's awesome, I'm block since 1 week :/ arglllllll

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 4:59 am
by Box293
Simple argument mistake

Code: Select all

/path='c:\\GESTION\\REQUEST
This should be

Code: Select all

path='c:\\GESTION\\REQUEST

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 6:52 am
by cocoyanouck
Eureka !

Problem solved, thanks a lot !!!!!

Re: Check Number Files in a directory

Posted: Tue Apr 12, 2016 1:47 pm
by jolson
That's excellent to hear, I'll close it up!