Go to All Forums

Monitor multiple scheduled tasks?

Hello Site24/7,

How can I monitor multiple scheduled tasks? I only need to monitor last run time and last run result.

I noticed that you have a plugin/powershell script for this, but it's only working for one scheduled task?
 
I've also looked into this thread, but to no further success..
www.site24x7.com/community/monitor-windows-scheduled-tasks

Thanks in advance!
Sincerely,
Christoffer
Like (3) Reply
Replies (4)

Hi,

If you consider monitoring multiple ScheduledTasks, instead of using multiple ScheduledTask plugin scripts, you can define all the configurations and execute them all using a single plugin script file. To do so,

1. Unzip the attached file ScheduledTask.zip
2. Kindly update the ScheduledTask.json with the scheduled task name.

Sample JSON
{"RtHDVBg_PushButton":{"taskName":"RtHDVBg_PushButton"},"Adobe Acrobat Update Task":{"taskName":"Adobe Acrobat Update Task"},"AppleSoftwareUpdate":{"taskName":"AppleSoftwareUpdate","taskLocation":"\\Apple"}}
3. Create a folder ScheduledTask under Site24x7 plugins folder and place the plugin files ScheduledTask.ps1 and ScheduledTask.json inside the folder.

This will add the scheduled task plugins based on your configuration. For more help, refer our help documentation.

 

 

Regards,

Hisham

Attachments
ScheduledTask.zip
Size: 2.28 KB
Like (0) Reply

Greetings!

We've introduced the .cfg file to the Windows Scheduled Tasks plugin. You can now make changes to the ScheduledTask.cfg file and monitor metrics for multiple scheduled tasks as separate monitors.

Here are the metrics the plugin monitor tracks:

lastRunBefore: Time of Previous Schedule task performed

author: Task's owner

Status: Current state of the task

lastRunTime: Previous Datetime of Task Scheduled

Start_Date: Task Started time

errorCode: Error code of Previous Scheduled task

 

Prerequisites:

Download and install the latest version of the [Site24x7 Windows agent] (https://www.site24x7.com/app/client#/admin/inventory/add-monitor) in the server where you plan to run the plugin. 

Installation:

1. Visit our GitHub repository and download the .ps1 file and the .cfg file.

https://github.com/site24x7/plugins/tree/master/ScheduledTask

2. Modify the .cfg file with the task name to monitor the particular task:

For example:

[Scheduled_task]
taskName=\OfficeSoftwareProtectionPlatform\SvcRestartTask

Note: To fill in the task name in the .cfg file, add the location of the task you want to monitor from the General tab of Windows Task Scheduler followed by a slash and the task name.

3. To monitor multiple tasks, modify the .cfg file accordingly.

Here's an example below:

[Scheduled_task1]
taskName=\OfficeSoftwareProtectionPlatform\SvcRestartTask

[Scheduled_task2]
taskName=\Microsoft\Windows\AppId\Work Room

3. Create a folder ScheduledTask under Site24x7 Windows plugins directory and place the plugin files ScheduledTask.ps1 and ScheduledTask.cfg inside the folder.

C:\ProgramFiles(x86)\Site24x7\WinAgent\monitoring\Plugins\


The agent will automatically execute the plugin within five minutes and send performance data to the Site24x7 data center.

Feel free to reply to this thread for any clarification.

Happy monitoring!

Like (0) Reply

I am getting lots of errors after importing this script to S24x7, see the screenshot below:

Plugin errors

Does it actually work? We are trying to set up monitoring for failed scheduled tasks and this script looks promising.

 

Thank you for your help.

Like (0) Reply

Hi Sham,

Thanks for your post. 

After seeing the error, we suspect that ScheduledTask.ps1 script was modified. Because our actual ScheduledTask.ps1 present in the GitHub contain 151 lines. 

https://github.com/site24x7/plugins/blob/master/ScheduledTask/ScheduledTask.ps1

But in the screenshot you shared has error at lines 204 and 209. Please let us know, whether you modify the script, if it so share the modified script with us. We will work it out the script and give you the solution. 

Regards,
Muralikrishnan,
Product Manager,
Site24x7.
Like (0) Reply

Was this post helpful?