Introduce pkg/watchdog to detect hardware watchdogs#468
Merged
Conversation
Add a new watchdog package that reports whether the host system has a hardware watchdog, detected via a non-empty /sys/class/watchdog class directory or, on kernels predating the watchdog sysfs class (< 4.5), the /dev/watchdog character device. The lookup paths are routed through linuxpath, adding a Dev path root (with a "/dev" path override key) alongside the existing roots. The watchdog class directory is added to the snapshot clone content so detection works against ghw snapshots. WatchdogInfo is wired into HostInfo, the ghw package aliases, and a new `ghwc watchdog` command. Signed-off-by: Paul Gaiduk <paulg@zededa.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
thank you! I've got some more PRs from our fork https://github.com/zededa/ghw. Is it okay if I keep them coming at the same pace? |
Owner
@europaul Keep 'em coming! I'm loving it! :) |
Owner
|
@europaul BTW, if you'd like a higher-bandwidth conversation, you can find me on Kubernetes slack community with the same username... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
pkg/watchdogpackage that reports whether the host system has a hardwarewatchdog:
WatchdogInfo.Presentis true when/sys/class/watchdoghas at least one entry, or —for kernels predating the watchdog sysfs class (< 4.5) — when the
/dev/watchdogcharacter device exists.
linuxpath; this adds aDevpath root alongside theexisting ones, with a corresponding
"/dev"key forWithPathOverrides./sys/class/watchdog/*is added to the snapshot clone content, so detection also worksagainst ghw snapshots.
HostInfo, theghwpackage aliases (ghw.Watchdog(),ghw.WatchdogInfo),a new
ghwc watchdogcommand (including the default human-format output), and the README.Testing
/dev/watchdogfallback, and the absent case.
go build ./... && go vet ./... && go test ./...pass on Linux; cross-compiles forwindows/darwin.
ghwc watchdogprintswatchdog present: true,and a snapshot round-trip (
snapshot.CloneTreeInto→ghw.Watchdog(ghw.WithChroot(dir)))detects it from the cloned tree as well.