Guides‎ > ‎Common Checks‎ > ‎

Scheduled Tasks

Here is an example of making sure that a scheduled task (Test_Task) is running as per it's schedule. On the Windows machine, the tasks runs every 5 minutes. The following check will alert if the last run time is more than five minutes (when it last started).

Additional configuration:

NSClient++ 0.3.9
  • In nsc.ini
    • CheckTaskSched2.dll
  • Needs to be UN-commented

NSClient++ 0.4.1
  • Open a command prompt
  • Type cd "\Program Files\NSClient++\" and press Enter
  • Type nscp settings --activate-module CheckTaskSched2 --add-defaults and press Enter

NSClient++ 0.4.2 onwards
  • Open a command prompt
  • Type cd "\Program Files\NSClient++\" and press Enter
  • Type nscp settings --activate-module CheckTaskSched --add-defaults and press Enter


Then restart the NSClient++ service.


NSClient++ 0.3.9 & 0.4.1 - Windows
Command:
check_nrpe -H 192.168.142.137 -t 30 -c CheckTaskSched -a "filter=title eq 'Test_Task' AND most_recent_run_time < -5m" "syntax=%title%: Last Run Time = %most_recent_run_time% GMT" MaxCrit=1

Output When Task Is Running To Schedule:
OK: All scheduled tasks are good.|'eventlog'=0;0;1

Output When Task Is NOT Running To Schedule:
Test_Task: Last Run Time = Monday, April 13, 2015 00:55:03 GMT, eventlog: 1 > critical|'eventlog'=1;0;1



NSClient++ 0.4.2 onwards - Windows
Command:
check_nrpe -H 192.168.142.137 -t 30 -c check_tasksched -a "filter=title eq 'Test_Task'" 'critical=most_recent_run_time < -5m' empty-state=critical 'empty-syntax=CRITICAL: Test_Task NOT found' 'detail-syntax=${title} is stale more than -5m'

Output When Task Is Running To Schedule:
OK: All tasks are ok|'Test_Task_exit_code'=0;0;0 'Test_Task_most_recent_run_time'=1461632103;0;1461632019

Output When Task Is NOT Running To Schedule:
CRITICAL: Test_Task is stale more than -5m|'Test_Task_exit_code'=0;0;0 'Test_Task_most_recent_run_time'=1461631503;0;1461631793

Output When Task Is NOT found
CRITICAL: Test_Task NOT found


Note: In your nagios config detail-syntax=${title} will need to be detail-syntax=$${title} for it to work (two $$ signs).