summaryrefslogtreecommitdiffstats
path: root/plugins/check_http.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-12-20 22:33:29 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-12-20 22:33:29 (GMT)
commit68fbbb6d638c827afbc567b03e5488a476a9b1b6 (patch)
tree2c1a54fa08eaa28551a946df75e5ba192479a701 /plugins/check_http.c
parent958162b45fb77dcacb302e6c65cc5fb45df47692 (diff)
downloadmonitoring-plugins-68fbbb6d638c827afbc567b03e5488a476a9b1b6.tar.gz
Removed unused timestamp variable (Matthias Eble)
Fixed redirection test. Added extra tests for funny syntax when checking certificates, updated help for more common syntax git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1555 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r--plugins/check_http.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 05ae55b..203ebe5 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -88,7 +88,6 @@ struct timeval tv;
88#define HTTP_URL "/" 88#define HTTP_URL "/"
89#define CRLF "\r\n" 89#define CRLF "\r\n"
90 90
91char timestamp[17] = "";
92int specify_port = FALSE; 91int specify_port = FALSE;
93int server_port = HTTP_PORT; 92int server_port = HTTP_PORT;
94char server_port_text[6] = ""; 93char server_port_text[6] = "";
@@ -147,13 +146,6 @@ main (int argc, char **argv)
147 if (process_arguments (argc, argv) == ERROR) 146 if (process_arguments (argc, argv) == ERROR)
148 usage4 (_("Could not parse arguments")); 147 usage4 (_("Could not parse arguments"));
149 148
150 if (strstr (timestamp, ":")) {
151 if (strstr (server_url, "?"))
152 asprintf (&server_url, "%s&%s", server_url, timestamp);
153 else
154 asprintf (&server_url, "%s?%s", server_url, timestamp);
155 }
156
157 if (display_html == TRUE) 149 if (display_html == TRUE)
158 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", 150 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
159 use_ssl ? "https" : "http", host_name, 151 use_ssl ? "https" : "http", host_name,
@@ -861,7 +853,7 @@ check_http (void)
861 853
862 /* return a CRITICAL status if we couldn't read any data */ 854 /* return a CRITICAL status if we couldn't read any data */
863 if (pagesize == (size_t) 0) 855 if (pagesize == (size_t) 0)
864 die (STATE_CRITICAL, _("No data received %s\n"), timestamp); 856 die (STATE_CRITICAL, _("No data received from host\n"));
865 857
866 /* close the connection */ 858 /* close the connection */
867#ifdef HAVE_SSL 859#ifdef HAVE_SSL
@@ -967,8 +959,8 @@ check_http (void)
967 microsec = deltime (tv); 959 microsec = deltime (tv);
968 elapsed_time = (double)microsec / 1.0e6; 960 elapsed_time = (double)microsec / 1.0e6;
969 die (onredirect, 961 die (onredirect,
970 _(" - %s - %.3f second response time %s%s|%s %s\n"), 962 _(" - %s - %.3f second response time %s|%s %s\n"),
971 status_line, elapsed_time, timestamp, 963 status_line, elapsed_time,
972 (display_html ? "</A>" : ""), 964 (display_html ? "</A>" : ""),
973 perfd_time (elapsed_time), perfd_size (pagesize)); 965 perfd_time (elapsed_time), perfd_size (pagesize));
974 } /* end if (http_status >= 300) */ 966 } /* end if (http_status >= 300) */
@@ -983,8 +975,8 @@ check_http (void)
983 microsec = deltime (tv); 975 microsec = deltime (tv);
984 elapsed_time = (double)microsec / 1.0e6; 976 elapsed_time = (double)microsec / 1.0e6;
985 asprintf (&msg, 977 asprintf (&msg,
986 _("HTTP WARNING: %s - %.3f second response time %s%s|%s %s\n"), 978 _("HTTP WARNING: %s - %.3f second response time %s|%s %s\n"),
987 status_line, elapsed_time, timestamp, 979 status_line, elapsed_time,
988 (display_html ? "</A>" : ""), 980 (display_html ? "</A>" : ""),
989 perfd_time (elapsed_time), perfd_size (pagesize)); 981 perfd_time (elapsed_time), perfd_size (pagesize));
990 if (check_critical_time == TRUE && elapsed_time > critical_time) 982 if (check_critical_time == TRUE && elapsed_time > critical_time)
@@ -997,9 +989,9 @@ check_http (void)
997 989
998 if (strlen (string_expect)) { 990 if (strlen (string_expect)) {
999 if (strstr (page, string_expect)) { 991 if (strstr (page, string_expect)) {
1000 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), 992 printf (_("HTTP OK %s - %.3f second response time %s|%s %s\n"),
1001 status_line, elapsed_time, 993 status_line, elapsed_time,
1002 timestamp, (display_html ? "</A>" : ""), 994 (display_html ? "</A>" : ""),
1003 perfd_time (elapsed_time), perfd_size (pagesize)); 995 perfd_time (elapsed_time), perfd_size (pagesize));
1004 exit (STATE_OK); 996 exit (STATE_OK);
1005 } 997 }
@@ -1014,9 +1006,9 @@ check_http (void)
1014 if (strlen (regexp)) { 1006 if (strlen (regexp)) {
1015 errcode = regexec (&preg, page, REGS, pmatch, 0); 1007 errcode = regexec (&preg, page, REGS, pmatch, 0);
1016 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { 1008 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) {
1017 printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"), 1009 printf (_("HTTP OK %s - %.3f second response time %s|%s %s\n"),
1018 status_line, elapsed_time, 1010 status_line, elapsed_time,
1019 timestamp, (display_html ? "</A>" : ""), 1011 (display_html ? "</A>" : ""),
1020 perfd_time (elapsed_time), perfd_size (pagesize)); 1012 perfd_time (elapsed_time), perfd_size (pagesize));
1021 exit (STATE_OK); 1013 exit (STATE_OK);
1022 } 1014 }
@@ -1052,9 +1044,9 @@ check_http (void)
1052 exit (STATE_WARNING); 1044 exit (STATE_WARNING);
1053 } 1045 }
1054 /* We only get here if all tests have been passed */ 1046 /* We only get here if all tests have been passed */
1055 asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s%s|%s %s\n"), 1047 asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s|%s %s\n"),
1056 status_line, page_len, elapsed_time, 1048 status_line, page_len, elapsed_time,
1057 timestamp, (display_html ? "</A>" : ""), 1049 (display_html ? "</A>" : ""),
1058 perfd_time (elapsed_time), perfd_size (page_len)); 1050 perfd_time (elapsed_time), perfd_size (page_len));
1059 die (STATE_OK, "%s", msg); 1051 die (STATE_OK, "%s", msg);
1060 return STATE_UNKNOWN; 1052 return STATE_UNKNOWN;
@@ -1263,9 +1255,9 @@ print_help (void)
1263 1255
1264#ifdef HAVE_SSL 1256#ifdef HAVE_SSL
1265 printf (" %s\n", "-S, --ssl"); 1257 printf (" %s\n", "-S, --ssl");
1266 printf (" %s\n", _("Connect via SSL")); 1258 printf (" %s\n", _("Connect via SSL. Port defaults to 443"));
1267 printf (" %s\n", "-C, --certificate=INTEGER"); 1259 printf (" %s\n", "-C, --certificate=INTEGER");
1268 printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); 1260 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1269 printf (" %s\n", _("(when this option is used the url is not checked.)\n")); 1261 printf (" %s\n", _("(when this option is used the url is not checked.)\n"));
1270#endif 1262#endif
1271 1263
@@ -1329,13 +1321,13 @@ print_help (void)
1329 printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 ")); 1321 printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 "));
1330 printf (" %s\n", _("certificate is still valid for the specified number of days.")); 1322 printf (" %s\n", _("certificate is still valid for the specified number of days."));
1331 printf (_("Examples:")); 1323 printf (_("Examples:"));
1332 printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com"); 1324 printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl -H www.verisign.com");
1333 printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,")); 1325 printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,"));
1334 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); 1326 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds"));
1335 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); 1327 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,"));
1336 printf (" %s\n\n", _("a STATE_CRITICAL will be returned.")); 1328 printf (" %s\n\n", _("a STATE_CRITICAL will be returned."));
1337 1329
1338 printf (" %s\n\n", "CHECK CERTIFICATE: check_http www.verisign.com -C 14"); 1330 printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 14");
1339 printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); 1331 printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,"));
1340 printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); 1332 printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than"));
1341 printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); 1333 printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"));