DESCRIPTION:
Sometimes you need to know when a certain quantity of old files are sitting in a folder and shouldn’t be. For example, a daily process normally moves/transfers files to a different server but somehow it missed one.
INSTRUCTIONS:
- Download this DataSource file and add it into your LogicMonitor account (Settings > DataSource > Add > From file)
- Set these properties on the device so the datasource ‘applies to’ some device (for example)
file_spec = \\server1\share\*.txt
minutes_age = 33 - If desired, set the threshold to alert you on a certain quantity of files. Do this by setting the datapoint within the datasource as shown in screenshot.
Screenshot below shows datasource and related graph:
Below shows where to set threshold for Qty of files:
For the technically curious, below is the PowerShell script I’m using:
$file_spec="##file_spec##" $minutes_age = ##minutes_age## $file_list = Get-ChildItem -path $file_spec | where {($_.Lastwritetime -lt (date).addminutes(-$minutes_age)) -and (! $_.PSIsContainer)} Write-Host "The file list is... $file_list" # just show the list $Qty = @($file_list).Count # counts the qty in list Write-host "minutes_age threshold: $minutes_age" Write-host "qty of files older than threshold minutes: $Qty"
No comments