I have created a template that monitors several file locations and looks for a particular file. The problem is that the customer only wants it polled first thing in the morning so if it fails it can be fixed quickly. I have thought of a couple ways to do this but wanted to see if there were any other options.
1. set the polling interval to 24hrs and poll it fitst thing in the morning. My concern with this is that I don't know if this interval would be reset when the SolarWinds server reboots.
2. Poll it every 2 hrs or so but have the alert only run for a 2 hr window in the morning. This seems like a lot of overhead when the polling would fails 20 of 24 hrs a day.
[string]$path= "\\networkdrive\smart_update\ACE8\SmartUpdate Refresh Logs\*(COMPLETE).txt"
$minutes = 400
$stat=0
$msg=""
$LastWrite = $(Get-Date).AddMinutes(-$minutes)
$LastFile = $(Get-ChildItem $path | sort LastWriteTime | select -last 1)
$ModifiedTime = (Get-Item $LastFile).LastWriteTime
if($ModifiedTime -gt $LastWrite)
{
$stat = 0
$msg = "File recently updated"
Write-Host "Statistic: $stat"
Write-Host "Message: $msg"
Exit 0;
}
Else
{
$stat = 1
$msg = "File not recently updated. File was last updated $ModifiedTime"
Write-Host "Statistic: $stat"
Write-Host "Message: $msg"
Exit 1;
}