Monitor-Backlog and take actions with custom conditions

3 04 2014

Hi Again,
I needed a quick way to place a folder where files from clients in my environment are being constantly sent and imported elsewhere under closer watch for backlogging and performance troubleshooting, the responsiveness of a business process was reliant on how fast the files from the clients gets processed,
I wanted the following abilities:
– it had to be temporary as I just wanted to get a rough idea on the times of day I get bottlenecks if any
– I didn’t want to interrupt / burden the server with too frequent queries
– I wanted to do something that I can use later / recycle in some form for other uses
– I had to get an idea visually of how bad things are meaning i needed couple of condition (severities)

The script below is configurable just that way, you can set the path (where to look), the kind of check (what to look for), how frequently?, where to report?, what to report?, set different conditions (if backlogged 50 files then do that, if backlogged 150+ files do this)

As You can see in the script below,
Running the ps1 will check every 60 sec. The number of files in the folder, if the number of files is larger than 50 it will log and “info” severity log line, if it’s more than that it will log “error” and “warning” type of log lines.

TIP: a very useful to read logs is with trace32 that comes with SMS toolkit as it will auto highlight yellow and red where the text read “warning” and “error” respectively.

Comments are very much welcome.

The log will look something like this:













The script is also available here:

#Params (Frequency of checks, Path to check, path to log file, check)
$Sleep_MS = 60
$Path = “\\server\C$\Program Files (x86)\BigFix Enterprise\BES Server\FillDBData\BufferDir\”
$Log_Path = “\\server\C$\Program Files (x86)\BigFix Enterprise\BES Server\FillDBData\BacklogMonitor.log”
$Check = (Get-ChildItem $Path -recurse | Where {!$_.PSIsContainer}).count
while ($check -ge 0)
sleep $Sleep_MS
$check = (Get-ChildItem $Path -recurse | Where {!$_.PSIsContainer}).count
if ($check -lt 50) {continue}
$Date = Get-Date
$log = "Info:At $Date file count was high - file amount was: $check"
$log_warning = "Warning: At $Date file count was high - file amount was: $check"
$log_error = "Error: At $Date file count was high - file amount was: $check"
if ($check -gt 50 -and $check -lt 150) {$log | Out-File -Append -FilePath $Log_Path}
if ($check -gt 150 -and $check -lt 1000) {$log_warning | Out-File -Append -FilePath $Log_Path}
if ($check -gt 1000) {$log_error | Out-File -Append -FilePath $Log_Path}



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: