Documentation ¶
Overview ¶
Package watchdog provides functions for interacting with the Linux watchdog.
The basic usage is:
wd, err := watchdog.Open(watchdog.Dev) while running { wd.KeepAlive() } wd.MagicClose()
Open() arms the watchdog. MagicClose() disarms the watchdog.
Note not every watchdog driver supports every function!
For more, see: https://www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt
Index ¶
- Constants
- type Option
- type Status
- type Watchdog
- func (w *Watchdog) BootStatus() (Status, error)
- func (w *Watchdog) Close() error
- func (w *Watchdog) KeepAlive() error
- func (w *Watchdog) MagicClose() error
- func (w *Watchdog) PreTimeout() (time.Duration, error)
- func (w *Watchdog) SetOptions(options Option) error
- func (w *Watchdog) SetPreTimeout(timeout time.Duration) error
- func (w *Watchdog) SetTimeout(timeout time.Duration) error
- func (w *Watchdog) Status() (Status, error)
- func (w *Watchdog) Support() (*unix.WatchdogInfo, error)
- func (w *Watchdog) TimeLeft() (time.Duration, error)
- func (w *Watchdog) Timeout() (time.Duration, error)
Constants ¶
const Dev = "/dev/watchdog"
Dev is the name of the first watchdog. If there are multiple watchdogs, they are named /dev/watchdog0, /dev/watchdog1, ...
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option int32
Option are options passed to SetOptions().
const ( // Unknown status error OptionUnknown Option = -1 // Turn off the watchdog timer OptionDisableCard Option = 0x0001 // Turn on the watchdog timer OptionEnableCard Option = 0x0002 // Kernel panic on temperature trip OptionTempPanic Option = 0x0004 )
Bitset of possible flags for the Option type.
type Status ¶
type Status int32
Status contains flags returned by Status() and BootStatus(). These are the same flags used for Support()'s options field.
const ( // Unknown flag error StatusUnknown Status = -1 // Reset due to CPU overheat StatusOverheat Status = 0x0001 // Fan failed StatusFanFault Status = 0x0002 // External relay 1 StatusExtern1 Status = 0x0004 // ExStatusl relay 2 StatusExtern2 Status = 0x0008 // Power bad/power fault StatusPowerUnder Status = 0x0010 // Card previously reset the CPU StatusCardReset Status = 0x0020 // Power over voltage StatusPowerOver Status = 0x0040 // Set timeout (in seconds) StatusSetTimeout Status = 0x0080 // Supports magic close char StatusMagicClose Status = 0x0100 // Pretimeout (in seconds), get/set StatusPreTimeout Status = 0x0200 // Watchdog triggers a management or other external alarm not a reboot StatusAlarmOnly Status = 0x0400 // Keep alive ping reply StatusKeepAlivePing Status = 0x8000 )
Bitset of possible flags for the Status() type.
type Watchdog ¶
Watchdog holds the descriptor of an open watchdog driver.
func (*Watchdog) BootStatus ¶
BootStatus returns the status at the last reboot.
func (*Watchdog) MagicClose ¶
MagicClose disarms the watchdog. However if the kernel is compiled with CONFIG_WATCHDOG_NOWAYOUT=y, there may be no way to disarm the watchdog.
func (*Watchdog) PreTimeout ¶
PreTimeout returns the current watchdog pretimeout.
func (*Watchdog) SetOptions ¶
SetOptions can be used to control some aspects of the cards operation.
func (*Watchdog) SetPreTimeout ¶
SetPreTimeout sets the watchdog pretimeout on the fly. The pretimeout is the duration before triggering the preaction (such as an NMI, interrupt, ...). timeout must be a multiple of seconds; otherwise, an error is returned.
func (*Watchdog) SetTimeout ¶
SetTimeout sets the watchdog timeout on the fly. It returns an error if the timeout gets set to the wrong value. timeout must be a multiple of seconds; otherwise, an error is returned.
func (*Watchdog) Support ¶
func (w *Watchdog) Support() (*unix.WatchdogInfo, error)
Support returns the WatchdogInfo struct.