Check for new or modified files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Check for new or modified files

Post by hbouma »

We are being asked to check a Windows system for any new files or modified files created under a directory and its subdirectories.

I have been unsuccessful in creating my own plugin or finding a plugin so far that will work. Does anyone know of a plugin that does this, or have any suggestions about a plugin that may do what I need?

For our purposes, a modification to the date/time stamp will be enough to justify a failure condition, as well as a new file being created.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Check for new or modified files

Post by gsmith »

Hi

You could do something like this Powershell script:

Code: Select all

 Get-ChildItem -Path C:\ -Exclude 'C:\Windows\*','C:\PerfLogs\*' -File -Recurse | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-10/1440)}  | Select -First 1

where
-Exclude = skip these locations

{$_.LastWriteTime -gt (Get-Date).AddDays(-10/1440)} = get files modified in the last 10 minutes (10/1440)

Select -First 1 = stop after you find one. Don't use this if you want a list of files that are 10 minutes old or younger

Obviously there is more to it than this, but you could look at other powershell plugins to get how to
return required variables, etc.

Thanks
Locked