Why are there two modules for checking tasks?

The difference between the same command inside the wiki:CheckTaskSched module is that this one uses the Task Schedule API 2.0 which is only available on Windows Vista and beyond. Both commands will work on machines after Windows Vista but wiki:CheckTaskSched2 will not work on machines NT/XP machines. wiki:CheckTaskSched will not be able to see all tasks even when running on a Modern windows instead it will only see tasks created in compatibility mode.

CheckTaskSched

CheckTaskSched is part of the wiki:CheckTaskSched module. Requires 0.3.9

A command to check aspects on scheduled tasks it can be used to check one file but that is not the goal. The core scenario is: "do I have more then x files matching this criteria?" but it is flexible enough to be applicable in many other scenarios as well.

OptionValuesDescription
truncate Truncate return data (not performance data)
ignore-perf-dataA boolean flag to disable returning performance data
syntax%filename%The syntax of how each file is presented, can include the following tokens: %path%, %filename%, %creation%, %access%, %write%, %size%, %version%, %line-count%
master-syntax%list%The syntax for the returned message %list% (the list of syntax strings), %matches% (number of matched files), %files% (number of files total)
alias Alias for the check
debug Boolean flag to enable debugging
filterThe filter string (see below)
MaxWarnnumber of recordsThe maximum records to allow before reporting a warning state.
MaxCritnumber of recordsThe maximum records to allow before reporting a critical state.
warnnumber of recordsThe maximum records to allow before reporting a warning state. This is the exact version where you have more control then the Max/MinWarn? equivalent.
critnumber of recordsThe maximum records to allow before reporting a critical state. This is the exact version where you have more control then the Max/MinWarn? equivalent.

The CheckTaskSched command Uses filters to define the "interesting" tasks.

Syntax

The syntax is much like SQL where clauses for details on the syntax see the filters page.

Order

Order is somewhat important but mainly in the fact that some operations are more costly then others.

Filter Variables

<filter variable>ValuesDescription
titlestring_expression?Tasks name
accountstring_expression?User who runs the task
applicationstring_expression?The application
commentstring_expression?Retrieves the comment for the work item.
creatorstring_expression?Retrieves the creator of the work item.
parametersstring_expression?Retrieves the command-line parameters of a task.
working_directorystring_expression?Retrieves the working directory of the task.
exit_codenumber_expression?Retrieves the last exit code returned by the executable associated with the work item on its last run.
flagsnumber_expression?Returns the flags used to modify the behavior of the task.
max_run_timenumber_expression?Retrieves the maximum length of time the task can run.
prioritynumber_expression?Retrieves the priority for the task.
statusnumber_expression?Retrieves the status of the work item. Possible values include: ready, running, not_scheduled, has_not_run, disabled, has_more_runs, no_valid_triggers
max_most_recent_run_timenumber_expression?Retrieves the most recent time the work item began running.

time expression

A time expression is a date/time interval as a number followed by a unit postfix (m, s, h, d, w). A few examples of time expression are: generated < -2d means filter will match any records older than 2 days, generated > -2h means match any records newer then 2 hours. Warning, the bash shell on linux interprets the "<,>,!". Use the "\" to avoid this. e.g. generated=\>2d or the safe versions where you replace > with gt like so: generated lt -2d. On the Client activate the "Nasty Metachars" Option, to allow <>and such.

string expression

A string expression is a key followed by a string that specifies a string expression. Example: version = '1.0.0.0'

Some more Examples (for 0.3.9)

Check if any jobs have failed

Sample Command:

CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
warning: WARNING:test.job (1)
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
}
<<CheckTaskSched>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0

Check if any jobs have failed, showing only status

Sample Command:

CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" "master-syntax=%status%" warn=>0
warning
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" "master-syntax=%status%" warn=>0
}
<<CheckTaskSched>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" "master-syntax=%status%" warn=>0

Check if any scheduled tasks currently running have been running for more then 30 minutes

Sample Command:

CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -30m" "syntax=%title% (%most_recent_run_time%)" warn=>0
warning: WARNING:test.job (2011-02-10 23:14:35)
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
}
<<CheckTaskSched>> 30m
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=status = 'running' AND most_recent_run_time < -30m" "syntax=%title% (%most_recent_run_time%)" warn=>0

Check a given scheduled task has failed or not

Sample Command:

CheckTaskSched "filter=title eq 'test.job' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
warning: WARNING:test.job (2)
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
}
<<CheckTaskSched>> test.job
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=title eq 'test.job' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0

Check a given scheduled task has been running for more then 30 minutes

Sample Command:

CheckTaskSched "filter=title = 'test.job' status = 'running' AND most_recent_run_time < -30m" "syntax=%title% (%most_recent_run_time%)" warn=>0
warning: WARNING:test.job (2011-02-10 23:14:35)
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=title = '$ARG1$' status = 'running' AND most_recent_run_time < -$ARG2$" "syntax=%title% (%most_recent_run_time%)" warn=>0
}
<<CheckTaskSched>> test.job!30m
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=title = 'test.job' status = 'running' AND most_recent_run_time < -30m" "syntax=%title% (%most_recent_run_time%)" warn=>0

Ignore all disabled tasks

Sample Command:

CheckTaskSched "filter=status ne 'disabled' AND exit_code eq 0" "syntax=%title% (%exit_code%)" warn=>0
warning
Nagios Configuration:
define command {
  command_name <<CheckTaskSched>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=status ne 'disabled' AND exit_code eq 0" "syntax=%title% (%exit_code%)" warn=>0
}
<<CheckTaskSched>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckTaskSched -a "filter=status ne 'disabled' AND exit_code eq 0" "syntax=%title% (%exit_code%)" warn=>0