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