Good day, I wanted to create a folder monitor for an empty folder and when the folder receives files, it will alert and send an email. Basically, we are using this as a way to alert our team of files that need to be processed in the folder.
Sounds like a powershell script running under a SAM template may be your ticket
As @bobmarley mentioned, you could run a PowerShell script. Alternatively you could use the File Count Monitor (there is an out-of-the-box template or you can add the component monitor to a new template). Specify the location and any filters and it will come back with a file count. You can set the thresholds to be warning or critical at greater than 0, and then set up an alert to monitor that specific application/component status.
https://documentation.solarwinds.com/en/success_center/sam/content/sam-file-count-monitor-sw3221.htm
Or you can use the File Exists component monitor but I think that only has a Down/Red option not a warning/critical.https://documentation.solarwinds.com/en/success_center/sam/content/sam-file-existence-monitor-sw4755.htm
Both @shuth and @bobmarley solutions should work for a file detection monitor. Since you mentioned that files are there when they need to be processed, I would probably go with Bob's approach. We have something similar in our environment that gets picked up by a different application and if a file is there for longer than X minutes, then we need someone to hop on and intervene.
Here is something we have used before. In the same monitor you set 2 script arguments, the first one is the file path. The 2nd one is the amount of time a file can exist before its considered stale.
So your script argument would be something like:
C:\Temp,10
Any file that exists in C:\Temp for more than 10 minutes would trip the alarm.
#Build out file path variable If ([String]::IsNullOrEmpty($Args[0])) { Write-Host "Message: File path [Argument 0] cannot be null" Exit 5 } Else { $FilePath = $Args[0] }#Build out Age variable Try{ Switch ([String]::IsNullOrEmpty($Args[1])) { "True" {[Int]$FileAge = 0} "False" {[Int]$FileAge = $Args[1]} } } Catch { Write-Host "Message: Error setting file age" Exit 5 }#Retrieve File Information Clear-Variable FileObj,FileCount -ErrorAction Ignore Try { $FileObj = Get-ChildItem -Path $FilePath -ErrorAction Stop | Where-Object {($_.PSisContainer -eq $False) -and ($_.LastWriteTime -lt ((Get-Date).AddMinutes("-$($FileAge)")))} $FileCount = ($FileObj | Measure-Object).count } Catch { Write-Host "Message: unable to retrieve files from $($FilePath) - $($Error[0].Exception)" Exit 1 }#SolarWinds Output Write-Host "Message: $($FileCount) objects exist in $($FilePath) | $($FileObj.Name -Join ',')" Write-Host "Statistic: $($FileCount)" Exit 0
This tends to work really well for local files. If its on a remote file share, milage will vary pending the permissions in place.
I would use Shuth solution, set the Warning or Critical level to Greater Than or Equal to 1The you can create an email alert based upon the file counter monitor targeting the correct Teams.if you are looking for a particular File Name or Extension, the change those element
ie. Only Log file. Entension "Log"Only MyLogfile_<Date>.* File Name "MyLogfile*", Extension "*"