Hi,

I would like to monitor scheduled tasks in Windows Server 2003. I need the "last run time" and the "last result code" as channel data and a warning if "last run time" is older than xx minutes or "last result code" <> "0x0" I have read hint to add log file creation to the task but this not good because in this case the "last result code" will not the same as the application exit code.


Article Comments

Hello,

you would have to have the scheduled task also to write the 'Last Result Code' into the or a file, and read it with the Logfile Content Check Sensor.

Best Regards.


Mar, 2011 - Permalink

Hi,

Just this is my question! The Last result code will generate when my task finished. (Eg exit or error code.) I can not read this value and write into a file by another task. How can I access this value Windows has the log file c:\windows\tasks\SchedLgU.Txt but this have some problem: - can not be read by Logfile Content Check Sensor (access error) - a bit chaotic content: not the last line the last event - it has a line 'exit code (<error code>)' if the task run and has error code but not if the task can't start for example if file not exit on the shared folder


Mar, 2011 - Permalink

Then you might have to program equivalent debugging code and information into the "application" started in the scheduled task so that this one itself created a valuable logfile. Otherwise, it might simply be not possible.


Mar, 2011 - Permalink

Thanks for your Tip I will do it...


Mar, 2011 - Permalink

PTF.ScheduledTask

This is possible with Custom Sensor PTF.ScheduledTask. This sensor returns the number of minutes since the last run of the specified task

-c=   The ip-address or hostname of the computer running the task.
-t=   The name of the task.
-x=   Optional exit code of the task to monitor.
-u=   Optional Domain\Username.
-p=   Optional Password or PassHash

To monitor task "defrag drive c:" on computer "myserver" use:

-c=myserver -t="defrag drive c:"

Optionally provide credentials of an account that can access the Scheduled Taks information and the exit code that the task should return under normal circumstances

The sensor can be downloaded from this page.


Mar, 2011 - Permalink

I've been checking this out and I am not sure its working correctly with Windows 2008. For instance:

schtasks command on the server:
Folder: \
TaskName                                 Next Run Time          Status
======================================== ====================== ===============
Database Backup                          5/29/2011 3:00:35 AM   Ready
Inventory                                5/31/2011 12:19:10 AM  Ready

Running the ptf exe manually

ScheduledTask.exe -c=servername -t="Inventory" -x=0 -u=domainname\username -p=h:/k7ULyAHIpzNhSeIRqWMgw== (passwordhash)

Task Inventory not found on host servername

Now, I've obviously left out the actual values above, but it does seem like its not reading the tasks on Windows 2008

When I deliberately change the password hash, it gives me the impersonation error so I know the account information is correct.


May, 2011 - Permalink

Hi Mark,

This bug is supposed to be fixed in version 8.0.2 of the sensor, that somehow never was published :-(. Please download this version and let me know if this solves your problem.


May, 2011 - Permalink

Hello!

I cannot find the PTF.ScheduledTask custom sensor at the link provided: http://code.google.com/p/prtg-addons/wiki/PTF_Custom_Sensors

Was this removed or discontinued?


Nov, 2012 - Permalink