Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 39 additions & 32 deletions docs/checks/commands/check_tasksched.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,45 +41,52 @@ Naemon Config

## Argument Defaults

| Argument | Default Value |
| ------------- | ---------------------------------------- |
| filter | enabled = true |
| warning | exit_code != 0 |
| critical | exit_code < 0 |
| empty-state | 1 (WARNING) |
| empty-syntax | %(status) - No tasks found |
| top-syntax | %(status) - \${problem_list} |
| ok-syntax | %(status) - All tasks are ok |
| detail-syntax | \${folder}/\${title}: \${exit_code} != 0 |
| Argument | Default Value |
| ------------- | ---------------------------------------------------------------------- |
| filter | enabled = true |
| warning | exit_code != 0 |
| critical | exit_code < 0 |
| empty-state | 3 (UNKNOWN) |
| empty-syntax | %(status) - No tasks found |
| top-syntax | %(status) - \${problem_list} |
| ok-syntax | %(status) - All tasks are ok |
| detail-syntax | \${uri_clean} (%{most_recent_run_time:date}) exited with \${exit_code} |

## Check Specific Arguments

| Argument | Description |
| -------- | ---------------------------------------------------------- |
| timezone | Sets the timezone for time metrics (default is local time) |
| Argument | Description |
| --------- | --------------------------------------------------------------------------------------------------------- |
| folder | The folder where the scheduled task is saved. This is used for exact matches, unless recurisive option is enabled. |
| recursive | Include the subfolders of the specified folder as well when searching for scheduled tasks. |
| timezone | Sets the timezone for time metrics (default is local time) |
| title | Sets the task to check. This corresonds to the title of the scheduled task, called TaskName in Powershell output. |

## Attributes

### Filter Keywords

these can be used in filters and thresholds (along with the default attributes):

