Go to All Forums

Monitor Windows Scheduled Tasks

It would be extremely helpful in a server monitor to be able to monitor scheduled tasks.

 

Useful thresholds on scheduled tasks that I can think of would be

Running Status => x minutes/hours/days

Disabled Status => x minutes/hours/days

Last run time => x minutes/hours/days ago

Error code returned on last run - yes/no

Error code returned on last run => x runs

 

 

Like (4) Edit Delete Reply
Replies (11)

Re: Monitor Windows Scheduled Tasks

You can use custom plugin to monitor the scheduled tasks.

Please find attached ScheduledTask.zip. Please unzip this file and mention the name of the scheduled task to be monitored in the file "ScheduledTask.ps1" and copy paste the ScheduledTask folder into the plugins folder.
Eg: C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins

The scheduled task plugin contains the following metrics :

  • state_value: Current state of the task
  • numberOfMissedRuns : Number of task schedules that were missed from running
  • lastRunBefore : Time of previous schedule tasks performed
  • author : Task's owner
  • state : Description of the task state
  • lastRunTime : Previous date and time of the task scheduled
  • createdon : Task created time
  • errorCode : Error code of previous scheduled tasks

 

Attachments
ScheduledTask.zip
Size: 1.88 KB
Like (2) Reply

Re: Re: Monitor Windows Scheduled Tasks

Thank you.  If we want to monitor a bunch of scheduled tasks on a particular server would we setup an additional PS job for each or is there a way to create a list of tasks in one plugin?

Like (0) Reply

Re: Re: Re: Monitor Windows Scheduled Tasks

Hi,

For each server added, you will be able to monitor one plugin and each plugin can have up to 25 attributes. And, the Scheduled Task plugin that we have provided has around eight attributes. So if you would want to add and monitor multiple job tasks with the same metrics as given in the Scheduled Task plugin, it would exceed the default attribute limit. 

However, if you wish to know and monitor only the name and status of a scheduled task, it is possible to add them as a single plugin monitor.

Please let us know if this helps.

Thanks!

Like (1) Reply

Re: Re: Re: Re: Monitor Windows Scheduled Tasks

Thanks.  It appears that the powershell script uses the command Get-ScheduledTask which doesn't work in windows 2008 R2, which is most of our environment. Do you perhaps have an example that works in a batch file and uses schtasks which does work in windows 2008 R2.

Like (0) Reply

Re: Re: Re: Re: Re: Monitor Windows Scheduled Tasks

You can write a custom plugin to monitor the scheduled tasks. Please find attached ScheduledTask.zip. We have used schtasks command to get data. it will remove the Get-ScheduledTask dependency. So this plugin will work fine in Windows 2008 R2.

  1. Unzip this file
  2. Mention the name of the scheduled task to be monitored in "ScheduledTask.ps1".
  3. Now, copy paste the ScheduledTask folder into the plugins folder.
    Eg: C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins

Performance Metrics:

This plugin contains the following metrics:

  • lastRunBefore : Time of the previous schedule task that was performed
  • author : Task's owner
  • Status : Current state of the task
  • lastRunTime : Date and time of the previous scheduled task
  • Start_Date : The time when the task was initiated
  • errorCode : Error code of the previous scheduled task

Hope this helps. Let us know for further queries.

Thanks!

Attachments
ScheduledTask.zip
Size: 2.08 KB
Like (1) Reply

Re: Re: Re: Re: Re: Re: Monitor Windows Scheduled Tasks

Hello, 

I am attempting to use this on Server 2012 R2, and not seeing the correct stats being returned. 

Has there been an updates to this, or would this be unique to my environment?

 

Thanks! 

Like (0) Reply

Re: Re: Re: Re: Re: Re: Re: Monitor Windows Scheduled Tasks

Hi,

Could you please share the logs to support@site24x7.com to analyze the issue? 

It would be helpful for us to assist you better.

 

Thanks!

Like (1) Reply

Re: Re: Re: Re: Monitor Windows Scheduled Tasks

by Hugo

Hello.

"

However, if you wish to know and monitor only the name and status of a scheduled task, it is possible to add them as a single plugin monitor."

 

Could you please help doing this ?

Like (0) Reply

Re: Re: Re: Re: Re: Monitor Windows Scheduled Tasks

Hello,

We would like to know to how many tasks you would be monitoring. Because we have limitation on the plugin metrics, i.e., a maximum of 25 attributes only.  

So please let us know the count of the scheduled tasks you would like to monitor, and based on that we shall give you suggestions.

 

 

Regards,

Muralikrishnan

Like (0) Reply

Re: Re: Monitor Windows Scheduled Tasks

Does this utility also send alert email in case schedule task is failed or did not run?

Like (0) Reply

Re: Re: Re: Monitor Windows Scheduled Tasks

Hi,

Using this plugin, you can get alerts for scheduled task failures by setting a threshold for the metric "errorCode". If the metric errorCode is 0, it means the previously scheduled task was completed successfully; if the errorCode is greater than 0, it means the previously scheduled task failed.

This plugin script does not have the support to alert when the scheduled tasks do not run. We are currently working on providing in-depth Windows Scheduled Tasks Monitoring and we shall include this metric in that.

Hope this helps. Let us know for further queries if any.

Happy Monitoring!

 

Like (0) Reply

Was this post helpful?