Page 1 of 1

Monitoring File count using wmi/nrpe/command

Posted: Wed Feb 10, 2021 12:54 pm
by linearstack
Hi

I want to setup monitoring of file count in a particular folder using wmi/command/nrpe.
Can you please advise how can setup using command or plugin etc.

I tried this using check command "check_file_service".
I created a new command as:
$USER1$/folder_watch.pl -H $HOSTADDRESS -u $ARG1$ -p $ARG2$ -f $ARG3$ -D $ARG4$ $ARG5$

where Arguments are as:

ARG1 = 'username'
ARG2 = 'password'
ARG3 = files
ARG4 = C:\test (path of folder which we want to monitor files)
ARG5 = -F '[^\0] ' -w 5 -c 10

Can you please advise how to fix this or if there is any other way to achieve this?

Thanks

Re: Monitoring File count using wmi/nrpe/command

Posted: Thu Feb 11, 2021 5:41 pm
by benjaminsmith
Hi,

Do you have NSClient installed on the remote Windows System? We have helpful examples on the following page.

See: File And Folder Checks

For NSLCIent, the check command would look like:

Code: Select all

./check_nrpe -H 10.25.14.2 -c check_files -a path='C:\\Temp' pattern=*.* 'warning=count>500' 'critical=count>1000' top-syntax='${status}: ${count} files found' 'empty-state=ok'
For the case of WMI, you can check the folder size, for example.

Code: Select all

./check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p Str0ngP@ssw0rd -m checkfoldersize -a C:/Temp
Let us know which approach you'd like to use and if you need assistance.

Benjamin

Re: Monitoring File count using wmi/nrpe/command

Posted: Mon Feb 15, 2021 1:29 am
by linearstack
Thanks for replying.
We are actually monitoring it using WMI.
With WMI we want to set the monitoring of number of files in folder rather than folder size.

Re: Monitoring File count using wmi/nrpe/command

Posted: Mon Feb 15, 2021 4:11 pm
by ssax
You should be able to do this which checks the count:

CRITICAL if count greater than 10:

Code: Select all

./check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p 'Str0ngP@ssw0rd' -m checkfoldersize -a C:/Temp -c _ItemCount=10
CRITICAL if count less than 10:

Code: Select all

./check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p 'Str0ngP@ssw0rd' -m checkfoldersize -a C:/Temp -c _ItemCount=10:
You can change 10 to whatever you'd like:

https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT