What do you, the community, feel is the best way to monitor for failed tasks?
I've been looking at some different ways to check for when a scheduled task fails... I'm unsure what the best option is, in that I see multiple ways of getting this information.
- An alert, monitoring for specific EventID's in the event viewer
- Parsing the output of SCHTASKS.EXE (which I'm having the most issues with -- specifically because of disabled tasks)
- Using the \Windows\Tasks\SchedLgU.txt file, which is kind of sparce..
Does anyone have a solid method they use for scheduled task failure alerting? What would be the best practice here?
I dont use the Windows task scheduler so cant help on how to monitor that for failures.
I sugest that it might be an idea to migrate the tasks from the Window Scheduler into K and run them as procedures. That way you can then provide better error checking and reporting.
On a Windows 2008 server you can monitor the Microsoft-Windows-TaskScheduler/Operational event log with a monitor set
You have to enable this eventlog type (agent – Event Log settings and assign the TaskScheduler)
Then Monitor - Agent Monitoing – Select Alert function - Alerts eventlogs Microsoft-Windows-TaskScheduler/Operational and create a new monitor set and also some ignore filters
On a 2003 server you can create a job and check the output
schtasks.exe /QUERY /FO LIST /V and check if the last results is different then 0
I'm with Peter, we're in the process of migrating our tasks to K. My reasoning being we only have to look in one place for the result, and if we need to change the task in anyway its in the same place our other tasks are.
The current scenario is such that we aren't able to migrate all of our tasks to Kaseya yet, and so we need a way to monitor them like Pim indicates...
Pim, I like the use of your SCHTASKS switches, however I'm not clear on 'how' you check the output? Is it within the Kaseya Procedure you use to generate the output, or do you need to then call a log parser so as to accommodate the tab spacing within the file I'm piping it to?
Another question for Pim:
Pim, I did what you said and was trying to build a Log Parser definition however the amount of data included in the output of that command is too many characters for Kaseya to handle the parser definition...
Any recommendations? The parser definition looked like this:
Next Run Time: $lastrun$
Logon Mode: $logonmode$
Last Run Time: M/D/YYYY H:M:S tt
Last Result: $lastresult$
Task To Run: $taskrun$
Start In: $startin$
Scheduled Task State: $taskstate$
Idle Time: $idletime$
Power Management: $powermanagement$
Run As User: $runuser$
Delete Task If Not Rescheduled: $deletetask$
Stop Task If Runs X Hours and X Mins: $stoptask$
Schedule Type: $scheduletype$
Start Time: $starttime$
Start Date: $startdate$
End Date: $enddate$
Repeat: Every: $repeatfreq$
Repeat: Until: Time: $repeatuntiltime$
Repeat: Until: Duration: $repeatuntilduration$
Repeat: Stop If Still Running: $repeatstopif$
If you change the command from Pim to this: schtasks.exe /QUERY /FO LIST /V |findstr /I "taskname result state" you will only get the following returned:
I'm trying to sort out now how I can get that information into a log parser so that I'll be alerted if the Last Result is a non zero value, but I'm not familiar with the log parser.