watchdog

package
v0.0.0-...-5fb8a3f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package watchdog provides access to hardware watchdogs. These can be used to automatically reset/reboot a system if they are no longer pinged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// Type identifies the type of watchdog device. It corresponds to the Linux
	// driver's watchdog_info.identity value.
	Type string
	// HasConfiguratbleTimeout indicates if the device supports the SetTimeout
	// call.
	HasConfigurableTimeout bool
	// HasPretimeout indicates if the device supports notifying the system of
	// an impending reset and the functions to control this
	// (Get/SetPreTimeout).
	HasPretimeout bool
	// Indicates if the watchdog is capable of reporting that it is responsible
	// for the last system reset.
	ReportsWatchdogReset bool
	// contains filtered or unexported fields
}

Device represents a handle to a hardware watchdog.

func Open

func Open(name string) (*Device, error)

Open opens a watchdog device identified by the path to its device inode.

func (*Device) Close

func (w *Device) Close() error

Close disables the watchdog and releases all associated resources.

func (*Device) CloseActive

func (w *Device) CloseActive() error

CloseActive releases all resources and file handles, but keeps the watchdog active. Another system must reopen it and ping it before it expires to avoid a reset.

func (*Device) GetPreTimeout

func (w *Device) GetPreTimeout() (time.Duration, error)

GetPreTimeout gets the current pre-timeout (see SetPreTimeout for more).

func (*Device) GetTimeout

func (w *Device) GetTimeout() (time.Duration, error)

GetTimeout returns the configured timeout duration.

func (*Device) LastResetByWatchdog

func (w *Device) LastResetByWatchdog() (bool, error)

LastResetByWatchdog returns true if the last system reset was caused by this watchdog. Not all watchdogs report this accurately.

func (*Device) Ping

func (w *Device) Ping() error

Ping the watchdog. This needs to be called regularly before the watchdog timeout expires, otherwise the system resets.

func (*Device) SetPreTimeout

func (w *Device) SetPreTimeout(t time.Duration) error

SetPreTimeout sets the minimum duration left on the expiry timer where when it drops below that, the system is notified (via some high-priority interrupt, usually an NMI). This is only available if HasPretimeout is true. This can be used by the system (if it's still in a sem-working state) to recover or dump diagnostic information before it gets forcibly reset by the watchdog. To disable this functionality, set the duration to zero.

func (*Device) SetTimeout

func (w *Device) SetTimeout(t time.Duration) error

SetTimeout sets the duration since the last ping after which it performs a recovery actions (usually a reset or reboot). Due to hardware limitations this function may approximate the set duration or not be a available at all. GetTimeout returns the active timeout.

Jump to

Keyboard shortcuts

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