diff options
-rw-r--r-- | configure.in | 82 | ||||
-rw-r--r-- | plugins/check_http.c | 66 |
2 files changed, 97 insertions, 51 deletions
diff --git a/configure.in b/configure.in index ca890f76..6c98fe9a 100644 --- a/configure.in +++ b/configure.in | |||
@@ -17,6 +17,13 @@ dnl Figure out how to invoke "install" and what install options to use. | |||
17 | AC_PROG_INSTALL | 17 | AC_PROG_INSTALL |
18 | AC_SUBST(INSTALL) | 18 | AC_SUBST(INSTALL) |
19 | 19 | ||
20 | AC_PROG_CC | ||
21 | AC_PROG_MAKE_SET | ||
22 | AC_PROG_AWK | ||
23 | |||
24 | AC_FUNC_GETLOADAVG | ||
25 | AM_FUNC_STRTOD | ||
26 | AM_WITH_REGEX | ||
20 | AC_PROG_RANLIB | 27 | AC_PROG_RANLIB |
21 | 28 | ||
22 | AC_PATH_PROG(ACLOCAL,aclocal) | 29 | AC_PATH_PROG(ACLOCAL,aclocal) |
@@ -61,10 +68,6 @@ dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$ | |||
61 | LDFLAGS="$LDFLAGS -L." | 68 | LDFLAGS="$LDFLAGS -L." |
62 | 69 | ||
63 | dnl Checks for programs. | 70 | dnl Checks for programs. |
64 | AC_PROG_CC | ||
65 | AC_PROG_MAKE_SET | ||
66 | AC_PROG_AWK | ||
67 | |||
68 | AC_PATH_PROG(PYTHON,python) | 71 | AC_PATH_PROG(PYTHON,python) |
69 | AC_PATH_PROG(PERL,perl) | 72 | AC_PATH_PROG(PERL,perl) |
70 | AC_PATH_PROG(SH,sh) | 73 | AC_PATH_PROG(SH,sh) |
@@ -261,6 +264,7 @@ AC_HEADER_STDC | |||
261 | AC_HEADER_TIME | 264 | AC_HEADER_TIME |
262 | AC_HEADER_SYS_WAIT | 265 | AC_HEADER_SYS_WAIT |
263 | 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) | 266 | 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) |
267 | AC_CHECK_HEADERS(stdarg.h sys/unistd.h unistd.h ctype.h sys/wait.h stdlib.h) | ||
264 | 268 | ||
265 | dnl Checks for typedefs, structures, and compiler characteristics. | 269 | dnl Checks for typedefs, structures, and compiler characteristics. |
266 | AC_C_CONST | 270 | AC_C_CONST |
@@ -269,17 +273,65 @@ AC_TYPE_PID_T | |||
269 | AC_TYPE_SIZE_T | 273 | AC_TYPE_SIZE_T |
270 | AC_TYPE_SIGNAL | 274 | AC_TYPE_SIGNAL |
271 | 275 | ||
272 | dnl AC_CHECK_MEMBER(struct timeb.millitm,[AC_DEFINE(HAVE_STRUCT_TIMEB_MILLITM)],,[#include <sys/timeb.h>]) | 276 | AC_CHECK_SIZEOF(int,cross) |
277 | AC_CHECK_SIZEOF(long,cross) | ||
278 | AC_CHECK_SIZEOF(short,cross) | ||
273 | 279 | ||
274 | dnl EXTRA_LIBRARIES="libgetopt.a libsnprintf.a" | 280 | AC_CACHE_CHECK([for long long],ac_cv_have_longlong,[ |
275 | dnl noinst_LIBRARIES="libgetopt.a libsnprintf.a" | 281 | AC_TRY_RUN([#include <stdio.h> |
276 | dnl libgetopt_a_SOURCES="getopt.c getopt1.c" | 282 | main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }], |
277 | dnl libgetopt_a_DEPENDENCIES=getopt.h | 283 | ac_cv_have_longlong=yes,ac_cv_have_longlong=no,ac_cv_have_longlong=cross)]) |
278 | dnl libsnprintf_a_SOURCES=snprintf.c | 284 | if test x"$ac_cv_have_longlong" = x"yes"; then |
279 | dnl AC_SUBST(noinst_LIBRARIES) | 285 | AC_DEFINE(HAVE_LONGLONG) |
280 | dnl AC_SUBST(libgetopt_a_SOURCES) | 286 | fi |
281 | dnl AC_SUBST(libgetopt_a_DEPENDENCIES) | 287 | |
282 | dnl AC_SUBST(libsnprintf_a_SOURCES) | 288 | # |
289 | # Check if the compiler supports the LL prefix on long long integers. | ||
290 | # AIX needs this. | ||
291 | |||
292 | AC_CACHE_CHECK([for LL suffix on long long integers],ac_cv_compiler_supports_ll, [ | ||
293 | AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL], | ||
294 | ac_cv_compiler_supports_ll=yes,ac_cv_compiler_supports_ll=no)]) | ||
295 | if test x"$ac_cv_compiler_supports_ll" = x"yes"; then | ||
296 | AC_DEFINE(COMPILER_SUPPORTS_LL) | ||
297 | fi | ||
298 | AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE_VA_COPY,[ | ||
299 | AC_TRY_LINK([#include <stdarg.h> | ||
300 | va_list ap1,ap2;], [__va_copy(ap1,ap2);], | ||
301 | ac_cv_HAVE_VA_COPY=yes,ac_cv_HAVE_VA_COPY=no)]) | ||
302 | if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then | ||
303 | AC_DEFINE(HAVE_VA_COPY) | ||
304 | fi | ||
305 | |||
306 | AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[ | ||
307 | AC_TRY_RUN([ | ||
308 | #include <sys/types.h> | ||
309 | #include <stdarg.h> | ||
310 | void foo(const char *format, ...) { | ||
311 | va_list ap; | ||
312 | int len; | ||
313 | char buf[5]; | ||
314 | |||
315 | va_start(ap, format); | ||
316 | len = vsnprintf(buf, 0, format, ap); | ||
317 | va_end(ap); | ||
318 | if (len != 5) exit(1); | ||
319 | |||
320 | va_start(ap, format); | ||
321 | len = vsnprintf(0, 0, format, ap); | ||
322 | va_end(ap); | ||
323 | if (len != 5) exit(1); | ||
324 | |||
325 | if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); | ||
326 | |||
327 | exit(0); | ||
328 | } | ||
329 | main() { foo("hello"); } | ||
330 | ], | ||
331 | ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)]) | ||
332 | if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then | ||
333 | AC_DEFINE(HAVE_C99_VSNPRINTF) | ||
334 | fi | ||
283 | 335 | ||
284 | dnl We used to not do long options unless a compatible lib was found | 336 | dnl We used to not do long options unless a compatible lib was found |
285 | dnl Now we provide code and make libgetopt if native is not suitable | 337 | 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 | |||
302 | AC_CHECK_FUNC(asprintf,,LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a") | 354 | AC_CHECK_FUNC(asprintf,,LIBS="$LIBS -lsnprintf" DEPLIBS="$DEPLIBS libsnprintf.a") |
303 | 355 | ||
304 | dnl Checks for library functions. | 356 | dnl Checks for library functions. |
305 | AC_CHECK_FUNCS(select socket strdup strstr strtod strtol strtoul gettimeofday) | 357 | AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul gettimeofday) |
306 | 358 | ||
307 | AC_MSG_CHECKING(for type of socket size) | 359 | AC_MSG_CHECKING(for type of socket size) |
308 | AC_TRY_COMPILE([#include <stdlib.h> | 360 | AC_TRY_COMPILE([#include <stdlib.h> |
diff --git a/plugins/check_http.c b/plugins/check_http.c index b3b2263d..3ba406a8 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -222,9 +222,9 @@ main (int argc, char **argv) | |||
222 | 222 | ||
223 | if (strstr (timestamp, ":")) { | 223 | if (strstr (timestamp, ":")) { |
224 | if (strstr (server_url, "?")) | 224 | if (strstr (server_url, "?")) |
225 | server_url = ssprintf (server_url, "%s&%s", server_url, timestamp); | 225 | asprintf (&server_url, "%s&%s", server_url, timestamp); |
226 | else | 226 | else |
227 | server_url = ssprintf (server_url, "%s?%s", server_url, timestamp); | 227 | asprintf (&server_url, "%s?%s", server_url, timestamp); |
228 | } | 228 | } |
229 | 229 | ||
230 | if (display_html == TRUE) | 230 | if (display_html == TRUE) |
@@ -539,10 +539,8 @@ check_http (void) | |||
539 | #ifdef HAVE_SSL | 539 | #ifdef HAVE_SSL |
540 | if (use_ssl == TRUE) { | 540 | if (use_ssl == TRUE) { |
541 | 541 | ||
542 | if (connect_SSL () != OK) { | 542 | if (connect_SSL () != OK) |
543 | msg = ssprintf (msg, "Unable to open TCP socket"); | 543 | terminate (STATE_CRITICAL, "Unable to open TCP socket"); |
544 | terminate (STATE_CRITICAL, msg); | ||
545 | } | ||
546 | 544 | ||
547 | if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { | 545 | if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { |
548 | X509_free (server_cert); | 546 | X509_free (server_cert); |
@@ -552,7 +550,7 @@ check_http (void) | |||
552 | return STATE_CRITICAL; | 550 | return STATE_CRITICAL; |
553 | } | 551 | } |
554 | 552 | ||
555 | buf = ssprintf (buf, "%s %s HTTP/1.0\r\n", http_method, server_url); | 553 | asprintf (&buf, "%s %s HTTP/1.0\r\n", http_method, server_url); |
556 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 554 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
557 | ERR_print_errors_fp (stderr); | 555 | ERR_print_errors_fp (stderr); |
558 | return STATE_CRITICAL; | 556 | return STATE_CRITICAL; |
@@ -560,7 +558,7 @@ check_http (void) | |||
560 | 558 | ||
561 | /* optionally send the host header info (not clear if it's usable) */ | 559 | /* optionally send the host header info (not clear if it's usable) */ |
562 | if (strcmp (host_name, "")) { | 560 | if (strcmp (host_name, "")) { |
563 | buf = ssprintf (buf, "Host: %s\r\n", host_name); | 561 | asprintf (&buf, "Host: %s\r\n", host_name); |
564 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 562 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
565 | ERR_print_errors_fp (stderr); | 563 | ERR_print_errors_fp (stderr); |
566 | return STATE_CRITICAL; | 564 | return STATE_CRITICAL; |
@@ -568,7 +566,7 @@ check_http (void) | |||
568 | } | 566 | } |
569 | 567 | ||
570 | /* send user agent */ | 568 | /* send user agent */ |
571 | buf = ssprintf (buf, "User-Agent: check_http/%s (nagios-plugins %s)\r\n", | 569 | asprintf (&buf, "User-Agent: check_http/%s (nagios-plugins %s)\r\n", |
572 | clean_revstring (REVISION), PACKAGE_VERSION); | 570 | clean_revstring (REVISION), PACKAGE_VERSION); |
573 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 571 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
574 | ERR_print_errors_fp (stderr); | 572 | ERR_print_errors_fp (stderr); |
@@ -578,7 +576,7 @@ check_http (void) | |||
578 | /* optionally send the authentication info */ | 576 | /* optionally send the authentication info */ |
579 | if (strcmp (user_auth, "")) { | 577 | if (strcmp (user_auth, "")) { |
580 | auth = base64 (user_auth, strlen (user_auth)); | 578 | auth = base64 (user_auth, strlen (user_auth)); |
581 | buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth); | 579 | asprintf (&buf, "Authorization: Basic %s\r\n", auth); |
582 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 580 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
583 | ERR_print_errors_fp (stderr); | 581 | ERR_print_errors_fp (stderr); |
584 | return STATE_CRITICAL; | 582 | return STATE_CRITICAL; |
@@ -587,12 +585,12 @@ check_http (void) | |||
587 | 585 | ||
588 | /* optionally send http POST data */ | 586 | /* optionally send http POST data */ |
589 | if (http_post_data) { | 587 | if (http_post_data) { |
590 | buf = ssprintf (buf, "Content-Type: application/x-www-form-urlencoded\r\n"); | 588 | asprintf (&buf, "Content-Type: application/x-www-form-urlencoded\r\n"); |
591 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 589 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
592 | ERR_print_errors_fp (stderr); | 590 | ERR_print_errors_fp (stderr); |
593 | return STATE_CRITICAL; | 591 | return STATE_CRITICAL; |
594 | } | 592 | } |
595 | buf = ssprintf (buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data)); | 593 | asprintf (&buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data)); |
596 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 594 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
597 | ERR_print_errors_fp (stderr); | 595 | ERR_print_errors_fp (stderr); |
598 | return STATE_CRITICAL; | 596 | return STATE_CRITICAL; |
@@ -605,7 +603,7 @@ check_http (void) | |||
605 | } | 603 | } |
606 | 604 | ||
607 | /* send a newline so the server knows we're done with the request */ | 605 | /* send a newline so the server knows we're done with the request */ |
608 | buf = ssprintf (buf, "\r\n\r\n"); | 606 | asprintf (&buf, "\r\n\r\n"); |
609 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { | 607 | if (SSL_write (ssl, buf, strlen (buf)) == -1) { |
610 | ERR_print_errors_fp (stderr); | 608 | ERR_print_errors_fp (stderr); |
611 | return STATE_CRITICAL; | 609 | return STATE_CRITICAL; |
@@ -614,23 +612,21 @@ check_http (void) | |||
614 | } | 612 | } |
615 | else { | 613 | else { |
616 | #endif | 614 | #endif |
617 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) { | 615 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) |
618 | msg = ssprintf (msg, "Unable to open TCP socket"); | 616 | terminate (STATE_CRITICAL, "Unable to open TCP socket"); |
619 | terminate (STATE_CRITICAL, msg); | 617 | asprintf (&buf, "%s %s HTTP/1.0\r\n", http_method, server_url); |
620 | } | ||
621 | buf = ssprintf (buf, "%s %s HTTP/1.0\r\n", http_method, server_url); | ||
622 | send (sd, buf, strlen (buf), 0); | 618 | send (sd, buf, strlen (buf), 0); |
623 | 619 | ||
624 | 620 | ||
625 | 621 | ||
626 | /* optionally send the host header info */ | 622 | /* optionally send the host header info */ |
627 | if (strcmp (host_name, "")) { | 623 | if (strcmp (host_name, "")) { |
628 | buf = ssprintf (buf, "Host: %s\r\n", host_name); | 624 | asprintf (&buf, "Host: %s\r\n", host_name); |
629 | send (sd, buf, strlen (buf), 0); | 625 | send (sd, buf, strlen (buf), 0); |
630 | } | 626 | } |
631 | 627 | ||
632 | /* send user agent */ | 628 | /* send user agent */ |
633 | buf = ssprintf (buf, | 629 | asprintf (&buf, |
634 | "User-Agent: check_http/%s (nagios-plugins %s)\r\n", | 630 | "User-Agent: check_http/%s (nagios-plugins %s)\r\n", |
635 | clean_revstring (REVISION), PACKAGE_VERSION); | 631 | clean_revstring (REVISION), PACKAGE_VERSION); |
636 | send (sd, buf, strlen (buf), 0); | 632 | send (sd, buf, strlen (buf), 0); |
@@ -638,23 +634,23 @@ check_http (void) | |||
638 | /* optionally send the authentication info */ | 634 | /* optionally send the authentication info */ |
639 | if (strcmp (user_auth, "")) { | 635 | if (strcmp (user_auth, "")) { |
640 | auth = base64 (user_auth, strlen (user_auth)); | 636 | auth = base64 (user_auth, strlen (user_auth)); |
641 | buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth); | 637 | asprintf (&buf, "Authorization: Basic %s\r\n", auth); |
642 | send (sd, buf, strlen (buf), 0); | 638 | send (sd, buf, strlen (buf), 0); |
643 | } | 639 | } |
644 | 640 | ||
645 | /* optionally send http POST data */ | 641 | /* optionally send http POST data */ |
646 | /* written by Chris Henesy <lurker@shadowtech.org> */ | 642 | /* written by Chris Henesy <lurker@shadowtech.org> */ |
647 | if (http_post_data) { | 643 | if (http_post_data) { |
648 | buf = ssprintf (buf, "Content-Type: application/x-www-form-urlencoded\r\n"); | 644 | asprintf (&buf, "Content-Type: application/x-www-form-urlencoded\r\n"); |
649 | send (sd, buf, strlen (buf), 0); | 645 | send (sd, buf, strlen (buf), 0); |
650 | buf = ssprintf (buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data)); | 646 | asprintf (&buf, "Content-Length: %i\r\n\r\n", strlen (http_post_data)); |
651 | send (sd, buf, strlen (buf), 0); | 647 | send (sd, buf, strlen (buf), 0); |
652 | http_post_data = strscat (http_post_data, "\r\n"); | 648 | http_post_data = strscat (http_post_data, "\r\n"); |
653 | send (sd, http_post_data, strlen (http_post_data), 0); | 649 | send (sd, http_post_data, strlen (http_post_data), 0); |
654 | } | 650 | } |
655 | 651 | ||
656 | /* send a newline so the server knows we're done with the request */ | 652 | /* send a newline so the server knows we're done with the request */ |
657 | buf = ssprintf (buf, "\r\n\r\n"); | 653 | asprintf (&buf, "\r\n\r\n"); |
658 | send (sd, buf, strlen (buf), 0); | 654 | send (sd, buf, strlen (buf), 0); |
659 | #ifdef HAVE_SSL | 655 | #ifdef HAVE_SSL |
660 | } | 656 | } |
@@ -663,7 +659,7 @@ check_http (void) | |||
663 | /* fetch the page */ | 659 | /* fetch the page */ |
664 | pagesize = (size_t) 0; | 660 | pagesize = (size_t) 0; |
665 | while ((i = my_recv ()) > 0) { | 661 | while ((i = my_recv ()) > 0) { |
666 | buffer[i] = "\0"; | 662 | buffer[i] = '\0'; |
667 | full_page = strscat (full_page, buffer); | 663 | full_page = strscat (full_page, buffer); |
668 | pagesize += i; | 664 | pagesize += i; |
669 | } | 665 | } |
@@ -716,9 +712,9 @@ check_http (void) | |||
716 | /* make sure the status line matches the response we are looking for */ | 712 | /* make sure the status line matches the response we are looking for */ |
717 | if (!strstr (status_line, server_expect)) { | 713 | if (!strstr (status_line, server_expect)) { |
718 | if (server_port == HTTP_PORT) | 714 | if (server_port == HTTP_PORT) |
719 | msg = ssprintf (msg, "Invalid HTTP response received from host\n"); | 715 | asprintf (&msg, "Invalid HTTP response received from host\n"); |
720 | else | 716 | else |
721 | msg = ssprintf (msg, | 717 | asprintf (&msg, |
722 | "Invalid HTTP response received from host on port %d\n", | 718 | "Invalid HTTP response received from host on port %d\n", |
723 | server_port); | 719 | server_port); |
724 | terminate (STATE_CRITICAL, msg); | 720 | terminate (STATE_CRITICAL, msg); |
@@ -727,7 +723,7 @@ check_http (void) | |||
727 | 723 | ||
728 | /* Exit here if server_expect was set by user and not default */ | 724 | /* Exit here if server_expect was set by user and not default */ |
729 | if ( server_expect_yn ) { | 725 | if ( server_expect_yn ) { |
730 | msg = ssprintf (msg, "HTTP OK: Status line output matched \"%s\"\n", | 726 | asprintf (&msg, "HTTP OK: Status line output matched \"%s\"\n", |
731 | server_expect); | 727 | server_expect); |
732 | if (verbose) | 728 | if (verbose) |
733 | printf ("%s\n",msg); | 729 | printf ("%s\n",msg); |
@@ -742,8 +738,7 @@ check_http (void) | |||
742 | strstr (status_line, "501") || | 738 | strstr (status_line, "501") || |
743 | strstr (status_line, "502") || | 739 | strstr (status_line, "502") || |
744 | strstr (status_line, "503")) { | 740 | strstr (status_line, "503")) { |
745 | msg = ssprintf (msg, "HTTP CRITICAL: %s\n", status_line); | 741 | terminate (STATE_CRITICAL, "HTTP CRITICAL: %s\n", status_line); |
746 | terminate (STATE_CRITICAL, msg); | ||
747 | } | 742 | } |
748 | 743 | ||
749 | /* client errors result in a warning state */ | 744 | /* client errors result in a warning state */ |
@@ -752,8 +747,7 @@ check_http (void) | |||
752 | strstr (status_line, "402") || | 747 | strstr (status_line, "402") || |
753 | strstr (status_line, "403") || | 748 | strstr (status_line, "403") || |
754 | strstr (status_line, "404")) { | 749 | strstr (status_line, "404")) { |
755 | msg = ssprintf (msg, "HTTP WARNING: %s\n", status_line); | 750 | terminate (STATE_WARNING, "HTTP WARNING: %s\n", status_line); |
756 | terminate (STATE_WARNING, msg); | ||
757 | } | 751 | } |
758 | 752 | ||
759 | /* check redirected page if specified */ | 753 | /* check redirected page if specified */ |
@@ -807,7 +801,7 @@ check_http (void) | |||
807 | else if (sscanf (pos, HDR_LOCATION URI_PATH, server_url) == 1) { | 801 | else if (sscanf (pos, HDR_LOCATION URI_PATH, server_url) == 1) { |
808 | if ((server_url[0] != '/') && (x = strrchr(orig_url, '/'))) { | 802 | if ((server_url[0] != '/') && (x = strrchr(orig_url, '/'))) { |
809 | *x = '\0'; | 803 | *x = '\0'; |
810 | server_url = ssprintf (server_url, "%s/%s", orig_url, server_url); | 804 | asprintf (&server_url, "%s/%s", orig_url, server_url); |
811 | } | 805 | } |
812 | check_http (); | 806 | check_http (); |
813 | } | 807 | } |
@@ -828,7 +822,7 @@ check_http (void) | |||
828 | else if (onredirect == STATE_CRITICAL) | 822 | else if (onredirect == STATE_CRITICAL) |
829 | printf ("HTTP CRITICAL"); | 823 | printf ("HTTP CRITICAL"); |
830 | time (&end_time); | 824 | time (&end_time); |
831 | msg = ssprintf (msg, ": %s - %d second response time %s%s|time=%d\n", | 825 | asprintf (&msg, ": %s - %d second response time %s%s|time=%d\n", |
832 | status_line, (int) (end_time - start_time), timestamp, | 826 | status_line, (int) (end_time - start_time), timestamp, |
833 | (display_html ? "</A>" : ""), (int) (end_time - start_time)); | 827 | (display_html ? "</A>" : ""), (int) (end_time - start_time)); |
834 | terminate (onredirect, msg); | 828 | terminate (onredirect, msg); |
@@ -840,7 +834,7 @@ check_http (void) | |||
840 | 834 | ||
841 | /* check elapsed time */ | 835 | /* check elapsed time */ |
842 | time (&end_time); | 836 | time (&end_time); |
843 | msg = ssprintf (msg, "HTTP problem: %s - %d second response time %s%s|time=%d\n", | 837 | asprintf (&msg, "HTTP problem: %s - %d second response time %s%s|time=%d\n", |
844 | status_line, (int) (end_time - start_time), timestamp, | 838 | status_line, (int) (end_time - start_time), timestamp, |
845 | (display_html ? "</A>" : ""), (int) (end_time - start_time)); | 839 | (display_html ? "</A>" : ""), (int) (end_time - start_time)); |
846 | if (check_critical_time == TRUE && (end_time - start_time) > critical_time) | 840 | if (check_critical_time == TRUE && (end_time - start_time) > critical_time) |
@@ -889,7 +883,7 @@ check_http (void) | |||
889 | #endif | 883 | #endif |
890 | 884 | ||
891 | /* We only get here if all tests have been passed */ | 885 | /* We only get here if all tests have been passed */ |
892 | msg = ssprintf (msg, "HTTP ok: %s - %d second response time %s%s|time=%d\n", | 886 | asprintf (&msg, "HTTP ok: %s - %d second response time %s%s|time=%d\n", |
893 | status_line, (int) (end_time - start_time), | 887 | status_line, (int) (end_time - start_time), |
894 | timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time)); | 888 | timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time)); |
895 | terminate (STATE_OK, msg); | 889 | terminate (STATE_OK, msg); |