Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoCheck = fmt.Errorf("no check found to run")
)
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct {
// Command is the command to run as stored in the database.
Command []string
// ExitCodes contains the list of exit codes of past runs.
ExitCodes []int
// contains filtered or unexported fields
}
Check is contains the metadata to run a check and its current state.
type CheckResult ¶
type CheckResult struct {
ExitCode int
Message string // Message will be shown in the frontend for context
}
CheckResult is the result of a check. It may contain a message and must contain an exit code. The exit code should conform to the nagios specification of 0 - okay 1 - error 2 - warning 3 - unknown or executor errors Other codes are also okay and may be mapped to different values, but need further configuration in the system.
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker maintains the state of checks that need to be run.
func NewChecker ¶
func NewChecker(cfg CheckerConfig) (*Checker, error)
type CheckerConfig ¶
type CheckerConfig struct {
// CheckerID is used to find the checks that need to be run by this
// instance.
CheckerID int
// DB is the connection to the database to use.
DB *sql.DB
// Timeout is the duration a check has time to run.
// Set this to a reasonable value for all checks to avoid long running
// checks blocking the execution.
Timeout time.Duration
// Executor receives a check and must run the requested command in the
// time of the context.
// At the end it must return a CheckResult.
Executor func(Check, context.Context) CheckResult
// HostIdentifier is used in notifications to point to the source of the
// notification.
HostIdentifier string
// Checker will send debug details to the logger for each command executed.
Logger *slog.Logger
}
Click to show internal directories.
Click to hide internal directories.