Page 1 of 1

How to monitor file size

Posted: Thu Nov 07, 2019 6:30 am
by Frédéric GRANAT
Hi,
I would like to monitor the size of a particular file, file located on a windows server.
By example :
If size != 0 : alert

In case of alert, I would like to send it to an email address.

Ideally I wouldn't like to install a component on my server (nrpe client,...etc)

What's the easiest way to perform that ?

Re: How to monitor file size

Posted: Thu Nov 07, 2019 12:01 pm
by mbellerue
We have some plugins on the Exchange that check the file size of files on SMB shares, or FTP servers. Maybe one of these could be useful?
https://exchange.nagios.org/index.php?o ... ile%20size

Another option would be to create a passive check. This would be more work without an agent like NCPA on the system. But not impossible. You could create a Powershell script to query WMI for the file size, and report back via NRDP on the Nagios XI server. Here is a document that shows more information about NRDP.
https://assets.nagios.com/downloads/nag ... erview.pdf

Here is an example Powershell command for getting the size of a file.

Code: Select all

(Get-WmiObject -Class CIM_LogicalFile -Namespace "root\cimv2" -Property "FileSize" -Filter "Name = 'C:\\Monitoring\\ReadHere\\blah.txt'").FileSize