diff --git a/plugins/check_http.c b/plugins/check_http.c
index 98005d0220edc63a67da83f97daa5d6ad9e4d74d..5f96e31e78b23bc49e5f482f74a8a8850564b841 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ $Id$
+
******************************************************************************/
/* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
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"
clean_revstring (revision), VERSION);
if (process_arguments (argc, argv) == ERROR)
- usage (_("check_http: could not parse arguments\n"));
+ usage4 (_("Could not parse arguments"));
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
X509_free (server_cert);
}
else {
- printf (_("ERROR: Cannot retrieve server certificate.\n"));
+ printf (_("CRITICAL - Cannot retrieve server certificate.\n"));
result = STATE_CRITICAL;
}
SSL_shutdown (ssl);
#endif
return result;
}
-\f
+
/* process command-line arguments */
switch (c) {
case '?': /* usage */
- usage3 (_("unknown argument"), optopt);
+ printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
+ print_usage ();
+ exit (STATE_UNKNOWN);
break;
case 'h': /* help */
print_help ();
break;
case 'c': /* critical time threshold */
if (!is_nonnegative (optarg))
- usage2 (_("invalid critical threshold"), optarg);
+ usage2 (_("Critical threshold must be integer"), optarg);
else {
critical_time = strtod (optarg, NULL);
check_critical_time = TRUE;
break;
case 'w': /* warning time threshold */
if (!is_nonnegative (optarg))
- usage2 (_("invalid warning threshold"), optarg);
+ usage2 (_("Warning threshold must be integer"), optarg);
else {
warning_time = strtod (optarg, NULL);
check_warning_time = TRUE;
case 'C': /* Check SSL cert validity */
#ifdef HAVE_SSL
if (!is_intnonneg (optarg))
- usage2 (_("invalid certificate expiration period"), optarg);
+ usage2 (_("Invalid certificate expiration period"), optarg);
else {
days_till_exp = atoi (optarg);
check_cert = TRUE;
}
#else
- usage (_("check_http: invalid option - SSL is not available\n"));
+ usage (_("Invalid option - SSL is not available\n"));
#endif
break;
case 'f': /* onredirect */
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;
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 */
#ifdef USE_IPV6
address_family = AF_INET6;
#else
- usage (_("IPv6 support not available\n"));
+ usage4 (_("IPv6 support not available"));
#endif
break;
case 'v': /* verbose */
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);
}
return TRUE;
}
-\f
+
/* written by lauri alanko */
buf[i] = '\0';
return buf;
}
-\f
-
}
+
static void
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"),
X509_free (server_cert);
}
else {
- printf (_("ERROR: Cannot retrieve server certificate.\n"));
+ printf (_("CRITICAL - Cannot retrieve server certificate.\n"));
return STATE_CRITICAL;
}
if ( sslerr == SSL_ERROR_SSL ) {
die (STATE_WARNING, _("Client Certificate Required\n"));
} else {
- die (STATE_CRITICAL, _("Error in recv()\n"));
+ die (STATE_CRITICAL, _("Error on receive\n"));
}
}
else {
#endif
- die (STATE_CRITICAL, _("Error in recv()\n"));
+ die (STATE_CRITICAL, _("Error on receive\n"));
#ifdef HAVE_SSL
}
#endif
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;
asprintf (&msg,
- _("HTTP problem: %s - %.3f second response time %s%s|%s %s\n"),
+ _("HTTP WARNING: %s - %.3f second response time %s%s|%s %s\n"),
status_line, elapsed_time, timestamp,
(display_html ? "</A>" : ""),
perfd_time (elapsed_time), perfd_size (pagesize));
-
/* per RFC 2396 */
#define HDR_LOCATION "%*[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]: "
#define URI_HTTP "%[HTPShtps]://"
addr = malloc (MAX_IPV4_HOSTLENGTH + 1);
if (addr == NULL)
- die (STATE_UNKNOWN, _("ERROR: 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, _("ERROR: could not allocate url\n"));
+ die (STATE_UNKNOWN, _("Could not allocate url\n"));
while (pos) {
url = realloc (url, strcspn (pos, "\r\n"));
if (url == NULL)
- die (STATE_UNKNOWN, _("ERROR: could not allocate url\n"));
+ die (STATE_UNKNOWN, _("could not allocate url\n"));
/* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
if (sscanf (pos, HD1, type, addr, port, url) == 4) {
}
#endif
+
+
#ifdef HAVE_SSL
int
check_certificate (X509 ** certificate)
return STATE_OK;
}
#endif
-\f
+
char *perfd_time (double elapsed_time)
}
+
char *perfd_size (int page_len)
{
return perfdata ("size", page_len, "B",
}
+
int
my_recv (void)
{
}
+
int
my_close (void)
{
-
-
-\f
void
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 ();
-
void
print_usage (void)
{
- printf (_("\
-Usage: %s (-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
- [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
- [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
- [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
- [-P string] [-m min_pg_size] [-4|-6] [-N] [-M <age>] [-A string]\n\
- [-k string]\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
+ printf ("\
+Usage: %s -H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
+ [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
+ [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
+ [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
+ [-P string] [-m min_pg_size] [-4|-6] [-N] [-M <age>]\n\
+ [-A string] [-k string]\n", progname);
}