restart

package
v0.5.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package restart provides functionality used to evaluate whether the need for a service restart or system reboot.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRebootEvidence = errors.New("invalid RebootEvidence indicator")

ErrInvalidRebootEvidence indicates that an invalid RebootEvidence indicator was specified.

View Source
var ErrMissingOptionalItem = errors.New("missing optional reboot asserter")

ErrMissingOptionalItem indicates that an optional item (e.g., registry key, file) was not found, though it is not required to be present.

View Source
var ErrMissingRequiredItem = errors.New("missing required reboot asserter")

ErrMissingRequiredItem indicates that a required item (e.g., registry key, file) was not found and is required to be present.

View Source
var ErrMissingValue = errors.New("missing expected value")

ErrMissingValue indicates that an expected value was missing.

View Source
var ErrRebootRequired = errors.New("reboot assertions matched, reboot needed")

ErrRebootRequired indicates that sufficient confidence in reboot assertions has been met and a reboot is needed.

View Source
var ErrUnknownRebootEvidence = errors.New("unknown RebootEvidence indicator")

ErrUnknownRebootEvidence indicates that an unknown RebootEvidence indicator was specified.

Functions

func DisableLogging

func DisableLogging()

DisableLogging reapplies default package-level logging settings of muting all logging output.

func EnableLogging

func EnableLogging()

EnableLogging enables logging output from this package. Output is muted by default unless explicitly requested (by calling this function).

Types

type MatchedPath added in v0.2.0

type MatchedPath interface {
	// Root returns the left-most element of a matched path. This returned
	// value is the beginning of a qualified path.
	Root() string

	// Rel returns the relative (unqualified) element of a matched path. The
	// base element of the path is usually included in this element.
	Rel() string

	// Base returns the last or right-most "leaf" element of a matched path.
	Base() string

	// Full returns the qualified matched path value.
	Full() string

	// String provides a human readable version of the matched path value.
	String() string
}

MatchedPath represents a the path to an item (e.g., reg key, file) that was successfully matched when evaluating an assertion.

type MatchedPaths added in v0.2.0

type MatchedPaths []MatchedPath

MatchedPaths is a collection of MatchedPath values.

type RebootRequiredAsserter

type RebootRequiredAsserter interface {

	// Values implementing this interface are able to determine their service
	// state.
	ServiceStater

	// Err does not apply filtering. This is left to higher-level code
	// operating on values implementing this interface.
	Err() error

	// Validate performs basic validation of all items in the collection. An
	// error is returned for any validation failures.
	Validate() error

	// Evaluate performs the minimum number of assertions to determine whether
	// a reboot is needed. If an error is encountered further checks are
	// skipped.
	Evaluate()

	// String provides the fully qualified path for an asserter.
	String() string

	// RebootReasons returns a list of the reasons associated with the
	// evidence found for an evaluation that indicates a reboot is needed.
	RebootReasons() []string

	// Ignored indicates whether the asserter has been marked as ignored.
	Ignored() bool

	// MatchedPaths returns all recorded paths from successful assertion
	// matches.
	MatchedPaths() MatchedPaths

	// RebootRequired indicates whether an evaluation determined that a reboot
	// is needed.
	RebootRequired() bool

	// HasEvidence indicates whether any evidence was found for an assertion
	// evaluation.
	HasEvidence() bool

	// Filter uses the list of specified ignore patterns to mark each matched
	// path for the Key as ignored *IF* a match is found. If no matched paths
	// are recorded Filter makes no changes. Filter should be called before
	// performing final state evaluation.
	Filter(ignorePatterns []string)
}

RebootRequiredAsserter represents an item (reg key, file) that is able to determine the need for a reboot.

type RebootRequiredAsserterWithDataDisplay

type RebootRequiredAsserterWithDataDisplay interface {
	RebootRequiredAsserter

	// DataDisplay provides a string representation of an item's actual data
	// for display purposes.
	DataDisplay() string
}

RebootRequiredAsserterWithDataDisplay represents an item (reg key, file) that is able to determine the need for a reboot and provide the value associated with the item for display purposes.

type RebootRequiredAsserterWithSubPaths added in v0.2.0

type RebootRequiredAsserterWithSubPaths interface {
	RebootRequiredAsserter

	// HasSubPathMatches indicates whether an item has evidence of subpath
	// matches.
	HasSubPathMatches() bool
}

RebootRequiredAsserterWithSubPaths represents an item (reg key, file) that is able to determine the need for a reboot and if there is evidence of subpath matches.

type RebootRequiredAsserters

type RebootRequiredAsserters []RebootRequiredAsserter

RebootRequiredAsserters is a collection of items that if (if all requirements are matched) indicate the need for a reboot.

func (RebootRequiredAsserters) Errs added in v0.2.0

func (rras RebootRequiredAsserters) Errs(evalIgnored bool) []error

Errs returns a slice of all errors associated with evaluation results in the collection. Missing optional items are excluded. A boolean value is accepted which indicates whether assertion values marked as ignored (during filtering) should also be considered.

The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) Evaluate added in v0.2.0

func (rras RebootRequiredAsserters) Evaluate()

Evaluate performs an evaluation of each assertion in the collection to determine whether a reboot is needed.

func (RebootRequiredAsserters) Filter added in v0.2.0

