1.\" $OpenBSD: watchdog.4,v 1.11 2009/05/21 16:07:25 mk Exp $ 2.\" 3.\" Copyright (c) 2004-2006 Michael Knudsen <mk@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.Dd $Mdocdate: May 21 2009 $ 17.Dt WATCHDOG 4 18.Os 19.Sh NAME 20.Nm watchdog 21.Nd hardware timers/counters for quick crash recovery 22.Sh DESCRIPTION 23Hardware watchdog timers are devices that reboot the machine when it 24hangs. 25The kernel continually resets the watchdog clock on a regular basis. 26Thus, if the kernel halts, the clock will time out and reset the machine. 27Watchdog timers may be configured to be reset from userland 28to cause a reboot if process scheduling fails; 29see 30.Xr watchdogd 8 31for further information. 32.Pp 33A number of hardware watchdogs are supported, and all are configured 34using 35.Xr sysctl 8 36under the 37.Va kern.watchdog 38name: 39.Bl -tag -width kern.watchdog.period -offset indent 40.It Va kern.watchdog.auto 41Automatically reset 42.Pq Sq tickle 43the watchdog timer but disable it at system shutdown time. 44.It Va kern.watchdog.period 45The timeout in seconds. 46Setting it to zero disables the watchdog timer. 47.El 48.Pp 49In situations where the machine provides vital services which are not 50handled completely in kernel space, e.g. mail exchange, it may be 51desirable to reboot the machine if process scheduling fails. 52This is done by setting 53.Va kern.watchdog.auto 54to zero and running a process which repeatedly sets 55.Va kern.watchdog.period 56to the desired timeout value. 57Then, if process scheduling fails, the process resetting the timer will 58not be run, leading to the machine being rebooted. 59Note that the kernel will not automatically disable an enabled watchdog at 60system shutdown time when 61.Va kern.watchdog.auto 62is set to zero. 63.Pp 64Watchdog timers should be used in high-availability environments where 65getting machines up and running quickly after a crash is more important 66than determining the cause of the crash. 67A watchdog timer enables a crashed machine to autonomously attempt to 68recover quickly after a system failure. 69.Pp 70Note that this also means that it is unwise to combine watchdog timers 71with 72.Xr ddb 4 73since the latter may prevent the former from resetting the 74watchdog timeout before it expires. 75This means that the machine will be rebooted before any debugging 76can be done. 77In other words: For mission critical machines, disable 78.Xr ddb 4 79by adding 80.Dq ddb.panic=0 81to 82.Xr sysctl.conf 5 83since this will give the chance to perform a crash dump and reboot. 84Simply setting the watchdog will lose the debug trace of what went 85wrong. 86.Sh SEE ALSO 87.Xr ddb 4 , 88.Xr sysctl.conf 5 , 89.Xr config 8 , 90.Xr sysctl 8 , 91.Xr watchdogd 8 92.Sh BUGS 93For systems with multiple watchdog timers available, only a single 94one can be used at a time. 95There is currently no way of selecting which device is used; the first 96discovered by the kernel is selected. 97