| Attribute | Description |
| -------------------- | ------------------------------------------------------------------ |
| application | Name of the application that the task is associated with |
| comment | Comment or description for the work item |
| creator | Creator of the work item |
| enabled | Flag whether this job is enabled (true/false) |
| exit_code | The last jobs exit code |
| exit_string | The last jobs exit code as string |
| folder | Task folder |
| has_run | True if this task has ever been executed |
| max_run_time | Maximum length of time the task can run |
| most_recent_run_time | Most recent time the work item began running |
| priority | Task priority |
| title | Task title |
| hidden | Indicates that the task will not be visible in the UI (true/false) |
| missed_runs | Number of times the registered task has missed a scheduled run |
| task_status | Task status as string |
| next_run_time | Time when the registered task is next scheduled to run |
| parameters | Command line parameters for the task |
| Attribute | Description |
| -------------------- | ---------------------------------------------------------------------------------------------- |
| application | Name of the application that the task is associated with |
| comment | Comment or description for the work item |
| creator | Creator of the work item |
| enabled | Flag whether this job is enabled (true/false) |
| exit_code | The last jobs exit code |
| exit_string | The last jobs exit code as string |
| folder | Task folder |
| uri | Fully qualified path to the task, includes folder and the task title |
| uri_clean | Remove the leading backslash from the URI, only for tasks directly saved at root and not for ones saved inside folders. |
| has_run | True if this task has ever been executed |
| max_run_time | Maximum length of time the task can run |
| most_recent_run_time | Most recent time the work item began running |
| priority | Task priority |
| title | Task title |
| hidden | Indicates that the task will not be visible in the UI (true/false) |
| missed_runs | Number of times the registered task has missed a scheduled run |
| task_status | Task status as string |
| next_run_time | Time when the registered task is next scheduled to run |
| parameters | Last actions command line parameters |
| execute | Last actions executed program |
| working_dir | Last actions working directory |
5 changes: 4 additions & 1 deletion pkg/snclient/check_os_updates_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ func (l *CheckOSUpdates) addWindows(ctx context.Context, check *CheckData) (bool

// https://learn.microsoft.com/en-us/windows/win32/api/wuapi/nf-wuapi-iupdatesearcher-search
// https://learn.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdate
cmd := powerShellCmd(ctx, checkOSupdatesPS1)
cmd, err := powerShellCmd(ctx, checkOSupdatesPS1)
if err != nil {
return false, fmt.Errorf("error when building a powershell command: %s", err.Error())
}
if l.update {
cmd.Env = append(cmd.Env, "ONLINE_SEARCH=1")
}
Expand Down
33 changes: 27 additions & 6 deletions pkg/snclient/check_tasksched.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ func init() {
AvailableChecks["check_tasksched"] = CheckEntry{"check_tasksched", NewCheckTasksched}
}

type CheckTasksched struct{}
type CheckTasksched struct {
TaskTitle string
Folder string
Recursive bool
}

const (
CheckTaskschedDefaultTaskTitle string = "*"
CheckTaskschedDefaultFolder string = "\\"
CheckTaskschedDefaultRecursive bool = true
)

func NewCheckTasksched() CheckHandler {
return &CheckTasksched{}
return &CheckTasksched{
TaskTitle: CheckTaskschedDefaultTaskTitle,
Folder: CheckTaskschedDefaultFolder,
Recursive: CheckTaskschedDefaultRecursive,
}
}

func (l *CheckTasksched) Build() *CheckData {
Expand All @@ -25,16 +39,19 @@ func (l *CheckTasksched) Build() *CheckData {
State: CheckExitOK,
},
args: map[string]CheckArgument{
"timezone": {description: "Sets the timezone for time metrics (default is local time)"},
"timezone": {description: "Sets the timezone for time metrics (default is local time)"},
"title": {value: &l.TaskTitle, description: "Sets the task to check. This corresonds to the title of the scheduled task, called TaskName in Powershell output."},
"folder": {value: &l.Folder, description: "The folder where the scheduled task is saved. This is used for exact matches, unless recurisive option is enabled."},
Comment thread
sni marked this conversation as resolved.
"recursive": {value: &l.Recursive, description: "Include the subfolders of the specified folder as well when searching for scheduled tasks."},
},
defaultFilter: "enabled = true",
defaultCritical: "exit_code < 0",
defaultWarning: "exit_code != 0",
detailSyntax: "${folder}/${title}: ${exit_code} != 0",
detailSyntax: "${uri_clean} (%{most_recent_run_time:date}) exited with ${exit_code}",
topSyntax: "%(status) - ${problem_list}",
okSyntax: "%(status) - All tasks are ok",
emptySyntax: "%(status) - No tasks found",
emptyState: CheckExitWarning,
emptyState: CheckExitUnknown,
attributes: []CheckAttribute{
{name: "application", description: "Name of the application that the task is associated with"},
{name: "comment", description: "Comment or description for the work item"},
Expand All @@ -43,6 +60,8 @@ func (l *CheckTasksched) Build() *CheckData {
{name: "exit_code", description: "The last jobs exit code"},
{name: "exit_string", description: "The last jobs exit code as string"},
{name: "folder", description: "Task folder"},
{name: "uri", description: "Fully qualified path to the task, includes folder and the task title"},
{name: "uri_clean", description: "Remove the leading backslash from the URI, only for tasks directly saved at root and not for ones saved inside folders."},
{name: "has_run", description: "True if this task has ever been executed"},
{name: "max_run_time", description: "Maximum length of time the task can run", unit: UDuration},
{name: "most_recent_run_time", description: "Most recent time the work item began running", unit: UDate},
Expand All @@ -52,7 +71,9 @@ func (l *CheckTasksched) Build() *CheckData {
{name: "missed_runs", description: "Number of times the registered task has missed a scheduled run"},
{name: "task_status", description: "Task status as string"},
{name: "next_run_time", description: "Time when the registered task is next scheduled to run", unit: UDate},
{name: "parameters", description: "Command line parameters for the task"},
{name: "parameters", description: "Last actions command line parameters"},
{name: "execute", description: "Last actions executed program"},
{name: "working_dir", description: "Last actions working directory"},
},
exampleDefault: `
check_tasksched
Expand Down
Loading