func (rras RebootRequiredAsserters) Filter(ignorePatterns []string)

Filter uses the list of specified ignore patterns to mark any applicable items in the collection as ignored. Filter should be called before performing final state evaluation.

func (RebootRequiredAsserters) HasCriticalState added in v0.2.0

func (rras RebootRequiredAsserters) HasCriticalState() bool

HasCriticalState indicates whether any items in the collection were evaluated to a CRITICAL state. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) HasErrors added in v0.2.0

func (rras RebootRequiredAsserters) HasErrors(evalIgnored bool) bool

HasErrors indicates whether any of the assertion evaluations resulted in an error. Missing optional items are excluded. A boolean value is accepted which indicates whether assertion values marked as ignored (during filtering) should also be considered. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) HasIgnored added in v0.2.0

func (rras RebootRequiredAsserters) HasIgnored() bool

HasIgnored indicates whether the collection contains an entry marked as ignored. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) HasRebootRequired added in v0.2.0

func (rras RebootRequiredAsserters) HasRebootRequired() bool

HasRebootRequired indicates whether the collection contains an entry whose evaluation indicates that a reboot is needed. Entries marked as ignored are not considered. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) HasWarningState added in v0.2.0

func (rras RebootRequiredAsserters) HasWarningState() bool

HasWarningState indicates whether any items in the collection were evaluated to a WARNING state. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) IgnoredItems added in v0.2.0

IgnoredItems returns all items in the collection that have been marked as ignored. If no items have been marked as ignored an empty collection is returned. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) IsOKState added in v0.2.0

func (rras RebootRequiredAsserters) IsOKState() bool

IsOKState indicates whether all items in the collection were evaluated to an OK state. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NotIgnoredItems added in v0.2.0

func (rras RebootRequiredAsserters) NotIgnoredItems() RebootRequiredAsserters

NotIgnoredItems returns all items in the collection that have not been marked as ignored. If all items have been marked as ignored an empty collection is returned. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NumApplied added in v0.2.0

func (rras RebootRequiredAsserters) NumApplied() int

NumApplied indicates how many reboot assertions were applied.

func (RebootRequiredAsserters) NumErrors added in v0.2.0

func (rras RebootRequiredAsserters) NumErrors(evalIgnored bool) int

NumErrors indicates how many of the evaluation results in the collection have an associated error. Missing optional items are excluded. A boolean value is accepted which indicates whether assertion values marked as ignored (during filtering) should also be considered. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NumIgnored added in v0.2.0

func (rras RebootRequiredAsserters) NumIgnored() int

NumIgnored indicates how many of the items in the collection have been marked as ignored. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NumMatched added in v0.2.0

func (rras RebootRequiredAsserters) NumMatched() int

NumMatched indicates how many of the items in the collection indicate the need for a reboot. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NumNotIgnored added in v0.2.0

func (rras RebootRequiredAsserters) NumNotIgnored() int

NumNotIgnored indicates how many of the items in the collection have not been marked as ignored. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) NumNotMatched added in v0.2.0

func (rras RebootRequiredAsserters) NumNotMatched() int

NumNotMatched indicates how many of the items in the collection do not indicate the need for a reboot. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) RebootRequired added in v0.2.0

func (rras RebootRequiredAsserters) RebootRequired() bool

RebootRequired indicates whether any of the evaluation results in the collection indicate the need for a reboot.

func (RebootRequiredAsserters) ServiceState added in v0.2.0

func (rras RebootRequiredAsserters) ServiceState() nagios.ServiceState

ServiceState returns the appropriate Service Check Status label and exit code for the collection's evaluation results. The caller is responsible for filtering the collection prior to calling this method.

func (RebootRequiredAsserters) Validate

func (rras RebootRequiredAsserters) Validate() error

Validate performs basic validation of all items in the collection. An error is returned for any validation failures.

type ServiceStater

type ServiceStater interface {

	// IsCriticalState indicates whether an evaluation determined that the
	// type is in a CRITICAL state. Whether the type has been marked as
	// Ignored is considered. The caller is responsible for filtering the
	// collection prior to calling this method.
	IsCriticalState() bool

	// IsCriticalState indicates whether an evaluation determined that the
	// type is in a WARNING state. Whether the type has been marked as
	// Ignored is considered. The caller is responsible for filtering the
	// collection prior to calling this method.
	IsWarningState() bool

	// IsOKState indicates whether an evaluation determined that the type is
	// in an OK state. Whether the type has been marked as Ignored is
	// considered. The caller is responsible for filtering the collection
	// prior to calling this method.
	IsOKState() bool
}

ServiceStater represents a type that is capable of evaluating its overall state.

Directories

Path Synopsis
Package files provides functionality used to evaluate whether the state of a file indicates the need for a service restart or system reboot.
Package files provides functionality used to evaluate whether the state of a file indicates the need for a service restart or system reboot.
Package registry provides helper/wrapper functions for accessing Windows registry keys and values in order to determine the need for a service restart or system reboot.
Package registry provides helper/wrapper functions for accessing Windows registry keys and values in order to determine the need for a service restart or system reboot.
Package reports provides functions for generating one-line summary (Service Output) and detailed overview (Long Service Output) "reports" of plugin service check results.
Package reports provides functions for generating one-line summary (Service Output) and detailed overview (Long Service Output) "reports" of plugin service check results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL