diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_http.c | 160 |
1 files changed, 78 insertions, 82 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 93a68ef..188e9ec 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -1094,8 +1094,9 @@ redir (char *pos, char *status_line) | |||
1094 | die (STATE_UNKNOWN, _("Could not allocate url\n")); | 1094 | die (STATE_UNKNOWN, _("Could not allocate url\n")); |
1095 | 1095 | ||
1096 | while (pos) { | 1096 | while (pos) { |
1097 | sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i); | 1097 | |
1098 | if (i == 0) { | 1098 | if (sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i) < 1) { |
1099 | |||
1099 | pos += (size_t) strcspn (pos, "\r\n"); | 1100 | pos += (size_t) strcspn (pos, "\r\n"); |
1100 | pos += (size_t) strspn (pos, "\r\n"); | 1101 | pos += (size_t) strspn (pos, "\r\n"); |
1101 | if (strlen(pos) == 0) | 1102 | if (strlen(pos) == 0) |
@@ -1250,68 +1251,65 @@ print_help (void) | |||
1250 | 1251 | ||
1251 | printf (_(UT_HELP_VRSN)); | 1252 | printf (_(UT_HELP_VRSN)); |
1252 | 1253 | ||
1253 | printf (_("\ | 1254 | printf (" %s\n", "-H, --hostname=ADDRESS"); |
1254 | -H, --hostname=ADDRESS\n\ | 1255 | printf (" %s\n", _("Host name argument for servers using host headers (virtual host)")); |
1255 | Host name argument for servers using host headers (virtual host)\n\ | 1256 | printf (" %s\n", _("Append a port to include it in the header (eg: example.com:5000)")); |
1256 | Append a port to include it in the header (eg: example.com:5000)\n\ | 1257 | printf (" %s\n", "-I, --IP-address=ADDRESS"); |
1257 | -I, --IP-address=ADDRESS\n\ | 1258 | printf (" %s\n", _("IP address or name (use numeric address if possible to bypass DNS lookup).")); |
1258 | IP address or name (use numeric address if possible to bypass DNS lookup).\n\ | 1259 | printf (" %s\n", "-p, --port=INTEGER"); |
1259 | -p, --port=INTEGER\n\ | 1260 | printf (" %s", _("Port number (default: ")); |
1260 | Port number (default: %d)\n"), HTTP_PORT); | 1261 | printf ("%d)\n", HTTP_PORT); |
1261 | 1262 | ||
1262 | printf (_(UT_IPv46)); | 1263 | printf (_(UT_IPv46)); |
1263 | 1264 | ||
1264 | #ifdef HAVE_SSL | 1265 | #ifdef HAVE_SSL |
1265 | printf (_("\ | 1266 | printf (" %s\n", "-S, --ssl"); |
1266 | -S, --ssl\n\ | 1267 | printf (" %s\n", _("Connect via SSL")); |
1267 | Connect via SSL\n\ | 1268 | printf (" %s\n", "-C, --certificate=INTEGER"); |
1268 | -C, --certificate=INTEGER\n\ | 1269 | printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); |
1269 | Minimum number of days a certificate has to be valid.\n\ | 1270 | printf (" %s\n", _("(when this option is used the url is not checked.)\n")); |
1270 | (when this option is used the url is not checked.)\n")); | ||
1271 | #endif | 1271 | #endif |
1272 | 1272 | ||
1273 | printf (_("\ | 1273 | printf (" %s\n", "-e, --expect=STRING"); |
1274 | -e, --expect=STRING\n\ | 1274 | printf (" %s\n", _("String to expect in first (status) line of server response (default: ")); |
1275 | String to expect in first (status) line of server response (default: %s)\n\ | 1275 | printf ("%s\n", HTTP_EXPECT); |
1276 | If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\ | 1276 | printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); |
1277 | -s, --string=STRING\n\ | 1277 | printf (" %s\n", "-s, --string=STRING"); |
1278 | String to expect in the content\n\ | 1278 | printf (" %s\n", _("String to expect in the content")); |
1279 | -u, --url=PATH\n\ | 1279 | printf (" %s\n", "-u, --url=PATH"); |
1280 | URL to GET or POST (default: /)\n\ | 1280 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
1281 | -P, --post=STRING\n\ | 1281 | printf (" %s\n," "-P, --post=STRING"); |
1282 | URL encoded http POST data\n\ | 1282 | printf (" %s\n", _("URL encoded http POST data")); |
1283 | -N, --no-body\n\ | 1283 | printf (" %s\n", "-N, --no-body"); |
1284 | Don't wait for document body: stop reading after headers.\n\ | 1284 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); |
1285 | (Note that this still does an HTTP GET or POST, not a HEAD.)\n\ | 1285 | printf (" %s\n", _("(Note that this still does an HTTP GET or POST, not a HEAD.)")); |
1286 | -M, --max-age=SECONDS\n\ | 1286 | printf (" %s\n", "-M, --max-age=SECONDS"); |
1287 | Warn if document is more than SECONDS old. the number can also be of \n\ | 1287 | printf (" %s\n", _("Warn if document is more than SECONDS old. the number can also be of")); |
1288 | the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days.\n\ | 1288 | printf (" %s\n", _("the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days.")); |
1289 | -T, --content-type=STRING\n\ | 1289 | printf (" %s\n", "-T, --content-type=STRING"); |
1290 | specify Content-Type header media type when POSTing\n"), HTTP_EXPECT); | 1290 | printf (" %s\n", _("specify Content-Type header media type when POSTing\n")); |
1291 | 1291 | ||
1292 | printf (_("\ | 1292 | printf (" %s\n", "-l, --linespan"); |
1293 | -l, --linespan\n\ | 1293 | printf (" %s\n", _("Allow regex to span newlines (must precede -r or -R)")); |
1294 | Allow regex to span newlines (must precede -r or -R)\n\ | 1294 | printf (" %s\n", "-r, --regex, --ereg=STRING"); |
1295 | -r, --regex, --ereg=STRING\n\ | 1295 | printf (" %s\n", _("Search page for regex STRING")); |
1296 | Search page for regex STRING\n\ | 1296 | printf (" %s\n", "-R, --eregi=STRING"); |
1297 | -R, --eregi=STRING\n\ | 1297 | printf (" %s\n", _("Search page for case-insensitive regex STRING")); |
1298 | Search page for case-insensitive regex STRING\n\ | 1298 | printf (" %s\n", "--invert-regex"); |
1299 | --invert-regex\n\ | 1299 | printf (" %s\n", _("Return CRITICAL if found, OK if not\n")); |
1300 | Return CRITICAL if found, OK if not\n")); | 1300 | |
1301 | 1301 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | |
1302 | printf (_("\ | 1302 | printf (" %s\n", _("Username:password on sites with basic authentication")); |
1303 | -a, --authorization=AUTH_PAIR\n\ | 1303 | printf (" %s\n", "-A, --useragent=STRING"); |
1304 | Username:password on sites with basic authentication\n\ | 1304 | printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); |
1305 | -A, --useragent=STRING\n\ | 1305 | printf (" %s\n", "-k, --header=STRING"); |
1306 | String to be sent in http header as \"User Agent\"\n\ | 1306 | printf (" %s\n", _(" Any other tags to be sent in http header. Use multiple times for additional headers")); |
1307 | -k, --header=STRING\n\ | 1307 | printf (" %s\n", "-L, --link=URL"); |
1308 | Any other tags to be sent in http header. Use multiple times for additional headers\n\ | 1308 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); |
1309 | -L, --link=URL\n\ | 1309 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow>"); |
1310 | Wrap output in HTML link (obsoleted by urlize)\n\ | 1310 | printf (" %s\n", _("How to handle redirected pages")); |
1311 | -f, --onredirect=<ok|warning|critical|follow>\n\ | 1311 | printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); |
1312 | How to handle redirected pages\n\ | 1312 | printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); |
1313 | -m, --pagesize=INTEGER<:INTEGER>\n\ | ||
1314 | Minimum page size required (bytes) : Maximum page size required (bytes)\n")); | ||
1315 | 1313 | ||
1316 | printf (_(UT_WARN_CRIT)); | 1314 | printf (_(UT_WARN_CRIT)); |
1317 | 1315 | ||
@@ -1319,32 +1317,30 @@ print_help (void) | |||
1319 | 1317 | ||
1320 | printf (_(UT_VERBOSE)); | 1318 | printf (_(UT_VERBOSE)); |
1321 | 1319 | ||
1322 | printf (_("\ | 1320 | printf (_("Notes:")); |
1323 | This plugin will attempt to open an HTTP connection with the host. Successful\n\ | 1321 | printf (" %s\n", _("This plugin will attempt to open an HTTP connection with the host.")); |
1324 | connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\ | 1322 | printf (" %s\n", _("Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL")); |
1325 | errors return STATE_UNKNOWN. Successful connects, but incorrect reponse\n\ | 1323 | printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect reponse")); |
1326 | messages from the host result in STATE_WARNING return values. If you are\n\ | 1324 | printf (" %s\n", _("messages from the host result in STATE_WARNING return values. If you are")); |
1327 | checking a virtual server that uses 'host headers' you must supply the FQDN\n\ | 1325 | printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN")); |
1328 | (fully qualified domain name) as the [host_name] argument.\n")); | 1326 | printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument.")); |
1329 | 1327 | ||
1330 | #ifdef HAVE_SSL | 1328 | #ifdef HAVE_SSL |
1331 | printf (_("\n\ | 1329 | printf (" %s\n", _("This plugin can also check whether an SSL enabled web server is able to")); |
1332 | This plugin can also check whether an SSL enabled web server is able to\n\ | 1330 | printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 ")); |
1333 | serve content (optionally within a specified time) or whether the X509 \n\ | 1331 | printf (" %s\n", _("certificate is still valid for the specified number of days.")); |
1334 | certificate is still valid for the specified number of days.\n")); | 1332 | printf (_("Examples:")); |
1335 | printf (_("\n\ | 1333 | printf (" %s\n\n", "CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com"); |
1336 | CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com\n\n\ | 1334 | printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,")); |
1337 | When the 'www.verisign.com' server returns its content within 5 seconds, a\n\ | 1335 | printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); |
1338 | STATE_OK will be returned. When the server returns its content but exceeds\n\ | 1336 | printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); |
1339 | the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,\n\ | 1337 | printf (" %s\n\n", _("a STATE_CRITICAL will be returned.")); |
1340 | a STATE_CRITICAL will be returned.\n\n")); | 1338 | |
1341 | 1339 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http www.verisign.com -C 14"); | |
1342 | printf (_("\ | 1340 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); |
1343 | CHECK CERTIFICATE: check_http www.verisign.com -C 14\n\n\ | 1341 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); |
1344 | When the certificate of 'www.verisign.com' is valid for more than 14 days, a\n\ | 1342 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); |
1345 | STATE_OK is returned. When the certificate is still valid, but for less than\n\ | 1343 | printf (" %s\n\n", _("the certificate is expired.")); |
1346 | 14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when\n\ | ||
1347 | the certificate is expired.\n")); | ||
1348 | #endif | 1344 | #endif |
1349 | 1345 | ||
1350 | printf (_(UT_SUPPORT)); | 1346 | printf (_(UT_SUPPORT)); |