Commit d0cd1a1
Michael Jennings
New check: check_cmd_dmesg()
This check, requested by Mike Dubman <[email protected]>, both
addresses a user suggestion/critique *and* provides a working example
of how to write checks that wrap the built-in check_cmd_output()
function. With the recently added improvements to the aforementioned
check, wrappers can now provide customized and/or user-defined
messages for each match string. check_cmd_dmesg() takes advantage of
this capability to allow the user to detect certain error messages
that might appear in "dmesg" output and display a unique check failure
message for each one.
The syntax for check_cmd_dmesg() (and check_cmd_output() too) is:
check_cmd_dmesg [-r rc] [-t tm] [-e cmd] [-M msg] [-m mstr] [...]
where:
-r rc Expect cmd to return rc; fail if it doesn't
-t tm Time out cmd after tm seconds
-e cmd Use "cmd" instead of "dmesg" as the command to run
-M msg Use "msg" as the error message for corresponding mstr
-m mstr Match string (most likely negated) to check "cmd" output
You can specify "-M msg" and "-m mstr" multiple times to perform
multiple matches. If specified and non-empty, the 1st msg corresponds
to the 1st mstr, the 2nd msg to the 2nd mstr, and so on. Values
supplied for msg can use replaceables %m for mstr, %c for cmd, %l for
the line number of the match (for negated mstr only), and %L for
the entire matching line (again, for negated match strings only). If
multiple match strings are given, %f can be used to show how many
match strings failed.
In the case of check_cmd_dmesg(), the user will typically want to
supply a negated match string (e.g., "-m '!/segfault at/'") since
they'll almost always be looking for a string that *shouldn't* appear.
(In fact, perhaps check_cmd_dmesg() should add the ! if it's not
there? Thoughts?)
TODO: Cache dmesg output so it's only called once?1 parent 3dd8295 commit d0cd1a1
1 file changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
0 commit comments