package/watchdogd: new package
This patch adds support for watchdogd, a watchdog daemon with built-in process supervisor[1] as well as support for monitoring memory & file descriptor leaks, and CPU load average. When a monitored resource reaches a high watermark, a warning message is logged and when critical level is reached, the cause is saved and the system is rebooted. On reboot the reset cause can be retrieved to help locate the culprit. Support for SysV init script in this patch, and systemd unit file is installed from the one bundled with the package. Both files supoort additional command line options in /etc/default/watchdogd. The Config.in is slightly big, but allows for disabling or adjusting the poll interval for each resource monitor. For more information, see https://github.com/troglobit/watchdogd [1]: processes must have their main loop instrumented for supervision. Signed-off-by: Joachim Wiberg <troglobit@gmail.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
parent
a9dc2de551
commit
e694cc0a25
@ -1342,6 +1342,7 @@ F: package/mg/
|
|||||||
F: package/netcalc/
|
F: package/netcalc/
|
||||||
F: package/ssdp-responder/
|
F: package/ssdp-responder/
|
||||||
F: package/sysklogd/
|
F: package/sysklogd/
|
||||||
|
F: package/watchdogd/
|
||||||
|
|
||||||
N: Joao Pinto <jpinto@synopsys.com>
|
N: Joao Pinto <jpinto@synopsys.com>
|
||||||
F: board/synopsys/vdk/
|
F: board/synopsys/vdk/
|
||||||
|
@ -2549,6 +2549,7 @@ menu "System tools"
|
|||||||
source "package/unscd/Config.in"
|
source "package/unscd/Config.in"
|
||||||
source "package/util-linux/Config.in"
|
source "package/util-linux/Config.in"
|
||||||
source "package/watchdog/Config.in"
|
source "package/watchdog/Config.in"
|
||||||
|
source "package/watchdogd/Config.in"
|
||||||
source "package/xdg-dbus-proxy/Config.in"
|
source "package/xdg-dbus-proxy/Config.in"
|
||||||
source "package/xen/Config.in"
|
source "package/xen/Config.in"
|
||||||
source "package/xvisor/Config.in"
|
source "package/xvisor/Config.in"
|
||||||
|
58
package/watchdogd/Config.in
Normal file
58
package/watchdogd/Config.in
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
config BR2_PACKAGE_WATCHDOGD
|
||||||
|
bool "watchdogd"
|
||||||
|
depends on BR2_USE_MMU # fork()
|
||||||
|
select BR2_PACKAGE_LIBCONFUSE
|
||||||
|
select BR2_PACKAGE_LIBITE
|
||||||
|
select BR2_PACKAGE_LIBUEV
|
||||||
|
help
|
||||||
|
Extended version of uClinux-dist watchdogd. Monitors loadavg,
|
||||||
|
file descriptors and memory leaks, and capable of supervising
|
||||||
|
your processes main loop using an instrumentation API.
|
||||||
|
|
||||||
|
A reset reason is saved for power loss, CPU overload, or any
|
||||||
|
of the monitored conditions (above). The full capabilities
|
||||||
|
are limited by the kernel watchdog driver, but even the basic
|
||||||
|
"softdog" driver is supported. See /etc/watchdogd.conf for
|
||||||
|
details, and try watchdogctl for system status and available
|
||||||
|
commands.
|
||||||
|
|
||||||
|
https://github.com/troglobit/watchdogd/
|
||||||
|
|
||||||
|
if BR2_PACKAGE_WATCHDOGD
|
||||||
|
|
||||||
|
config BR2_PACKAGE_WATCHDOGD_TEST_SUITE
|
||||||
|
bool "Enable watchdogctl test cases"
|
||||||
|
help
|
||||||
|
The watchdogctl program comes with a suite of tests built-in.
|
||||||
|
They can be used to verify correct operation of watchdogd and
|
||||||
|
the kernel watchdog driver.
|
||||||
|
|
||||||
|
config BR2_PACKAGE_WATCHDOGD_GENERIC_POLL
|
||||||
|
int "Generic script monitor poll interval (sec)"
|
||||||
|
default "300"
|
||||||
|
help
|
||||||
|
Poll interval for generic script monitor, in seconds. A value
|
||||||
|
of zero (0) disables the monitor.
|
||||||
|
|
||||||
|
config BR2_PACKAGE_WATCHDOGD_LOADAVG_POLL
|
||||||
|
int "CPU load average monitor poll interval (sec)"
|
||||||
|
default "300"
|
||||||
|
help
|
||||||
|
Poll interval for CPU load average monitor, in seconds. A
|
||||||
|
value of zero (0) disables the monitor.
|
||||||
|
|
||||||
|
config BR2_PACKAGE_WATCHDOGD_FILENR_POLL
|
||||||
|
int "File descriptor leak monitor poll interval (sec)"
|
||||||
|
default "300"
|
||||||
|
help
|
||||||
|
Poll interval for file descriptor leak monitor, in seconds. A
|
||||||
|
value of zero (0) disables the monitor.
|
||||||
|
|
||||||
|
config BR2_PACKAGE_WATCHDOGD_MEMINFO_POLL
|
||||||
|
int "Memory leak monitor poll interval (sec)"
|
||||||
|
default "300"
|
||||||
|
help
|
||||||
|
Poll interval for memory leak monitor, in seconds. A value of
|
||||||
|
zero (0) disables the monitor.
|
||||||
|
|
||||||
|
endif
|
47
package/watchdogd/S01watchdogd
Executable file
47
package/watchdogd/S01watchdogd
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DAEMON="watchdogd"
|
||||||
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||||
|
|
||||||
|
cmd()
|
||||||
|
{
|
||||||
|
start-stop-daemon -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" "$@"
|
||||||
|
status=$?
|
||||||
|
if [ $status -eq 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
|
return $status
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
printf 'Starting %s: ' "$DAEMON"
|
||||||
|
# shellcheck disable=SC2086 # we need the word splitting
|
||||||
|
cmd -S -- $SMCROUTED_ARGS
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
printf 'Stopping %s: ' "$DAEMON"
|
||||||
|
cmd -K
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart)
|
||||||
|
$0 stop
|
||||||
|
sleep 1
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
|
||||||
|
reload)
|
||||||
|
printf 'Reloading %s: ' "$DAEMON"
|
||||||
|
cmd -K -s HUP
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|reload}"
|
||||||
|
exit 1
|
||||||
|
esac
|
5
package/watchdogd/watchdogd.hash
Normal file
5
package/watchdogd/watchdogd.hash
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Upstream .sha256 from GitHub
|
||||||
|
sha256 f36fdea9b323534a704c4c23d9af8050480bca4bdad89cdb50d26fcac316d172 watchdogd-3.4.tar.gz
|
||||||
|
|
||||||
|
# Locally calculated
|
||||||
|
sha256 fd685e20931174308c45a26418a7ce34d66704c4e4b92ab1d8299deb255cd676 LICENSE
|
55
package/watchdogd/watchdogd.mk
Normal file
55
package/watchdogd/watchdogd.mk
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# watchdogd
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
WATCHDOGD_VERSION = 3.4
|
||||||
|
WATCHDOGD_SITE = https://github.com/troglobit/watchdogd/releases/download/$(WATCHDOGD_VERSION)
|
||||||
|
WATCHDOGD_LICENSE = ISC
|
||||||
|
WATCHDOGD_LICENSE_FILES = LICENSE
|
||||||
|
WATCHDOGD_CPE_ID_VENDOR = troglobit
|
||||||
|
WATCHDOGD_DEPENDENCIES = host-pkgconf libconfuse libite libuev
|
||||||
|
WATCHDOGD_CONF_OPTS = --disable-compat --disable-examples --disable-test-mode
|
||||||
|
|
||||||
|
ifneq ($(BR2_PACKAGE_WATCHDOGD_TEST_SUITE),y)
|
||||||
|
WATCHDOGD_CONF_OPTS += --disable-builtin-tests
|
||||||
|
else
|
||||||
|
WATCHDOGD_CONF_OPTS += --enable-builtin-tests
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_WATCHDOGD_GENERIC_POLL),0)
|
||||||
|
WATCHDOGD_CONF_OPTS += --without-generic
|
||||||
|
else
|
||||||
|
WATCHDOGD_CONF_OPTS += --with-generic=$(BR2_PACKAGE_WATCHDOGD_GENERIC_POLL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_WATCHDOGD_LOADAVG_POLL),0)
|
||||||
|
WATCHDOGD_CONF_OPTS += --without-loadavg
|
||||||
|
else
|
||||||
|
WATCHDOGD_CONF_OPTS += --with-loadavg=$(BR2_PACKAGE_WATCHDOGD_LOADAVG_POLL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_WATCHDOGD_FILENR_POLL),0)
|
||||||
|
WATCHDOGD_CONF_OPTS += --without-filenr
|
||||||
|
else
|
||||||
|
WATCHDOGD_CONF_OPTS += --with-filenr=$(BR2_PACKAGE_WATCHDOGD_FILENR_POLL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_WATCHDOGD_MEMINFO_POLL),0)
|
||||||
|
WATCHDOGD_CONF_OPTS += --without-meminfo
|
||||||
|
else
|
||||||
|
WATCHDOGD_CONF_OPTS += --with-meminfo=$(BR2_PACKAGE_WATCHDOGD_MEMINFO_POLL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
define WATCHDOGD_INSTALL_INIT_SYSV
|
||||||
|
$(INSTALL) -D -m 0755 package/watchdogd/S01watchdogd \
|
||||||
|
$(TARGET_DIR)/etc/init.d/S01watchdogd
|
||||||
|
endef
|
||||||
|
|
||||||
|
define WATCHDOGD_INSTALL_INIT_SYSTEMD
|
||||||
|
$(INSTALL) -D -m 644 $(WATCHDOGD_SRCDIR)/watchdogd.service \
|
||||||
|
$(TARGET_DIR)/usr/lib/systemd/system/watchdogd.service
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(autotools-package))
|
Loading…
Reference in New Issue
Block a user