diff options
author | Richard Leitner <me@g0hl1n.net> | 2013-03-17 14:06:30 +0100 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-03-25 23:35:13 +0100 |
commit | fe5fa2a4802215bbc33132b8fc2cc25201c00109 (patch) | |
tree | 8ea1b2453400b57cf3cb91fc2482d9c41b5c2497 /plugins/check_nagios.c | |
parent | 6b208a6f31805bcd0cb5a08136dabc06b5905636 (diff) | |
download | monitoring-plugins-fe5fa2a4802215bbc33132b8fc2cc25201c00109.tar.gz |
Fixed SF.net bug 3602586, added timeout option for check_nagios
Diffstat (limited to 'plugins/check_nagios.c')
-rw-r--r-- | plugins/check_nagios.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index c8cdbc02..4fd6342d 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
@@ -205,6 +205,7 @@ process_arguments (int argc, char **argv) | |||
205 | {"filename", required_argument, 0, 'F'}, | 205 | {"filename", required_argument, 0, 'F'}, |
206 | {"expires", required_argument, 0, 'e'}, | 206 | {"expires", required_argument, 0, 'e'}, |
207 | {"command", required_argument, 0, 'C'}, | 207 | {"command", required_argument, 0, 'C'}, |
208 | {"timeout", optional_argument, 0, 't'}, | ||
208 | {"version", no_argument, 0, 'V'}, | 209 | {"version", no_argument, 0, 'V'}, |
209 | {"help", no_argument, 0, 'h'}, | 210 | {"help", no_argument, 0, 'h'}, |
210 | {"verbose", no_argument, 0, 'v'}, | 211 | {"verbose", no_argument, 0, 'v'}, |
@@ -226,7 +227,7 @@ process_arguments (int argc, char **argv) | |||
226 | } | 227 | } |
227 | 228 | ||
228 | while (1) { | 229 | while (1) { |
229 | c = getopt_long (argc, argv, "+hVvF:C:e:", longopts, &option); | 230 | c = getopt_long (argc, argv, "+hVvF:C:e:t:", longopts, &option); |
230 | 231 | ||
231 | if (c == -1 || c == EOF || c == 1) | 232 | if (c == -1 || c == EOF || c == 1) |
232 | break; | 233 | break; |
@@ -251,6 +252,13 @@ process_arguments (int argc, char **argv) | |||
251 | die (STATE_UNKNOWN, | 252 | die (STATE_UNKNOWN, |
252 | _("Expiration time must be an integer (seconds)\n")); | 253 | _("Expiration time must be an integer (seconds)\n")); |
253 | break; | 254 | break; |
255 | case 't': /* timeout */ | ||
256 | if (is_intnonneg (optarg)) | ||
257 | timeout_interval = atoi (optarg); | ||
258 | else | ||
259 | die (STATE_UNKNOWN, | ||
260 | _("Timeout must be an integer (seconds)\n")); | ||
261 | break; | ||
254 | case 'v': | 262 | case 'v': |
255 | verbose++; | 263 | verbose++; |
256 | break; | 264 | break; |
@@ -296,11 +304,13 @@ print_help (void) | |||
296 | printf (" %s\n", _("Minutes aging after which logfile is considered stale")); | 304 | printf (" %s\n", _("Minutes aging after which logfile is considered stale")); |
297 | printf (" %s\n", "-C, --command=STRING"); | 305 | printf (" %s\n", "-C, --command=STRING"); |
298 | printf (" %s\n", _("Substring to search for in process arguments")); | 306 | printf (" %s\n", _("Substring to search for in process arguments")); |
307 | printf (" %s\n", "-t, --timeout=INTEGER"); | ||
308 | printf (" %s\n", _("Timeout for the plugin in seconds")); | ||
299 | printf (UT_VERBOSE); | 309 | printf (UT_VERBOSE); |
300 | 310 | ||
301 | printf ("\n"); | 311 | printf ("\n"); |
302 | printf ("%s\n", _("Examples:")); | 312 | printf ("%s\n", _("Examples:")); |
303 | printf (" %s\n", "check_nagios -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios"); | 313 | printf (" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios"); |
304 | 314 | ||
305 | printf (UT_SUPPORT); | 315 | printf (UT_SUPPORT); |
306 | } | 316 | } |
@@ -311,5 +321,5 @@ void | |||
311 | print_usage (void) | 321 | print_usage (void) |
312 | { | 322 | { |
313 | printf ("%s\n", _("Usage:")); | 323 | printf ("%s\n", _("Usage:")); |
314 | printf ("%s -F <status log file> -e <expire_minutes> -C <process_string>\n", progname); | 324 | printf ("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", progname); |
315 | } | 325 | } |