X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_http.c;h=6e76706277d702712a92bfa3e34656b9fcb29bf5;hb=3982b98ba2db3ebebf65d7f0f4ad83a55a3efc49;hp=f5a6c2b85e3c0eca2320513b76c7124f7bc57bee;hpb=230d67e18ad368773f2302485d0b55f50f654e3f;p=nagiosplug.git diff --git a/plugins/check_http.c b/plugins/check_http.c index f5a6c2b..6e76706 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -21,7 +21,7 @@ const char *progname = "check_http"; const char *revision = "$Revision$"; -const char *copyright = "1999-2001"; +const char *copyright = "1999-2004"; const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "common.h" @@ -145,8 +145,8 @@ main (int argc, char **argv) asprintf (&user_agent, "User-Agent: check_http/%s (nagios-plugins %s)", clean_revstring (revision), VERSION); - if (process_arguments (argc, argv) != OK) - usage (_("check_http: could not parse arguments\n")); + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); if (strstr (timestamp, ":")) { if (strstr (server_url, "?")) @@ -251,9 +251,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* usage */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); break; case 'h': /* help */ print_help (); @@ -299,7 +297,7 @@ process_arguments (int argc, char **argv) break; case 'S': /* use SSL */ #ifndef HAVE_SSL - usage (_("check_http: invalid option - SSL is not available\n")); + usage4 (_("Invalid option - SSL is not available")); #endif use_ssl = TRUE; if (specify_port == FALSE) @@ -314,7 +312,7 @@ process_arguments (int argc, char **argv) check_cert = TRUE; } #else - usage (_("Invalid option - SSL is not available\n")); + usage4 (_("Invalid option - SSL is not available")); #endif break; case 'f': /* onredirect */ @@ -346,7 +344,7 @@ process_arguments (int argc, char **argv) break; case 'p': /* Server port */ if (!is_intnonneg (optarg)) - usage2 (_("invalid port number"), optarg); + usage2 (_("Invalid port number"), optarg); else { server_port = atoi (optarg); specify_port = TRUE; @@ -377,7 +375,7 @@ process_arguments (int argc, char **argv) case 'l': /* linespan */ case 'r': /* linespan */ case 'R': /* linespan */ - usage (_("check_http: call for regex which was not a compiled option\n")); + usage4 (_("Call for regex which was not a compiled option")); break; #else case 'l': /* linespan */ @@ -403,7 +401,7 @@ process_arguments (int argc, char **argv) #ifdef USE_IPV6 address_family = AF_INET6; #else - usage (_("IPv6 support not available\n")); + usage4 (_("IPv6 support not available")); #endif break; case 'v': /* verbose */ @@ -446,7 +444,7 @@ process_arguments (int argc, char **argv) if (server_address == NULL) { if (host_name == NULL) - usage (_("check_http: you must specify a server address or host name\n")); + usage4 (_("You must specify a server address or host name")); else server_address = strdup (host_name); } @@ -676,17 +674,17 @@ check_document_dates (const char *headers) } else if (!document_date || !*document_date) { die (STATE_CRITICAL, _("Document modification date unknown\n")); } else { - time_t sd = parse_time_string (server_date); - time_t dd = parse_time_string (document_date); + time_t srv_data = parse_time_string (server_date); + time_t doc_data = parse_time_string (document_date); - if (sd <= 0) { + if (srv_data <= 0) { die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date); - } else if (dd <= 0) { + } else if (doc_data <= 0) { die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date); - } else if (dd > sd + 30) { - die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), dd - sd); - } else if (dd < sd - maximum_age) { - int n = (sd - dd); + } else if (doc_data > srv_data + 30) { + die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), (int)doc_data - (int)srv_data); + } else if (doc_data < srv_data - maximum_age) { + int n = (srv_data - doc_data); if (n > (60 * 60 * 24 * 2)) die (STATE_CRITICAL, _("CRITICAL - Last modified %.1f days ago\n"), @@ -1049,11 +1047,11 @@ redir (char *pos, char *status_line) addr = malloc (MAX_IPV4_HOSTLENGTH + 1); if (addr == NULL) - die (STATE_UNKNOWN, _("could not allocate addr\n")); + die (STATE_UNKNOWN, _("Could not allocate addr\n")); url = malloc (strcspn (pos, "\r\n")); if (url == NULL) - die (STATE_UNKNOWN, _("could not allocate url\n")); + die (STATE_UNKNOWN, _("Could not allocate url\n")); while (pos) { @@ -1376,7 +1374,7 @@ print_help (void) This plugin tests the HTTP service on the specified host. It can test\n\ normal (http) and secure (https) servers, follow redirects, search for\n\ strings and regular expressions, check connection times, and report on\n\ -certificate expiration times.\n")); +certificate expiration times.\n\n")); print_usage (); @@ -1490,12 +1488,11 @@ the certificate is expired.\n")); void print_usage (void) { - printf (_("\ -Usage: %s (-H | -I ) [-u ] [-p ]\n\ - [-w ] [-c ] [-t ] [-L]\n\ - [-a auth] [-f ] [-e ]\n\ - [-s string] [-l] [-r | -R ]\n\ - [-P string] [-m min_pg_size] [-4|-6] [-N] [-M ] [-A string]\n\ - [-k string]\n"), progname); - printf (_(UT_HLP_VRS), progname, progname); + printf ("\ +Usage: %s -H | -I ) [-u ] [-p ]\n\ + [-w ] [-c ] [-t ] [-L]\n\ + [-a auth] [-f ] [-e ]\n\ + [-s string] [-l] [-r | -R ]\n\ + [-P string] [-m min_pg_size] [-4|-6] [-N] [-M ]\n\ + [-A string] [-k string]\n", progname); }