diff options
author | nafets <nafets@users.noreply.github.com> | 2014-11-17 23:00:45 +0100 |
---|---|---|
committer | nafets <nafets@users.noreply.github.com> | 2014-11-17 23:00:45 +0100 |
commit | bb16b73130519cf5e93340480c8fd5e7e696a15f (patch) | |
tree | 23bf275bfe4bc317f18527cf061cd947c8632eeb /plugins | |
parent | 668efcda1e1e33de5b442c704c8f2d0a64c59f56 (diff) | |
download | monitoring-plugins-bb16b73130519cf5e93340480c8fd5e7e696a15f.tar.gz |
added option to exit with an warning, if there is output on STDERR
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_by_ssh.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index a877f888..bc172c97 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -49,6 +49,7 @@ unsigned int commands = 0; | |||
49 | unsigned int services = 0; | 49 | unsigned int services = 0; |
50 | int skip_stdout = 0; | 50 | int skip_stdout = 0; |
51 | int skip_stderr = 0; | 51 | int skip_stderr = 0; |
52 | int warn_on_stderr = 0; | ||
52 | char *remotecmd = NULL; | 53 | char *remotecmd = NULL; |
53 | char **commargv = NULL; | 54 | char **commargv = NULL; |
54 | int commargc = 0; | 55 | int commargc = 0; |
@@ -109,7 +110,10 @@ main (int argc, char **argv) | |||
109 | if(chld_err.lines > skip_stderr) { | 110 | if(chld_err.lines > skip_stderr) { |
110 | printf (_("Remote command execution failed: %s\n"), | 111 | printf (_("Remote command execution failed: %s\n"), |
111 | chld_err.line[skip_stderr]); | 112 | chld_err.line[skip_stderr]); |
112 | return max_state_alt(result, STATE_UNKNOWN); | 113 | if ( warn_on_stderr ) |
114 | return max_state_alt(result, STATE_WARNING); | ||
115 | else | ||
116 | return max_state_alt(result, STATE_UNKNOWN); | ||
113 | } | 117 | } |
114 | 118 | ||
115 | /* this is simple if we're not supposed to be passive. | 119 | /* this is simple if we're not supposed to be passive. |
@@ -182,6 +186,7 @@ process_arguments (int argc, char **argv) | |||
182 | {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ | 186 | {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ |
183 | {"skip-stdout", optional_argument, 0, 'S'}, | 187 | {"skip-stdout", optional_argument, 0, 'S'}, |
184 | {"skip-stderr", optional_argument, 0, 'E'}, | 188 | {"skip-stderr", optional_argument, 0, 'E'}, |
189 | {"warn-on-stderr", no_argument, 0, 'W'}, | ||
185 | {"proto1", no_argument, 0, '1'}, | 190 | {"proto1", no_argument, 0, '1'}, |
186 | {"proto2", no_argument, 0, '2'}, | 191 | {"proto2", no_argument, 0, '2'}, |
187 | {"use-ipv4", no_argument, 0, '4'}, | 192 | {"use-ipv4", no_argument, 0, '4'}, |
@@ -301,6 +306,9 @@ process_arguments (int argc, char **argv) | |||
301 | else | 306 | else |
302 | skip_stderr = atoi (optarg); | 307 | skip_stderr = atoi (optarg); |
303 | break; | 308 | break; |
309 | case 'W': /* exit with warning if there is an output on stderr */ | ||
310 | warn_on_stderr = 1; | ||
311 | break; | ||
304 | case 'o': /* Extra options for the ssh command */ | 312 | case 'o': /* Extra options for the ssh command */ |
305 | comm_append("-o"); | 313 | comm_append("-o"); |
306 | comm_append(optarg); | 314 | comm_append(optarg); |
@@ -408,6 +416,8 @@ print_help (void) | |||
408 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); | 416 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); |
409 | printf (" %s\n", "-E, --skip-stderr[=n]"); | 417 | printf (" %s\n", "-E, --skip-stderr[=n]"); |
410 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); | 418 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); |
419 | printf (" %s\n", "-W, --warn-on-stderr]"); | ||
420 | printf (" %s\n", _("Exit with an warning, if there is an output on STDERR")); | ||
411 | printf (" %s\n", "-f"); | 421 | printf (" %s\n", "-f"); |
412 | printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); | 422 | printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); |
413 | printf (" %s\n","-C, --command='COMMAND STRING'"); | 423 | printf (" %s\n","-C, --command='COMMAND STRING'"); |
@@ -460,7 +470,7 @@ print_usage (void) | |||
460 | { | 470 | { |
461 | printf ("%s\n", _("Usage:")); | 471 | printf ("%s\n", _("Usage:")); |
462 | printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" | 472 | printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" |
463 | " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" | 473 | " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" |
464 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" | 474 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" |
465 | " [-p port] [-o ssh-option] [-F configfile]\n", | 475 | " [-p port] [-o ssh-option] [-F configfile]\n", |
466 | progname); | 476 | progname); |