summaryrefslogtreecommitdiffstats
path: root/plugins/check_http.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-18 03:46:10 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-18 03:46:10 (GMT)
commitb7e21ac5d2215f95116bc3ba48b1200f039d4207 (patch)
treefc2fa7b865aa31fab125e11a502ffdac2a4e40b5 /plugins/check_http.c
parent1fb42320aa0519536b58994e8fdcf16c66dba246 (diff)
downloadmonitoring-plugins-b7e21ac5d2215f95116bc3ba48b1200f039d4207.tar.gz
provide on more decimal point printing time
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@137 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r--plugins/check_http.c25
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];
207void print_usage (void); 207void print_usage (void);
208void print_help (void); 208void print_help (void);
209int process_arguments (int, char **); 209int process_arguments (int, char **);
210int call_getopt (int, char **);
211static char *base64 (char *bin, int len); 210static char *base64 (char *bin, int len);
212int check_http (void); 211int check_http (void);
213int my_recv (void); 212int 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);