]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - usr.sbin/watchdogd/watchdogd.8
MFC r322124:
[FreeBSD/stable/10.git] / usr.sbin / watchdogd / watchdogd.8
1 .\" Copyright (c) 2013  iXsystems.com,
2 .\"                     author: Alfred Perlstein <alfred@freebsd.org>
3 .\" Copyright (c) 2004  Poul-Henning Kamp <phk@FreeBSD.org>
4 .\" Copyright (c) 2003  Sean M. Kelly <smkelly@FreeBSD.org>
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd May 11, 2015
31 .Dt WATCHDOGD 8
32 .Os
33 .Sh NAME
34 .Nm watchdogd
35 .Nd watchdog daemon
36 .Sh SYNOPSIS
37 .Nm
38 .Op Fl dnSw
39 .Op Fl -debug
40 .Op Fl -softtimeout
41 .Op Fl -softtimeout-action Ar action
42 .Op Fl -pretimeout Ar timeout
43 .Op Fl -pretimeout-action Ar action
44 .Op Fl e Ar cmd
45 .Op Fl I Ar file
46 .Op Fl s Ar sleep
47 .Op Fl t Ar timeout
48 .Op Fl T Ar script_timeout
49 .Op Fl x Ar exit_timeout
50 .Sh DESCRIPTION
51 The
52 .Nm
53 utility interfaces with the kernel's watchdog facility to ensure
54 that the system is in a working state.
55 If
56 .Nm
57 is unable to interface with the kernel over a specific timeout,
58 the kernel will take actions to assist in debugging or restarting the computer.
59 .Pp
60 If
61 .Fl e Ar cmd
62 is specified,
63 .Nm
64 will attempt to execute this command with
65 .Xr system 3 ,
66 and only if the command returns with a zero exit code will the
67 watchdog be reset.
68 If
69 .Fl e Ar cmd
70 is not specified, the daemon will perform a trivial file system
71 check instead.
72 .Pp
73 The
74 .Fl n
75 argument 'dry-run' will cause watchdog not to arm the system watchdog and
76 instead only run the watchdog function and report on failures.
77 This is useful for developing new watchdogd scripts as the system will not
78 reboot if there are problems with the script.
79 .Pp
80 The
81 .Fl s Ar sleep
82 argument can be used to control the sleep period between each execution
83 of the check and defaults to 10 seconds.
84 .Pp
85 The
86 .Fl t Ar timeout
87 specifies the desired timeout period in seconds.
88 The default timeout is 128 seconds.
89 .Pp
90 One possible circumstance which will cause a watchdog timeout is an interrupt
91 storm.
92 If this occurs,
93 .Nm
94 will no longer execute and thus the kernel's watchdog routines will take
95 action after a configurable timeout.
96 .Pp
97 The
98 .Fl T Ar script_timeout
99 specifies the threshold (in seconds) at which the watchdogd will complain
100 that its script has run for too long.
101 If unset
102 .Ar script_timeout
103 defaults to the value specified by the
104 .Fl s Ar sleep
105 option.
106 .Pp
107 The
108 .Fl x Ar exit_timeout
109 argument is the timeout period (in seconds) to leave in effect when the
110 program exits.
111 Using
112 .Fl x
113 with a non-zero value protects against lockup during a reboot by
114 triggering a hardware reset if the software reboot doesn't complete
115 before the given timeout expires.
116 .Pp
117 Upon receiving the
118 .Dv SIGTERM
119 or
120 .Dv SIGINT
121 signals,
122 .Nm
123 will terminate, after first instructing the kernel to either disable the
124 timeout or reset it to the value given by
125 .Fl x Ar exit_timeout .
126 .Pp
127 The
128 .Nm
129 utility recognizes the following runtime options:
130 .Bl -tag -width 30m
131 .It Fl I Ar file
132 Write the process ID of the
133 .Nm
134 utility in the specified file.
135 .It Fl d Fl -debug
136 Do not fork.
137 When this option is specified,
138 .Nm
139 will not fork into the background at startup.
140 .Pp
141 .It Fl S
142 Do not send a message to the system logger when the watchdog command takes
143 longer than expected to execute.
144 The default behaviour is to log a warning via the system logger with the
145 LOG_DAEMON facility, and to output a warning to standard error.
146 .Pp
147 .It Fl w
148 Complain when the watchdog script takes too long.
149 This flag will cause watchdogd to complain when the amount of time to
150 execute the watchdog script exceeds the threshold of 'sleep' option.
151 .Pp
152 .It Fl -pretimeout Ar timeout
153 Set a "pretimeout" watchdog.
154 At "timeout" seconds before the watchdog will fire attempt an action.
155 The action is set by the --pretimeout-action flag.
156 The default is just to log a message (WD_SOFT_LOG) via
157 .Xr log 9 .
158 .Pp
159 .It Fl -pretimeout-action Ar action
160 Set the timeout action for the pretimeout.
161 See the section
162 .Sx Timeout Actions .
163 .Pp
164 .It Fl -softtimeout
165 Instead of arming the various hardware watchdogs, only use a basic software
166 watchdog.
167 The default action is just to
168 .Xr log 9
169 a message (WD_SOFT_LOG).
170 .Pp
171 .It Fl -softtimeout-action Ar action
172 Set the timeout action for the softtimeout.
173 See the section
174 .Sx Timeout Actions .
175 .Pp
176 .El
177 .Sh Timeout Actions
178 The following timeout actions are available via the
179 .Fl -pretimeout-action
180 and
181 .Fl -softtimeout-action
182 flags:
183 .Bl -tag -width ".Ar printf  "
184 .It Ar panic
185 Call
186 .Xr panic 9
187 when the timeout is reached.
188 .Pp
189 .It Ar ddb
190 Enter the kernel debugger via
191 .Xr kdb_enter 9
192 when the timeout is reached.
193 .Pp
194 .It Ar log
195 Log a message using
196 .Xr log 9
197 when the timeout is reached.
198 .Pp
199 .It Ar printf
200 call the kernel
201 .Xr printf 9
202 to display a message to the console and
203 .Xr dmesg 8
204 buffer.
205 .Pp
206 .El
207 Actions can be combined in a comma separated list as so:
208 .Ar log,printf
209 which would both
210 .Xr printf 9
211 and
212 .Xr log 9
213 which will send messages both to
214 .Xr dmesg 8
215 and the kernel
216 .Xr log 4
217 device for
218 .Xr syslog 8 .
219 .Sh FILES
220 .Bl -tag -width ".Pa /var/run/watchdogd.pid" -compact
221 .It Pa /var/run/watchdogd.pid
222 .El
223 .Sh EXAMPLES
224 .Ss Debugging watchdogd and/or your watchdog script.
225 This is a useful recipe for debugging
226 .Nm
227 and your watchdog script.
228 .Pp
229 (Note that ^C works oddly because
230 .Nm
231 calls
232 .Xr system 3
233 so the
234 first ^C will terminate the "sleep" command.)
235 .Pp
236 Explanation of options used:
237 .Bl -enum -offset indent -compact
238 .It
239 Set Debug on (--debug)
240 .It
241 Set the watchdog to trip at 30 seconds. (-t 30)
242 .It
243 Use of a softtimeout:
244 .Bl -enum -offset indent -compact -nested
245 .It
246 Use a softtimeout (do not arm the hardware watchdog).
247 (--softtimeout)
248 .It
249 Set the softtimeout action to do both kernel
250 .Xr printf 9
251 and
252 .Xr log 9
253 when it trips.
254 (--softtimeout-action log,printf)
255 .El
256 .It
257 Use of a pre-timeout:
258 .Bl -enum -offset indent -compact -nested
259 .It
260 Set a pre-timeout of 15 seconds (this will later trigger a panic/dump).
261 (--pretimeout 15)
262 .It
263 Set the action to also kernel
264 .Xr printf 9
265 and
266 .Xr log 9
267 when it trips.
268 (--pretimeout-action log,printf)
269 .El
270 .It
271 Use of a script:
272 .Bl -enum -offset indent -compact -nested
273 .It
274 Run "sleep 60" as a shell command that acts as the watchdog (-e 'sleep 60')
275 .It
276 Warn us when the script takes longer than 1 second to run (-w)
277 .El
278 .El
279 .Bd -literal
280 watchdogd --debug -t 30 \\
281   --softtimeout --softtimeout-action log,printf \\
282   --pretimeout 15 --pretimeout-action log,printf \\
283   -e 'sleep 60' -w
284 .Ed
285 .Ss Production use of example
286 .Bl -enum -offset indent -compact
287 .It
288 Set hard timeout to 120 seconds (-t 120)
289 .It
290 Set a panic to happen at 60 seconds (to trigger a
291 .Xr crash 8
292 for dump analysis):
293 .Bl -enum -offset indent -compact -nested
294 .It
295 Use of pre-timeout (--pretimeout 60)
296 .It
297 Specify pre-timeout action (--pretimeout-action log,printf,panic )
298 .El
299 .It
300 Use of a script:
301 .Bl -enum -offset indent -compact -nested
302 .It
303 Run your script (-e '/path/to/your/script 60')
304 .It
305 Log if your script takes a longer than 15 seconds to run time. (-w -T 15)
306 .El
307 .El
308 .Bd -literal
309 watchdogd  -t 120 \\
310   --pretimeout 60 --pretimeout-action log,printf,panic \\
311   -e '/path/to/your/script 60' -w -T 15
312 .Ed
313 .Sh SEE ALSO
314 .Xr watchdog 4 ,
315 .Xr watchdog 8 ,
316 .Xr watchdog 9
317 .Sh HISTORY
318 The
319 .Nm
320 utility appeared in
321 .Fx 5.1 .
322 .Sh AUTHORS
323 .An -nosplit
324 The
325 .Nm
326 utility and manual page were written by
327 .An Sean Kelly Aq smkelly@FreeBSD.org
328 and
329 .An Poul-Henning Kamp Aq phk@FreeBSD.org .
330 .Pp
331 Some contributions made by
332 .An Jeff Roberson Aq jeff@FreeBSD.org .
333 .Pp
334 The pretimeout and softtimeout action system was added by
335 .An Alfred Perlstein Aq alfred@freebsd.org .