diff options
-rw-r--r-- | plugins/check_http.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 3fa34eb..44b55a7 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -207,7 +207,6 @@ char buffer[MAX_INPUT_BUFFER]; | |||
207 | void print_usage (void); | 207 | void print_usage (void); |
208 | void print_help (void); | 208 | void print_help (void); |
209 | int process_arguments (int, char **); | 209 | int process_arguments (int, char **); |
210 | int call_getopt (int, char **); | ||
211 | static char *base64 (char *bin, int len); | 210 | static char *base64 (char *bin, int len); |
212 | int check_http (void); | 211 | int check_http (void); |
213 | int my_recv (void); | 212 | int my_recv (void); |
@@ -276,7 +275,8 @@ process_arguments (int argc, char **argv) | |||
276 | #ifdef HAVE_GETOPT_H | 275 | #ifdef HAVE_GETOPT_H |
277 | int option_index = 0; | 276 | int option_index = 0; |
278 | static struct option long_options[] = { | 277 | static struct option long_options[] = { |
279 | STD_OPTS_LONG, | 278 | STD_LONG_OPTS, |
279 | {"file",required_argument,0,'F'}, | ||
280 | {"link", no_argument, 0, 'L'}, | 280 | {"link", no_argument, 0, 'L'}, |
281 | {"nohtml", no_argument, 0, 'n'}, | 281 | {"nohtml", no_argument, 0, 'n'}, |
282 | {"ssl", no_argument, 0, 'S'}, | 282 | {"ssl", no_argument, 0, 'S'}, |
@@ -309,14 +309,13 @@ process_arguments (int argc, char **argv) | |||
309 | strcpy (argv[c], "-n"); | 309 | strcpy (argv[c], "-n"); |
310 | } | 310 | } |
311 | 311 | ||
312 | snprintf (optchars, MAX_INPUT_BUFFER, "%s%s", STD_OPTS, | 312 | #define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLS" |
313 | "P:I:a:e:p:s:R:r:u:f:C:nLS"); | ||
314 | 313 | ||
315 | while (1) { | 314 | while (1) { |
316 | #ifdef HAVE_GETOPT_H | 315 | #ifdef HAVE_GETOPT_H |
317 | c = getopt_long (argc, argv, optchars, long_options, &option_index); | 316 | c = getopt_long (argc, argv, OPTCHARS, long_options, &option_index); |
318 | #else | 317 | #else |
319 | c = getopt (argc, argv, optchars); | 318 | c = getopt (argc, argv, OPTCHARS); |
320 | #endif | 319 | #endif |
321 | if (c == -1 || c == EOF) | 320 | if (c == -1 || c == EOF) |
322 | break; | 321 | break; |
@@ -825,7 +824,7 @@ check_http (void) | |||
825 | else if (onredirect == STATE_CRITICAL) | 824 | else if (onredirect == STATE_CRITICAL) |
826 | printf ("HTTP CRITICAL"); | 825 | printf ("HTTP CRITICAL"); |
827 | elapsed_time = delta_time (tv); | 826 | elapsed_time = delta_time (tv); |
828 | asprintf (&msg, ": %s - %6.2f second response time %s%s|time=%6.2f\n", | 827 | asprintf (&msg, ": %s - %7.3f second response time %s%s|time=%7.3f\n", |
829 | status_line, elapsed_time, timestamp, | 828 | status_line, elapsed_time, timestamp, |
830 | (display_html ? "</A>" : ""), elapsed_time); | 829 | (display_html ? "</A>" : ""), elapsed_time); |
831 | terminate (onredirect, msg); | 830 | terminate (onredirect, msg); |
@@ -837,7 +836,7 @@ check_http (void) | |||
837 | 836 | ||
838 | /* check elapsed time */ | 837 | /* check elapsed time */ |
839 | elapsed_time = delta_time (tv); | 838 | elapsed_time = delta_time (tv); |
840 | asprintf (&msg, "HTTP problem: %s - %6.2f second response time %s%s|time=%6.2f\n", | 839 | asprintf (&msg, "HTTP problem: %s - %7.3f second response time %s%s|time=%7.3f\n", |
841 | status_line, elapsed_time, timestamp, | 840 | status_line, elapsed_time, timestamp, |
842 | (display_html ? "</A>" : ""), elapsed_time); | 841 | (display_html ? "</A>" : ""), elapsed_time); |
843 | if (check_critical_time == TRUE && elapsed_time > critical_time) | 842 | if (check_critical_time == TRUE && elapsed_time > critical_time) |
@@ -850,13 +849,13 @@ check_http (void) | |||
850 | 849 | ||
851 | if (strlen (string_expect)) { | 850 | if (strlen (string_expect)) { |
852 | if (strstr (page, string_expect)) { | 851 | if (strstr (page, string_expect)) { |
853 | printf ("HTTP ok: %s - %6.2f second response time %s%s|time=%6.2f\n", | 852 | printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", |
854 | status_line, elapsed_time, | 853 | status_line, elapsed_time, |
855 | timestamp, (display_html ? "</A>" : ""), elapsed_time); | 854 | timestamp, (display_html ? "</A>" : ""), elapsed_time); |
856 | exit (STATE_OK); | 855 | exit (STATE_OK); |
857 | } | 856 | } |
858 | else { | 857 | else { |
859 | printf ("HTTP CRITICAL: string not found%s|time=%6.2f\n", | 858 | printf ("HTTP CRITICAL: string not found%s|time=%7.3f\n", |
860 | (display_html ? "</A>" : ""), elapsed_time); | 859 | (display_html ? "</A>" : ""), elapsed_time); |
861 | exit (STATE_CRITICAL); | 860 | exit (STATE_CRITICAL); |
862 | } | 861 | } |
@@ -865,14 +864,14 @@ check_http (void) | |||
865 | if (strlen (regexp)) { | 864 | if (strlen (regexp)) { |
866 | errcode = regexec (&preg, page, REGS, pmatch, 0); | 865 | errcode = regexec (&preg, page, REGS, pmatch, 0); |
867 | if (errcode == 0) { | 866 | if (errcode == 0) { |
868 | printf ("HTTP ok: %s - %6.2f second response time %s%s|time=%6.2f\n", | 867 | printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", |
869 | status_line, elapsed_time, | 868 | status_line, elapsed_time, |
870 | timestamp, (display_html ? "</A>" : ""), elapsed_time); | 869 | timestamp, (display_html ? "</A>" : ""), elapsed_time); |
871 | exit (STATE_OK); | 870 | exit (STATE_OK); |
872 | } | 871 | } |
873 | else { | 872 | else { |
874 | if (errcode == REG_NOMATCH) { | 873 | if (errcode == REG_NOMATCH) { |
875 | printf ("HTTP CRITICAL: pattern not found%s|time=%6.2f\n", | 874 | printf ("HTTP CRITICAL: pattern not found%s|time=%7.3f\n", |
876 | (display_html ? "</A>" : ""), elapsed_time); | 875 | (display_html ? "</A>" : ""), elapsed_time); |
877 | exit (STATE_CRITICAL); | 876 | exit (STATE_CRITICAL); |
878 | } | 877 | } |
@@ -886,7 +885,7 @@ check_http (void) | |||
886 | #endif | 885 | #endif |
887 | 886 | ||
888 | /* We only get here if all tests have been passed */ | 887 | /* We only get here if all tests have been passed */ |
889 | asprintf (&msg, "HTTP ok: %s - %6.2f second response time %s%s|time=%6.2f\n", | 888 | asprintf (&msg, "HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", |
890 | status_line, (float)elapsed_time, | 889 | status_line, (float)elapsed_time, |
891 | timestamp, (display_html ? "</A>" : ""), elapsed_time); | 890 | timestamp, (display_html ? "</A>" : ""), elapsed_time); |
892 | terminate (STATE_OK, msg); | 891 | terminate (STATE_OK, msg); |