Follow Mike's blog
Archives for the month of: April, 2016


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.


  1. Download this DataSource file and add it into your LogicMonitor account (Settings > DataSource > Add > From file)
  2. Set these properties on the device so the datasource ‘applies to’ some device (for example)
    file_spec =  \\server1\share\*.txt
    minutes_age = 33
  3. 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:

$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"


Sometimes people want to know if one of their co-workers or subordinates disabled a SQL job.


Download the datasource file and add it into to LogicMonitor (Settings > Datasources > Add > From file)

It should alert you if enabled is not 1. If you want to ignore some jobs, just click on that instance and turn off alerting or monitoring.

It’s set to use Windows Integrated Authentication but if you want to use SQL authentication, you can change the datasource and specifying a SQL username and password.


I did this with a datasource that uses JDBC collection type to run a SQL query on the database to list the jobs and show those job names as instances. The collection portion of datasource runs another SQL query for each of those jobs to retrieve the current setting for “enabled”.




This will alert you via LogicMonitor when a MS-SQL ‘job’ fails


  1. Create a LogicMonitor “EventSource”. Named “SQL job failures” or similar. I suggest that you clone the default “SQL eventsource”.  Set these settings:
    LogName   EQUAL    “Application”
    EventID    In    “1304|208”
    SourceName    Contains    “SQL”
  2. Use Microsoft’s SQL Management Studio to set each job on each of your SQL servers so that when a job fails, it will write a message to the Windows Application event log (screenshot below)
    Right click on job and click “Properties”
    Click on “Notifications” on left pane
    Click on “Write to Windows event logs” checkbox and click “When the job fails”
  3. Test. I suggest you create and run a bogus backup job to test. Look in the Windows Event viewer and you should notice an EventID 1304. 


Optional:  In LogicMonitor you can create an Alert rule that notifies a specific person or team. Do this by selecting the datasource name of the eventSource you named above

Below is screenshot showing how to create/clone a LogicMonitor EventSource


Below shows how to set “Write to event log” on each SQL Job


Below shows what the alert looks like in LogicMonitor.