summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: defaea5)
raw | patch | inline | side by side (parent: defaea5)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 16 Oct 2002 10:16:07 +0000 (10:16 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 16 Oct 2002 10:16:07 +0000 (10:16 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@119 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
plugins/check_http.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index ca890f768f379b7f2026492ab1c8c978d5a5aaae..6c98fe9a1564fda61b2a98016809705fff3c8895 100644 (file)
--- a/configure.in
+++ b/configure.in
AC_PROG_INSTALL
AC_SUBST(INSTALL)
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PROG_AWK
+
+AC_FUNC_GETLOADAVG
+AM_FUNC_STRTOD
+AM_WITH_REGEX
AC_PROG_RANLIB
AC_PATH_PROG(ACLOCAL,aclocal)
LDFLAGS="$LDFLAGS -L."
dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_MAKE_SET
-AC_PROG_AWK
-
AC_PATH_PROG(PYTHON,python)
AC_PATH_PROG(PERL,perl)
AC_PATH_PROG(SH,sh)
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(signal.h strings.h string.h syslog.h unistd.h uio.h errno.h regex.h sys/types.h sys/time.h sys/socket.h sys/loadavg.h)
+AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h sys/wait.h stdlib.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
-dnl AC_CHECK_MEMBER(struct timeb.millitm,[AC_DEFINE(HAVE_STRUCT_TIMEB_MILLITM)],,[#include <sys/timeb.h>])
+AC_CHECK_SIZEOF(int,cross)
+AC_CHECK_SIZEOF(long,cross)
+AC_CHECK_SIZEOF(short,cross)
-dnl EXTRA_LIBRARIES="libgetopt.a libsnprintf.a"
-dnl noinst_LIBRARIES="libgetopt.a libsnprintf.a"
-dnl libgetopt_a_SOURCES="getopt.c getopt1.c"
-dnl libgetopt_a_DEPENDENCIES=getopt.h
-dnl libsnprintf_a_SOURCES=snprintf.c
-dnl AC_SUBST(noinst_LIBRARIES)
-dnl AC_SUBST(libgetopt_a_SOURCES)
-dnl AC_SUBST(libgetopt_a_DEPENDENCIES)
-dnl AC_SUBST(libsnprintf_a_SOURCES)
+AC_CACHE_CHECK([for long long],ac_cv_have_longlong,[
+AC_TRY_RUN([#include <stdio.h>
+main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
+ac_cv_have_longlong=yes,ac_cv_have_longlong=no,ac_cv_have_longlong=cross)])
+if test x"$ac_cv_have_longlong" = x"yes"; then
+ AC_DEFINE(HAVE_LONGLONG)
+fi
+
+#
+# Check if the compiler supports the LL prefix on long long integers.
+# AIX needs this.
+
+AC_CACHE_CHECK([for LL suffix on long long integers],ac_cv_compiler_supports_ll, [
+ AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
+ ac_cv_compiler_supports_ll=yes,ac_cv_compiler_supports_ll=no)])
+if test x"$ac_cv_compiler_supports_ll" = x"yes"; then
+ AC_DEFINE(COMPILER_SUPPORTS_LL)
+fi
+AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE_VA_COPY,[
+AC_TRY_LINK([#include <stdarg.h>
+va_list ap1,ap2;], [__va_copy(ap1,ap2);],
+ac_cv_HAVE_VA_COPY=yes,ac_cv_HAVE_VA_COPY=no)])
+if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
+ AC_DEFINE(HAVE_VA_COPY)
+fi
+
+AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <stdarg.h>
+void foo(const char *format, ...) {
+ va_list ap;
+ int len;
+ char buf[5];
+
+ va_start(ap, format);
+ len = vsnprintf(buf, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ va_start(ap, format);
+ len = vsnprintf(0, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+ exit(0);
+}
+main() { foo("hello"); }
+],
+ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
+if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+ AC_DEFINE(HAVE_C99_VSNPRINTF)
+fi
dnl We used to not do long options unless a compatible lib was found
dnl Now we provide code and make libgetopt if native is not suitable
@@ -302,7 +354,7 @@ AC_CHECK_FUNCS(getopt_long_only,,LIBS="$LIBS -lgetopt" DEPLIBS="$DEPLIBS libgeto
AC_CHECK_FUNC(asprintf,,LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a")
dnl Checks for library functions.
-AC_CHECK_FUNCS(select socket strdup strstr strtod strtol strtoul gettimeofday)
+AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul gettimeofday)
AC_MSG_CHECKING(for type of socket size)
AC_TRY_COMPILE([#include <stdlib.h>
diff --git a/plugins/check_http.c b/plugins/check_http.c
index b3b2263d711461b2b27961c655f0804075f89fca..3ba406a848d1005cee8e5214a92450a9c54e739c 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
- server_url = ssprintf (server_url, "%s&%s", server_url, timestamp);
+ asprintf (&server_url, "%s&%s", server_url, timestamp);
else
- server_url = ssprintf (server_url, "%s?%s", server_url, timestamp);
+ asprintf (&server_url, "%s?%s", server_url, timestamp);
}
if (display_html == TRUE)
#ifdef HAVE_SSL
if (use_ssl == TRUE) {
- if (connect_SSL () != OK) {
- msg = ssprintf (msg, "Unable to open TCP socket");
- terminate (STATE_CRITICAL, msg);
- }
+ if (connect_SSL () != OK)
+ terminate (STATE_CRITICAL, "Unable to open TCP socket");
if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
X509_free (server_cert);
return STATE_CRITICAL;
}
- buf = ssprintf (buf, "%s %s HTTP/1.0\r\n", http_method, server_url);
+ asprintf (&buf, "%s %s HTTP/1.0\r\n", http_method, server_url);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
/* optionally send the host header info (not clear if it's usable) */
if (strcmp (host_name, "")) {
- buf = ssprintf (buf, "Host: %s\r\n", host_name);
+ asprintf (&buf, "Host: %s\r\n", host_name);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
/* send user agent */
- buf = ssprintf (buf, "User-Agent: check_http/%s (nagios-plugins %s)\r\n",
+ asprintf (&buf, "User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
/* optionally send the authentication info */
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
- buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth);
+ asprintf (&buf, "Authorization: Basic %s\r\n", auth);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
/* optionally send http POST data */
if (http_post_data) {
- buf = ssprintf (buf, "Content-Type: application/x-www-form-urlencoded\r\n");
+ asprintf (&buf, "Content-Type: application/x-www-form-urlencoded\r\n");
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
- buf = ssprintf (buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
+ asprintf (&buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
/* send a newline so the server knows we're done with the request */
- buf = ssprintf (buf, "\r\n\r\n");
+ asprintf (&buf, "\r\n\r\n");
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
else {
#endif
- if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) {
- msg = ssprintf (msg, "Unable to open TCP socket");
- terminate (STATE_CRITICAL, msg);
- }
- buf = ssprintf (buf, "%s %s HTTP/1.0\r\n", http_method, server_url);
+ if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
+ terminate (STATE_CRITICAL, "Unable to open TCP socket");
+ asprintf (&buf, "%s %s HTTP/1.0\r\n", http_method, server_url);
send (sd, buf, strlen (buf), 0);
/* optionally send the host header info */
if (strcmp (host_name, "")) {
- buf = ssprintf (buf, "Host: %s\r\n", host_name);
+ asprintf (&buf, "Host: %s\r\n", host_name);
send (sd, buf, strlen (buf), 0);
}
/* send user agent */
- buf = ssprintf (buf,
+ asprintf (&buf,
"User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
send (sd, buf, strlen (buf), 0);
/* optionally send the authentication info */
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
- buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth);
+ asprintf (&buf, "Authorization: Basic %s\r\n", auth);
send (sd, buf, strlen (buf), 0);
}
/* optionally send http POST data */
/* written by Chris Henesy <lurker@shadowtech.org> */
if (http_post_data) {
- buf = ssprintf (buf, "Content-Type: application/x-www-form-urlencoded\r\n");
+ asprintf (&buf, "Content-Type: application/x-www-form-urlencoded\r\n");
send (sd, buf, strlen (buf), 0);
- buf = ssprintf (buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
+ asprintf (&buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
send (sd, buf, strlen (buf), 0);
http_post_data = strscat (http_post_data, "\r\n");
send (sd, http_post_data, strlen (http_post_data), 0);
}
/* send a newline so the server knows we're done with the request */
- buf = ssprintf (buf, "\r\n\r\n");
+ asprintf (&buf, "\r\n\r\n");
send (sd, buf, strlen (buf), 0);
#ifdef HAVE_SSL
}
/* fetch the page */
pagesize = (size_t) 0;
while ((i = my_recv ()) > 0) {
- buffer[i] = "\0";
+ buffer[i] = '\0';
full_page = strscat (full_page, buffer);
pagesize += i;
}
/* make sure the status line matches the response we are looking for */
if (!strstr (status_line, server_expect)) {
if (server_port == HTTP_PORT)
- msg = ssprintf (msg, "Invalid HTTP response received from host\n");
+ asprintf (&msg, "Invalid HTTP response received from host\n");
else
- msg = ssprintf (msg,
+ asprintf (&msg,
"Invalid HTTP response received from host on port %d\n",
server_port);
terminate (STATE_CRITICAL, msg);
/* Exit here if server_expect was set by user and not default */
if ( server_expect_yn ) {
- msg = ssprintf (msg, "HTTP OK: Status line output matched \"%s\"\n",
+ asprintf (&msg, "HTTP OK: Status line output matched \"%s\"\n",
server_expect);
if (verbose)
printf ("%s\n",msg);
strstr (status_line, "501") ||
strstr (status_line, "502") ||
strstr (status_line, "503")) {
- msg = ssprintf (msg, "HTTP CRITICAL: %s\n", status_line);
- terminate (STATE_CRITICAL, msg);
+ terminate (STATE_CRITICAL, "HTTP CRITICAL: %s\n", status_line);
}
/* client errors result in a warning state */
strstr (status_line, "402") ||
strstr (status_line, "403") ||
strstr (status_line, "404")) {
- msg = ssprintf (msg, "HTTP WARNING: %s\n", status_line);
- terminate (STATE_WARNING, msg);
+ terminate (STATE_WARNING, "HTTP WARNING: %s\n", status_line);
}
/* check redirected page if specified */
else if (sscanf (pos, HDR_LOCATION URI_PATH, server_url) == 1) {
if ((server_url[0] != '/') && (x = strrchr(orig_url, '/'))) {
*x = '\0';
- server_url = ssprintf (server_url, "%s/%s", orig_url, server_url);
+ asprintf (&server_url, "%s/%s", orig_url, server_url);
}
check_http ();
}
else if (onredirect == STATE_CRITICAL)
printf ("HTTP CRITICAL");
time (&end_time);
- msg = ssprintf (msg, ": %s - %d second response time %s%s|time=%d\n",
+ asprintf (&msg, ": %s - %d second response time %s%s|time=%d\n",
status_line, (int) (end_time - start_time), timestamp,
(display_html ? "</A>" : ""), (int) (end_time - start_time));
terminate (onredirect, msg);
/* check elapsed time */
time (&end_time);
- msg = ssprintf (msg, "HTTP problem: %s - %d second response time %s%s|time=%d\n",
+ asprintf (&msg, "HTTP problem: %s - %d second response time %s%s|time=%d\n",
status_line, (int) (end_time - start_time), timestamp,
(display_html ? "</A>" : ""), (int) (end_time - start_time));
if (check_critical_time == TRUE && (end_time - start_time) > critical_time)
#endif
/* We only get here if all tests have been passed */
- msg = ssprintf (msg, "HTTP ok: %s - %d second response time %s%s|time=%d\n",
+ asprintf (&msg, "HTTP ok: %s - %d second response time %s%s|time=%d\n",
status_line, (int) (end_time - start_time),
timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time));
terminate (STATE_OK, msg);