summaryrefslogtreecommitdiffstats
path: root/plugins/check_by_ssh.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r--plugins/check_by_ssh.c286
1 files changed, 198 insertions, 88 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 2bc38d49..df8907d9 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -26,16 +26,17 @@
26 * 26 *
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29const char *progname = "check_by_ssh";
30const char *copyright = "2000-2024";
31const char *email = "devel@monitoring-plugins.org";
32
33#include "common.h" 29#include "common.h"
30#include "output.h"
34#include "utils.h" 31#include "utils.h"
35#include "utils_cmd.h" 32#include "utils_cmd.h"
36#include "check_by_ssh.d/config.h" 33#include "check_by_ssh.d/config.h"
37#include "states.h" 34#include "states.h"
38 35
36const char *progname = "check_by_ssh";
37const char *copyright = "2000-2024";
38const char *email = "devel@monitoring-plugins.org";
39
39#ifndef NP_MAXARGS 40#ifndef NP_MAXARGS
40# define NP_MAXARGS 1024 41# define NP_MAXARGS 1024
41#endif 42#endif
@@ -45,7 +46,8 @@ typedef struct {
45 check_by_ssh_config config; 46 check_by_ssh_config config;
46} check_by_ssh_config_wrapper; 47} check_by_ssh_config_wrapper;
47static check_by_ssh_config_wrapper process_arguments(int /*argc*/, char ** /*argv*/); 48static check_by_ssh_config_wrapper process_arguments(int /*argc*/, char ** /*argv*/);
48static check_by_ssh_config_wrapper validate_arguments(check_by_ssh_config_wrapper /*config_wrapper*/); 49static check_by_ssh_config_wrapper
50 validate_arguments(check_by_ssh_config_wrapper /*config_wrapper*/);
49 51
50static command_construct comm_append(command_construct /*cmd*/, const char * /*str*/); 52static command_construct comm_append(command_construct /*cmd*/, const char * /*str*/);
51static void print_help(void); 53static void print_help(void);
@@ -70,6 +72,10 @@ int main(int argc, char **argv) {
70 72
71 const check_by_ssh_config config = tmp_config.config; 73 const check_by_ssh_config config = tmp_config.config;
72 74
75 if (config.output_format_is_set) {
76 mp_set_format(config.output_format);
77 }
78
73 /* Set signal handling and alarm timeout */ 79 /* Set signal handling and alarm timeout */
74 if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { 80 if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) {
75 usage_va(_("Cannot catch SIGALRM")); 81 usage_va(_("Cannot catch SIGALRM"));
@@ -84,59 +90,99 @@ int main(int argc, char **argv) {
84 } 90 }
85 } 91 }
86 92
87 output chld_out; 93 cmd_run_result child_result = cmd_run_array2(config.cmd.commargv, 0);
88 output chld_err; 94 mp_check overall = mp_check_init();
89 mp_state_enum result = cmd_run_array(config.cmd.commargv, &chld_out, &chld_err, 0);
90 95
91 /* SSH returns 255 if connection attempt fails; include the first line of error output */ 96 /* SSH returns 255 if connection attempt fails; include the first line of error output */
92 if (result == 255 && config.unknown_timeout) { 97 // we can sadly not detect other SSH errors
93 printf(_("SSH connection failed: %s\n"), chld_err.lines > 0 ? chld_err.line[0] : "(no error output)"); 98 if (child_result.cmd_error_code == 255 && config.unknown_timeout) {
94 return STATE_UNKNOWN; 99 mp_subcheck sc_ssh_execution = mp_subcheck_init();
100 xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s",
101 child_result.stderr.lines > 0 ? child_result.stderr.line[0]
102 : "(no error output)");
103
104 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
105 mp_add_subcheck_to_check(&overall, sc_ssh_execution);
106 mp_exit(overall);
95 } 107 }
96 108
97 if (verbose) { 109 if (verbose) {
98 for (size_t i = 0; i < chld_out.lines; i++) { 110 for (size_t i = 0; i < child_result.stdout.lines; i++) {
99 printf("stdout: %s\n", chld_out.line[i]); 111 printf("stdout: %s\n", child_result.stdout.line[i]);
100 } 112 }
101 for (size_t i = 0; i < chld_err.lines; i++) { 113 for (size_t i = 0; i < child_result.stderr.lines; i++) {
102 printf("stderr: %s\n", chld_err.line[i]); 114 printf("stderr: %s\n", child_result.stderr.line[i]);
103 } 115 }
104 } 116 }
105 117
106 size_t skip_stdout = 0; 118 size_t skip_stdout = 0;
107 if (config.skip_stdout == -1) { /* --skip-stdout specified without argument */ 119 if (config.skip_stdout) { /* --skip-stdout specified without argument */
108 skip_stdout = chld_out.lines; 120 skip_stdout = child_result.stdout.lines;
109 } else { 121 } else {
110 skip_stdout = config.skip_stdout; 122 skip_stdout = config.stdout_lines_to_ignore;
111 } 123 }
112 124
113 size_t skip_stderr = 0; 125 size_t skip_stderr = 0;
114 if (config.skip_stderr == -1) { /* --skip-stderr specified without argument */ 126 if (config.skip_stderr) { /* --skip-stderr specified without argument */
115 skip_stderr = chld_err.lines; 127 skip_stderr = child_result.stderr.lines;
116 } else { 128 } else {
117 skip_stderr = config.skip_stderr; 129 skip_stderr = config.sterr_lines_to_ignore;
118 } 130 }
119 131
120 /* UNKNOWN or worse if (non-skipped) output found on stderr */ 132 /* Allow UNKNOWN or WARNING state for (non-skipped) output found on stderr */
121 if (chld_err.lines > (size_t)skip_stderr) { 133 if (child_result.stderr.lines > skip_stderr &&
122 printf(_("Remote command execution failed: %s\n"), chld_err.line[skip_stderr]); 134 (config.unknown_on_stderr || config.warn_on_stderr)) {
135 mp_subcheck sc_stderr = mp_subcheck_init();
136 xasprintf(&sc_stderr.output, "remote command execution failed: %s",
137 child_result.stderr.line[skip_stderr]);
138
139 if (config.unknown_on_stderr) {
140 sc_stderr = mp_set_subcheck_state(sc_stderr, STATE_UNKNOWN);
141 }
142
123 if (config.warn_on_stderr) { 143 if (config.warn_on_stderr) {
124 return max_state_alt(result, STATE_WARNING); 144 sc_stderr = mp_set_subcheck_state(sc_stderr, STATE_WARNING);
125 } 145 }
126 return max_state_alt(result, STATE_UNKNOWN); 146
147 mp_add_subcheck_to_check(&overall, sc_stderr);
148 // TODO still exit here?
127 } 149 }
128 150
129 /* this is simple if we're not supposed to be passive. 151 /* this is simple if we're not supposed to be passive.
130 * Wrap up quickly and keep the tricks below */ 152 * Wrap up quickly and keep the tricks below */
131 if (!config.passive) { 153 if (!config.passive) {
132 if (chld_out.lines > (size_t)skip_stdout) { 154 mp_subcheck sc_active_check = mp_subcheck_init();
133 for (size_t i = skip_stdout; i < chld_out.lines; i++) { 155 xasprintf(&sc_active_check.output, "command stdout:");
134 puts(chld_out.line[i]); 156
157 if (child_result.stdout.lines > skip_stdout) {
158 for (size_t i = skip_stdout; i < child_result.stdout.lines; i++) {
159 xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output,
160 child_result.stdout.line[i]);
135 } 161 }
136 } else { 162 } else {
137 printf(_("%s - check_by_ssh: Remote command '%s' returned status %d\n"), state_text(result), config.remotecmd, result); 163 xasprintf(&sc_active_check.output, "remote command '%s' returned status %d",
164 config.remotecmd, child_result.cmd_error_code);
138 } 165 }
139 return result; /* return error status from remote command */ 166
167 /* return error status from remote command */
168
169 switch (child_result.cmd_error_code) {
170 case 0:
171 sc_active_check = mp_set_subcheck_state(sc_active_check, STATE_OK);
172 break;
173 case 1:
174 sc_active_check = mp_set_subcheck_state(sc_active_check, STATE_WARNING);
175 break;
176 case 2:
177 sc_active_check = mp_set_subcheck_state(sc_active_check, STATE_CRITICAL);
178 break;
179 default:
180 sc_active_check = mp_set_subcheck_state(sc_active_check, STATE_UNKNOWN);
181 break;
182 }
183
184 mp_add_subcheck_to_check(&overall, sc_active_check);
185 mp_exit(overall);
140 } 186 }
141 187
142 /* 188 /*
@@ -144,62 +190,88 @@ int main(int argc, char **argv) {
144 */ 190 */
145 191
146 /* process output */ 192 /* process output */
147 FILE *file_pointer = NULL; 193 mp_subcheck sc_passive_file = mp_subcheck_init();
148 if (!(file_pointer = fopen(config.outputfile, "a"))) { 194 FILE *output_file = NULL;
149 printf(_("SSH WARNING: could not open %s\n"), config.outputfile); 195 if (!(output_file = fopen(config.outputfile, "a"))) {
150 exit(STATE_UNKNOWN); 196 xasprintf(&sc_passive_file.output, "could not open %s", config.outputfile);
197 sc_passive_file = mp_set_subcheck_state(sc_passive_file, STATE_UNKNOWN);
198
199 mp_add_subcheck_to_check(&overall, sc_passive_file);
200 mp_exit(overall);
151 } 201 }
152 202
203 xasprintf(&sc_passive_file.output, "opened output file %s", config.outputfile);
204 sc_passive_file = mp_set_subcheck_state(sc_passive_file, STATE_OK);
205 mp_add_subcheck_to_check(&overall, sc_passive_file);
206
153 time_t local_time = time(NULL); 207 time_t local_time = time(NULL);
154 unsigned int commands = 0; 208 unsigned int commands = 0;
155 char *status_text; 209 char *status_text;
156 int cresult; 210 int cresult;
157 for (size_t i = skip_stdout; i < chld_out.lines; i++) { 211 mp_subcheck sc_parse_passive = mp_subcheck_init();
158 status_text = chld_out.line[i++]; 212 for (size_t i = skip_stdout; i < child_result.stdout.lines; i++) {
159 if (i == chld_out.lines || strstr(chld_out.line[i], "STATUS CODE: ") == NULL) { 213 status_text = child_result.stdout.line[i++];
160 die(STATE_UNKNOWN, _("%s: Error parsing output\n"), progname); 214 if (i == child_result.stdout.lines ||
215 strstr(child_result.stdout.line[i], "STATUS CODE: ") == NULL) {
216
217 sc_parse_passive = mp_set_subcheck_state(sc_parse_passive, STATE_UNKNOWN);
218 xasprintf(&sc_parse_passive.output, "failed to parse output");
219 mp_add_subcheck_to_check(&overall, sc_parse_passive);
220 mp_exit(overall);
161 } 221 }
162 222
163 if (config.service[commands] && status_text && sscanf(chld_out.line[i], "STATUS CODE: %d", &cresult) == 1) { 223 if (config.service[commands] && status_text &&
164 fprintf(file_pointer, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", (int)local_time, config.host_shortname, 224 sscanf(child_result.stdout.line[i], "STATUS CODE: %d", &cresult) == 1) {
165 config.service[commands++], cresult, status_text); 225 fprintf(output_file, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", (int)local_time,
226 config.host_shortname, config.service[commands++], cresult, status_text);
166 } 227 }
167 } 228 }
168 229
230 sc_parse_passive = mp_set_subcheck_state(sc_parse_passive, STATE_OK);
231 xasprintf(&sc_parse_passive.output, "parsed and wrote output");
232 mp_add_subcheck_to_check(&overall, sc_parse_passive);
233
169 /* Multiple commands and passive checking should always return OK */ 234 /* Multiple commands and passive checking should always return OK */
170 exit(result); 235 mp_exit(overall);
171} 236}
172 237
173/* process command-line arguments */ 238/* process command-line arguments */
174check_by_ssh_config_wrapper process_arguments(int argc, char **argv) { 239check_by_ssh_config_wrapper process_arguments(int argc, char **argv) {
175 static struct option longopts[] = {{"version", no_argument, 0, 'V'}, 240 enum {
176 {"help", no_argument, 0, 'h'}, 241 output_format_index = CHAR_MAX + 1,
177 {"verbose", no_argument, 0, 'v'}, 242 };
178 {"fork", no_argument, 0, 'f'}, 243
179 {"timeout", required_argument, 0, 't'}, 244 static struct option longopts[] = {
180 {"unknown-timeout", no_argument, 0, 'U'}, 245 {"version", no_argument, 0, 'V'},
181 {"host", required_argument, 0, 'H'}, /* backward compatibility */ 246 {"help", no_argument, 0, 'h'},
182 {"hostname", required_argument, 0, 'H'}, 247 {"verbose", no_argument, 0, 'v'},
183 {"port", required_argument, 0, 'p'}, 248 {"fork", no_argument, 0, 'f'},
184 {"output", required_argument, 0, 'O'}, 249 {"timeout", required_argument, 0, 't'},
185 {"name", required_argument, 0, 'n'}, 250 {"unknown-timeout", no_argument, 0, 'U'},
186 {"services", required_argument, 0, 's'}, 251 {"host", required_argument, 0, 'H'}, /* backward compatibility */
187 {"identity", required_argument, 0, 'i'}, 252 {"hostname", required_argument, 0, 'H'},
188 {"user", required_argument, 0, 'u'}, 253 {"port", required_argument, 0, 'p'},
189 {"logname", required_argument, 0, 'l'}, 254 {"output", required_argument, 0, 'O'},
190 {"command", required_argument, 0, 'C'}, 255 {"name", required_argument, 0, 'n'},
191 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ 256 {"services", required_argument, 0, 's'},
192 {"skip-stdout", optional_argument, 0, 'S'}, 257 {"identity", required_argument, 0, 'i'},
193 {"skip-stderr", optional_argument, 0, 'E'}, 258 {"user", required_argument, 0, 'u'}, /* backwards compatibility */
194 {"warn-on-stderr", no_argument, 0, 'W'}, 259 {"logname", required_argument, 0, 'l'},
195 {"proto1", no_argument, 0, '1'}, 260 {"command", required_argument, 0, 'C'},
196 {"proto2", no_argument, 0, '2'}, 261 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */
197 {"use-ipv4", no_argument, 0, '4'}, 262 {"skip-stdout", optional_argument, 0, 'S'},
198 {"use-ipv6", no_argument, 0, '6'}, 263 {"skip-stderr", optional_argument, 0, 'E'},
199 {"ssh-option", required_argument, 0, 'o'}, 264 {"unknown-on-stderr", no_argument, 0, 'e'},
200 {"quiet", no_argument, 0, 'q'}, 265 {"warn-on-stderr", no_argument, 0, 'W'},
201 {"configfile", optional_argument, 0, 'F'}, 266 {"proto1", no_argument, 0, '1'},
202 {0, 0, 0, 0}}; 267 {"proto2", no_argument, 0, '2'},
268 {"use-ipv4", no_argument, 0, '4'},
269 {"use-ipv6", no_argument, 0, '6'},
270 {"ssh-option", required_argument, 0, 'o'},
271 {"quiet", no_argument, 0, 'q'},
272 {"configfile", optional_argument, 0, 'F'},
273 {"output-format", required_argument, 0, output_format_index},
274 {0, 0, 0, 0}};
203 275
204 check_by_ssh_config_wrapper result = { 276 check_by_ssh_config_wrapper result = {
205 .errorcode = OK, 277 .errorcode = OK,
@@ -221,7 +293,8 @@ check_by_ssh_config_wrapper process_arguments(int argc, char **argv) {
221 293
222 int option = 0; 294 int option = 0;
223 while (true) { 295 while (true) {
224 int opt_index = getopt_long(argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, &option); 296 int opt_index =
297 getopt_long(argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, &option);
225 298
226 if (opt_index == -1 || opt_index == EOF) { 299 if (opt_index == -1 || opt_index == EOF) {
227 break; 300 break;
@@ -266,11 +339,13 @@ check_by_ssh_config_wrapper process_arguments(int argc, char **argv) {
266 char *p2; 339 char *p2;
267 340
268 p1 = optarg; 341 p1 = optarg;
269 result.config.service = realloc(result.config.service, (++result.config.number_of_services) * sizeof(char *)); 342 result.config.service = realloc(result.config.service,
343 (++result.config.number_of_services) * sizeof(char *));
270 while ((p2 = index(p1, ':'))) { 344 while ((p2 = index(p1, ':'))) {
271 *p2 = '\0'; 345 *p2 = '\0';
272 result.config.service[result.config.number_of_services - 1] = p1; 346 result.config.service[result.config.number_of_services - 1] = p1;
273 result.config.service = realloc(result.config.service, (++result.config.number_of_services) * sizeof(char *)); 347 result.config.service = realloc(
348 result.config.service, (++result.config.number_of_services) * sizeof(char *));
274 p1 = p2 + 1; 349 p1 = p2 + 1;
275 } 350 }
276 result.config.service[result.config.number_of_services - 1] = p1; 351 result.config.service[result.config.number_of_services - 1] = p1;
@@ -309,28 +384,39 @@ check_by_ssh_config_wrapper process_arguments(int argc, char **argv) {
309 case 'C': /* Command for remote machine */ 384 case 'C': /* Command for remote machine */
310 result.config.commands++; 385 result.config.commands++;
311 if (result.config.commands > 1) { 386 if (result.config.commands > 1) {
312 xasprintf(&result.config.remotecmd, "%s;echo STATUS CODE: $?;", result.config.remotecmd); 387 xasprintf(&result.config.remotecmd, "%s;echo STATUS CODE: $?;",
388 result.config.remotecmd);
313 } 389 }
314 xasprintf(&result.config.remotecmd, "%s%s", result.config.remotecmd, optarg); 390 xasprintf(&result.config.remotecmd, "%s%s", result.config.remotecmd, optarg);
315 break; 391 break;
316 case 'S': /* skip n (or all) lines on stdout */ 392 case 'S': /* skip n (or all) lines on stdout */
317 if (optarg == NULL) { 393 if (optarg == NULL) {
318 result.config.skip_stdout = -1; /* skip all output on stdout */ 394 result.config.skip_stdout = true; /* skip all output on stdout */
395
396 if (verbose) {
397 printf("Setting the skip_stdout flag\n");
398 }
319 } else if (!is_integer(optarg)) { 399 } else if (!is_integer(optarg)) {
320 usage_va(_("skip-stdout argument must be an integer")); 400 usage_va(_("skip-stdout argument must be an integer"));
321 } else { 401 } else {
322 result.config.skip_stdout = atoi(optarg); 402 result.config.stdout_lines_to_ignore = atoi(optarg);
323 } 403 }
324 break; 404 break;
325 case 'E': /* skip n (or all) lines on stderr */ 405 case 'E': /* skip n (or all) lines on stderr */
326 if (optarg == NULL) { 406 if (optarg == NULL) {
327 result.config.skip_stderr = -1; /* skip all output on stderr */ 407 result.config.skip_stderr = true; /* skip all output on stderr */
408 if (verbose) {
409 printf("Setting the skip_stderr flag\n");
410 }
328 } else if (!is_integer(optarg)) { 411 } else if (!is_integer(optarg)) {
329 usage_va(_("skip-stderr argument must be an integer")); 412 usage_va(_("skip-stderr argument must be an integer"));
330 } else { 413 } else {
331 result.config.skip_stderr = atoi(optarg); 414 result.config.sterr_lines_to_ignore = atoi(optarg);
332 } 415 }
333 break; 416 break;
417 case 'e': /* exit with unknown if there is an output on stderr */
418 result.config.unknown_on_stderr = true;
419 break;
334 case 'W': /* exit with warning if there is an output on stderr */ 420 case 'W': /* exit with warning if there is an output on stderr */
335 result.config.warn_on_stderr = true; 421 result.config.warn_on_stderr = true;
336 break; 422 break;
@@ -345,6 +431,18 @@ check_by_ssh_config_wrapper process_arguments(int argc, char **argv) {
345 result.config.cmd = comm_append(result.config.cmd, "-F"); 431 result.config.cmd = comm_append(result.config.cmd, "-F");
346 result.config.cmd = comm_append(result.config.cmd, optarg); 432 result.config.cmd = comm_append(result.config.cmd, optarg);
347 break; 433 break;
434 case output_format_index: {
435 parsed_output_format parser = mp_parse_output_format(optarg);
436 if (!parser.parsing_success) {
437 // TODO List all available formats here, maybe add anothoer usage function
438 printf("Invalid output format: %s\n", optarg);
439 exit(STATE_UNKNOWN);
440 }
441
442 result.config.output_format_is_set = true;
443 result.config.output_format = parser.output_format;
444 break;
445 }
348 default: /* help */ 446 default: /* help */
349 usage5(); 447 usage5();
350 } 448 }
@@ -396,7 +494,8 @@ command_construct comm_append(command_construct cmd, const char *str) {
396 die(STATE_UNKNOWN, _("%s: Argument limit of %d exceeded\n"), progname, NP_MAXARGS); 494 die(STATE_UNKNOWN, _("%s: Argument limit of %d exceeded\n"), progname, NP_MAXARGS);
397 } 495 }
398 496
399 if ((cmd.commargv = (char **)realloc(cmd.commargv, (cmd.commargc + 1) * sizeof(char *))) == NULL) { 497 if ((cmd.commargv = (char **)realloc(cmd.commargv, (cmd.commargc + 1) * sizeof(char *))) ==
498 NULL) {
400 die(STATE_UNKNOWN, _("Can not (re)allocate 'commargv' buffer\n")); 499 die(STATE_UNKNOWN, _("Can not (re)allocate 'commargv' buffer\n"));
401 } 500 }
402 501
@@ -412,12 +511,18 @@ check_by_ssh_config_wrapper validate_arguments(check_by_ssh_config_wrapper confi
412 return config_wrapper; 511 return config_wrapper;
413 } 512 }
414 513
415 if (config_wrapper.config.passive && config_wrapper.config.commands != config_wrapper.config.number_of_services) { 514 if (config_wrapper.config.passive &&
416 die(STATE_UNKNOWN, _("%s: In passive mode, you must provide a service name for each command.\n"), progname); 515 config_wrapper.config.commands != config_wrapper.config.number_of_services) {
516 die(STATE_UNKNOWN,
517 _("%s: In passive mode, you must provide a service name for each command.\n"),
518 progname);
417 } 519 }
418 520
419 if (config_wrapper.config.passive && config_wrapper.config.host_shortname == NULL) { 521 if (config_wrapper.config.passive && config_wrapper.config.host_shortname == NULL) {
420 die(STATE_UNKNOWN, _("%s: In passive mode, you must provide the host short name from the monitoring configs.\n"), progname); 522 die(STATE_UNKNOWN,
523 _("%s: In passive mode, you must provide the host short name from the monitoring "
524 "configs.\n"),
525 progname);
421 } 526 }
422 527
423 return config_wrapper; 528 return config_wrapper;
@@ -451,10 +556,13 @@ void print_help(void) {
451 printf(" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); 556 printf(" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]"));
452 printf(" %s\n", "-E, --skip-stderr[=n]"); 557 printf(" %s\n", "-E, --skip-stderr[=n]");
453 printf(" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); 558 printf(" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]"));
454 printf(" %s\n", "-W, --warn-on-stderr]"); 559 printf(" %s\n", "-e, --unknown-on-stderr");
455 printf(" %s\n", _("Exit with an warning, if there is an output on STDERR")); 560 printf(" %s\n", _("Exit with UNKNOWN, if there is output on STDERR"));
561 printf(" %s\n", "-W, --warn-on-stderr");
562 printf(" %s\n", _("Exit with WARNING, if there is output on STDERR"));
456 printf(" %s\n", "-f"); 563 printf(" %s\n", "-f");
457 printf(" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); 564 printf(" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always "
565 "return OK if ssh is executed"));
458 printf(" %s\n", "-C, --command='COMMAND STRING'"); 566 printf(" %s\n", "-C, --command='COMMAND STRING'");
459 printf(" %s\n", _("command to execute on the remote machine")); 567 printf(" %s\n", _("command to execute on the remote machine"));
460 printf(" %s\n", "-l, --logname=USERNAME"); 568 printf(" %s\n", "-l, --logname=USERNAME");
@@ -477,6 +585,7 @@ void print_help(void) {
477 printf(" %s\n", "-U, --unknown-timeout"); 585 printf(" %s\n", "-U, --unknown-timeout");
478 printf(" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL")); 586 printf(" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
479 printf(UT_VERBOSE); 587 printf(UT_VERBOSE);
588 printf(UT_OUTPUT_FORMAT);
480 printf("\n"); 589 printf("\n");
481 printf(" %s\n", _("The most common mode of use is to refer to a local identity file with")); 590 printf(" %s\n", _("The most common mode of use is to refer to a local identity file with"));
482 printf(" %s\n", _("the '-i' option. In this mode, the identity pair should have a null")); 591 printf(" %s\n", _("the '-i' option. In this mode, the identity pair should have a null"));
@@ -490,7 +599,8 @@ void print_help(void) {
490 printf(" %s\n", _("all of -O, -s, and -n options (servicelist order must match '-C'options)")); 599 printf(" %s\n", _("all of -O, -s, and -n options (servicelist order must match '-C'options)"));
491 printf("\n"); 600 printf("\n");
492 printf("%s\n", _("Examples:")); 601 printf("%s\n", _("Examples:"));
493 printf(" %s\n", "$ check_by_ssh -H localhost -n lh -s c1:c2:c3 -C uptime -C uptime -C uptime -O /tmp/foo"); 602 printf(" %s\n", "$ check_by_ssh -H localhost -n lh -s c1:c2:c3 -C uptime -C uptime -C "
603 "uptime -O /tmp/foo");
494 printf(" %s\n", "$ cat /tmp/foo"); 604 printf(" %s\n", "$ cat /tmp/foo");
495 printf(" %s\n", "[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c1;0; up 2 days"); 605 printf(" %s\n", "[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c1;0; up 2 days");
496 printf(" %s\n", "[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c2;0; up 2 days"); 606 printf(" %s\n", "[1080933700] PROCESS_SERVICE_CHECK_RESULT;flint;c2;0; up 2 days");
@@ -502,7 +612,7 @@ void print_help(void) {
502void print_usage(void) { 612void print_usage(void) {
503 printf("%s\n", _("Usage:")); 613 printf("%s\n", _("Usage:"));
504 printf(" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n" 614 printf(" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
505 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" 615 " [-S [lines]] [-E [lines]] [-e|-W] [-t timeout] [-i identity]\n"
506 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 616 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
507 " [-p port] [-o ssh-option] [-F configfile]\n", 617 " [-p port] [-o ssh-option] [-F configfile]\n",
508 progname); 618 progname);