libnrdpd.task

Core scheduling and execution.

class libnrdpd.task.Task(check)[source]

Bases: object

Definition of a task to run in the scheduler.

reset()[source]

Reset task so it can be run again.

Call this when you have completed processing a given run of a task.

reset_start()[source]

Set start time for the NEXT check.

This happens automatically during run() and reset().

run(**kwargs)[source]

Start the execution of the check associated with this task.

Convert the variables in the command from the check into something that can be used in os.execvp.

Params:

kwargs: Template variables to fill in.

property began

Time when the current run of the check began.

Before the process has started this will be None. Once a process has been started this will be a float indicating the start time for the current run.

Type

float

property check

The Check associated with this task.

Type

config.Check

property complete

Tell if the task has completed.

Keep checking this value to see if the check has completed. Each check of this value will initiate an output check and process that output of any was found.

Type

bool

property elapsed

Elapsed execution time.

This is only valid if the task has been completed. The value will be -1.0 if the task hasn’t completed yet.

Type

float

property ended

Time when the “current” run of the check ended.

A value of None indicates that the Task hasn’t detected that the process has ended yet.

Type

float or None

property expired

Tells if a check has exceeded it’s timeout value.

Type

bool

property start

Next scheduled execution time in epoch time.

Type

float

property status

The exit code for the process.

  • None: The Task hasn’t processed the execution status yet.

  • int: The exit status of the check. To be valid

    with the Nagios API this must be in the range 0-3.

  • Negative int: The nagios check exited with a signal. The abs()

    value of this is the signal that it terminated with.

Type

int or None

property stderr

stderr from the check.

A value other than None is considered a failed check.

Type

str or None

property stdout

stdout from the check.

Type

str or None