diff options
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 485bf3be..39d49070 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; |
@@ -116,7 +117,10 @@ main (int argc, char **argv) | |||
116 | if(chld_err.lines > skip_stderr) { | 117 | if(chld_err.lines > skip_stderr) { |
117 | printf (_("Remote command execution failed: %s\n"), | 118 | printf (_("Remote command execution failed: %s\n"), |
118 | chld_err.line[skip_stderr]); | 119 | chld_err.line[skip_stderr]); |
119 | return max_state_alt(result, STATE_UNKNOWN); | 120 | if ( warn_on_stderr ) |
121 | return max_state_alt(result, STATE_WARNING); | ||
122 | else | ||
123 | return max_state_alt(result, STATE_UNKNOWN); | ||
120 | } | 124 | } |
121 | 125 | ||
122 | /* this is simple if we're not supposed to be passive. | 126 | /* this is simple if we're not supposed to be passive. |
@@ -189,6 +193,7 @@ process_arguments (int argc, char **argv) | |||
189 | {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ | 193 | {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ |
190 | {"skip-stdout", optional_argument, 0, 'S'}, | 194 | {"skip-stdout", optional_argument, 0, 'S'}, |
191 | {"skip-stderr", optional_argument, 0, 'E'}, | 195 | {"skip-stderr", optional_argument, 0, 'E'}, |
196 | {"warn-on-stderr", no_argument, 0, 'W'}, | ||
192 | {"proto1", no_argument, 0, '1'}, | 197 | {"proto1", no_argument, 0, '1'}, |
193 | {"proto2", no_argument, 0, '2'}, | 198 | {"proto2", no_argument, 0, '2'}, |
194 | {"use-ipv4", no_argument, 0, '4'}, | 199 | {"use-ipv4", no_argument, 0, '4'}, |
@@ -307,6 +312,9 @@ process_arguments (int argc, char **argv) | |||
307 | else | 312 | else |
308 | skip_stderr = atoi (optarg); | 313 | skip_stderr = atoi (optarg); |
309 | break; | 314 | break; |
315 | case 'W': /* exit with warning if there is an output on stderr */ | ||
316 | warn_on_stderr = 1; | ||
317 | break; | ||
310 | case 'o': /* Extra options for the ssh command */ | 318 | case 'o': /* Extra options for the ssh command */ |
311 | comm_append("-o"); | 319 | comm_append("-o"); |
312 | comm_append(optarg); | 320 | comm_append(optarg); |
@@ -413,6 +421,8 @@ print_help (void) | |||
413 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); | 421 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); |
414 | printf (" %s\n", "-E, --skip-stderr[=n]"); | 422 | printf (" %s\n", "-E, --skip-stderr[=n]"); |
415 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); | 423 | printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); |
424 | printf (" %s\n", "-W, --warn-on-stderr]"); | ||
425 | printf (" %s\n", _("Exit with an warning, if there is an output on STDERR")); | ||
416 | printf (" %s\n", "-f"); | 426 | printf (" %s\n", "-f"); |
417 | printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); | 427 | printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); |
418 | printf (" %s\n","-C, --command='COMMAND STRING'"); | 428 | printf (" %s\n","-C, --command='COMMAND STRING'"); |
@@ -465,7 +475,7 @@ print_usage (void) | |||
465 | { | 475 | { |
466 | printf ("%s\n", _("Usage:")); | 476 | printf ("%s\n", _("Usage:")); |
467 | printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" | 477 | printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" |
468 | " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" | 478 | " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" |
469 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" | 479 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" |
470 | " [-p port] [-o ssh-option] [-F configfile]\n", | 480 | " [-p port] [-o ssh-option] [-F configfile]\n", |
471 | progname); | 481 | progname); |