2

How does one check the status of the hardware watchdog with systemd?

With util-linux you have the wdctl command which prints some information, however this doesn't always work (e.g. on a Raspberry Pi 3 or later). For example on a Pi 3:

# wdctl /dev/watchdog0
wdctl: cannot read information about /dev/watchdog0: No such file or directory
# wdctl /dev/watchdog
wdctl: cannot read information about /dev/watchdog: No such file or directory

However the watchdog appears to be active:

# dmesg | grep watchdog
[    6.985782] bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
[   17.190956] systemd[1]: Using hardware watchdog 'Broadcom BCM2835 Watchdog timer', version 0, device /dev/watchdog
[   17.206391] systemd[1]: Set hardware watchdog to 15s.

So is there a systemd-specific command that can be used to display the current status of the hardware watchdog and what systemd itself is doing with it?

Note that the old watchdog service no longer applies, as this was from before systemd got native hardware watchdog support:

# systemctl status watchdog
Unit watchdog.service could not be found.

I am after a command that provides similar information to wdctl, in that the watchdog timer is active, in use, and what the timeout is currently set to. Sort of like systemctl list-timers but for the hardware watchdog.

2 Answers 2

3

watchdogs are exclusive use devices. Which explains the wdctl outputs you reported.

However, all watchdog devices export their settings in /sys

You should then be able to find them under /sys/class/watchdog/*

If you want a command, then would grep . /sys/class/watchdog/*/*satisfy your need ?

5
  • That's odd, because on some systems I can run wdctl with the watchdog active and it tells me what the current timeout is. Running your grep command reveals basic information about the device, but nothing of interest. Looking through the sysfs directory, there doesn't seem to be anything that reports whether the watchdog is active, or what the current timeout is.
    – Malvineous
    Commented Jan 2, 2022 at 12:30
  • 2
    @Malvineous : The 2 infos you are looking for are supposed to be found in /sys/class/watchdog/watchdogN/ status and timeout files respectively (N standing for associated id) don't you get those files ?
    – MC68020
    Commented Jan 2, 2022 at 13:06
  • Interesting. No, I don't have those files in there, only dev, device, power, subsystem and uevent. It's the same on the system that wdctl works, as on the one where it doesn't. Hunting through the various subfolders I don't see any files like status or timeout or anything else of interest.
    – Malvineous
    Commented Jan 2, 2022 at 14:58
  • 1
    @Malvineous You may need to configure CONFIG_WATCHDOG_SYSFS=y in the kernel to export the above required components in the sysfs entry Commented Mar 27, 2023 at 13:09
  • @ArulpandiyanVadivel You might be right, zgrep CONFIG_WATCHDOG_SYSFS /proc/config.gz tells me it's unset.
    – Malvineous
    Commented Mar 27, 2023 at 17:13
3

I wondered the same thing and browsing for a similar issue I came up with the following:

sudo strace -t -e ioctl  -p1  | grep WDIOC_KEEPALIVE

At half the timeout interval, you should see something like:

01:15:47 ioctl(9, WDIOC_KEEPALIVE)      = 0  
...

This uses strace to monitor the pid 1 (systemd init) process for all ioctl calls, then filters out the ones for WDIOC_KEEPALIVE. systemd uses WDIOC_KEEPALIVE to "ping" the watchdog hardware and keep it from causing a reboot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .