watchdogd

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OpStop     = 'S' // Stop the watchdogd petting.
	OpContinue = 'C' // Continue the watchdogd petting.
	OpDisarm   = 'D' // Disarm the watchdog.
	OpArm      = 'A' // Arm the watchdog.
)
View Source
const (
	OpResultOk        = 'O' // Ok.
	OpResultError     = 'E' // Error.
	OpResultInvalidOp = 'I' // Invalid Op.
)

Variables

This section is empty.

Functions

func MonitorOops

func MonitorOops() error

MonitorOops return an error if the kernel logs contain an oops.

func NewClient

func NewClient() (*client, error)

func NewClientFromUDS

func NewClientFromUDS(uds string) (*client, error)

func Run

func Run(ctx context.Context, opts *DaemonOpts) error

Run starts up the daemon.

That includes: 1) Starts listening for watchdog(d) operation requests over unix network. 2) Arms the watchdog timer if it is not already armed. 3) Starts petting the watchdog timer.

Types

type Daemon

type Daemon struct {
	// CurrentOpts is current operating parameters for the daemon.
	//
	// It is assigned at the first call of Run and updated on each subsequent call of it.
	CurrentOpts *DaemonOpts

	// CurrentWd is an open file descriptor to the watchdog device specified in the daemon options.
	CurrentWd *watchdog.Watchdog

	// PettingOp syncs the signal to continue or stop petting the watchdog.
	PettingOp chan int

	// PettingOn indicate if there is an active petting session.
	PettingOn bool
}

Daemon contains running states of an instance of the daemon.

func New

func New(opts *DaemonOpts) *Daemon

func (*Daemon) ArmWatchdog

func (d *Daemon) ArmWatchdog() rune

armWatchdog starts watchdog timer.

func (*Daemon) DisarmWatchdog

func (d *Daemon) DisarmWatchdog() rune

disarmWatchdog disarm the watchdog if already armed.

func (*Daemon) DoPetting

func (d *Daemon) DoPetting() error

doPetting sends keepalive signal to Watchdog when necessary.

If at least one of the custom monitors failed check(s), it won't send a keepalive signal.

func (*Daemon) StartPetting

func (d *Daemon) StartPetting() rune

startPetting starts Watchdog petting in a new goroutine.

func (*Daemon) StartServing

func (d *Daemon) StartServing(l *net.UnixListener)

StartServing enters a loop of accepting and processing next incoming watchdogd operation call.

func (*Daemon) StopPetting

func (d *Daemon) StopPetting() rune

stopPetting stops an ongoing petting process if there is.

type DaemonOpts

type DaemonOpts struct {
	// Dev is the watchdog device. Ex: /dev/watchdog
	Dev string

	// nil uses the preset values. 0 disables the timeout.
	Timeout, PreTimeout *time.Duration

	// KeepAlive is the length of the keep alive interval.
	KeepAlive time.Duration

	// Monitors are called before each keepalive interval. If any monitor
	// function returns an error, the .
	Monitors []func() error

	// UDS is the name of daemon's unix domain socket.
	UDS string
}

DaemonOpts contain operating parameters for bootstrapping a watchdog daemon.

Jump to

Keyboard shortcuts

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