diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 560ae0c..0bce902 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -33,6 +33,7 @@ void print_usage (void); | |||
33 | 33 | ||
34 | int commands = 0; | 34 | int commands = 0; |
35 | int services = 0; | 35 | int services = 0; |
36 | int skip_lines = 0; | ||
36 | char *remotecmd = NULL; | 37 | char *remotecmd = NULL; |
37 | char *comm = NULL; | 38 | char *comm = NULL; |
38 | char *hostname = NULL; | 39 | char *hostname = NULL; |
@@ -101,15 +102,20 @@ main (int argc, char **argv) | |||
101 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) | 102 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) |
102 | asprintf (&result_text, "%s%s", result_text, input_buffer); | 103 | asprintf (&result_text, "%s%s", result_text, input_buffer); |
103 | 104 | ||
104 | |||
105 | /* WARNING if output found on stderr */ | 105 | /* WARNING if output found on stderr */ |
106 | if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { | 106 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { |
107 | printf ("%s\n", input_buffer); | 107 | if (skip_lines > 0) { |
108 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) | 108 | if (input_buffer[strlen(input_buffer)-1] == '\n') { |
109 | printf ("%s\n", input_buffer); | 109 | skip_lines--; |
110 | return STATE_WARNING; | 110 | } |
111 | } else { | ||
112 | printf ("%s", input_buffer); | ||
113 | result = STATE_WARNING; | ||
114 | } | ||
111 | } | 115 | } |
112 | (void) fclose (child_stderr); | 116 | (void) fclose (child_stderr); |
117 | if (result == STATE_WARNING) | ||
118 | return result; | ||
113 | 119 | ||
114 | 120 | ||
115 | /* close the pipe */ | 121 | /* close the pipe */ |
@@ -189,6 +195,7 @@ process_arguments (int argc, char **argv) | |||
189 | {"user", required_argument, 0, 'u'}, | 195 | {"user", required_argument, 0, 'u'}, |
190 | {"logname", required_argument, 0, 'l'}, | 196 | {"logname", required_argument, 0, 'l'}, |
191 | {"command", required_argument, 0, 'C'}, | 197 | {"command", required_argument, 0, 'C'}, |
198 | {"skip", required_argument, 0, 'S'}, | ||
192 | {"proto1", no_argument, 0, '1'}, | 199 | {"proto1", no_argument, 0, '1'}, |
193 | {"proto2", no_argument, 0, '2'}, | 200 | {"proto2", no_argument, 0, '2'}, |
194 | {"use-ipv4", no_argument, 0, '4'}, | 201 | {"use-ipv4", no_argument, 0, '4'}, |
@@ -204,7 +211,7 @@ process_arguments (int argc, char **argv) | |||
204 | strcpy (argv[c], "-t"); | 211 | strcpy (argv[c], "-t"); |
205 | 212 | ||
206 | while (1) { | 213 | while (1) { |
207 | c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:n:s:", longopts, | 214 | c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:S:n:s:", longopts, |
208 | &option); | 215 | &option); |
209 | 216 | ||
210 | if (c == -1 || c == EOF) | 217 | if (c == -1 || c == EOF) |
@@ -275,6 +282,13 @@ process_arguments (int argc, char **argv) | |||
275 | if (commands > 1) | 282 | if (commands > 1) |
276 | asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd); | 283 | asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd); |
277 | asprintf (&remotecmd, "%s%s", remotecmd, optarg); | 284 | asprintf (&remotecmd, "%s%s", remotecmd, optarg); |
285 | break; | ||
286 | case 'S': /* Skip n lines in the output to ignore system banner */ | ||
287 | if (!is_integer (optarg)) | ||
288 | usage2 (_("skip lines must be an integer"), optarg); | ||
289 | else | ||
290 | skip_lines = atoi (optarg); | ||
291 | break; | ||
278 | } | 292 | } |
279 | } | 293 | } |
280 | 294 | ||
@@ -353,6 +367,8 @@ print_help (void) | |||
353 | tell ssh to use Protocol 1\n\ | 367 | tell ssh to use Protocol 1\n\ |
354 | -2, --proto2\n\ | 368 | -2, --proto2\n\ |
355 | tell ssh to use Protocol 2\n\ | 369 | tell ssh to use Protocol 2\n\ |
370 | -S, --skiplines=n\n\ | ||
371 | Ignore first n lines on STDERR (to suppress a logon banner)\n\ | ||
356 | -f\n\ | 372 | -f\n\ |
357 | tells ssh to fork rather than create a tty\n")); | 373 | tells ssh to fork rather than create a tty\n")); |
358 | 374 | ||