[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.6,1.7
Karl DeBisschop
kdebisschop at users.sourceforge.net
Wed Oct 16 03:15:06 CEST 2002
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv30400/plugins
Modified Files:
check_http.c
Log Message:
use asprintf
Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** check_http.c 25 Sep 2002 08:01:44 -0000 1.6
--- check_http.c 16 Oct 2002 10:14:53 -0000 1.7
***************
*** 223,229 ****
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
! server_url = ssprintf (server_url, "%s&%s", server_url, timestamp);
else
! server_url = ssprintf (server_url, "%s?%s", server_url, timestamp);
}
--- 223,229 ----
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
! asprintf (&server_url, "%s&%s", server_url, timestamp);
else
! asprintf (&server_url, "%s?%s", server_url, timestamp);
}
***************
*** 540,547 ****
if (use_ssl == TRUE) {
! if (connect_SSL () != OK) {
! msg = ssprintf (msg, "Unable to open TCP socket");
! terminate (STATE_CRITICAL, msg);
! }
if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
--- 540,545 ----
if (use_ssl == TRUE) {
! if (connect_SSL () != OK)
! terminate (STATE_CRITICAL, "Unable to open TCP socket");
if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
***************
*** 553,557 ****
}
! buf = ssprintf (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);
--- 551,555 ----
}
! 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);
***************
*** 561,565 ****
/* 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);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
--- 559,563 ----
/* optionally send the host header info (not clear if it's usable) */
if (strcmp (host_name, "")) {
! asprintf (&buf, "Host: %s\r\n", host_name);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 569,573 ****
/* send user agent */
! buf = ssprintf (buf, "User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
--- 567,571 ----
/* send user agent */
! 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) {
***************
*** 579,583 ****
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
--- 577,581 ----
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! asprintf (&buf, "Authorization: Basic %s\r\n", auth);
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 588,597 ****
/* optionally send http POST data */
if (http_post_data) {
! buf = ssprintf (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));
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
--- 586,595 ----
/* optionally send http POST data */
if (http_post_data) {
! 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;
}
! 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);
***************
*** 606,610 ****
/* send a newline so the server knows we're done with the request */
! buf = ssprintf (buf, "\r\n\r\n");
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
--- 604,608 ----
/* send a newline so the server knows we're done with the request */
! asprintf (&buf, "\r\n\r\n");
if (SSL_write (ssl, buf, strlen (buf)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 615,623 ****
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);
send (sd, buf, strlen (buf), 0);
--- 613,619 ----
else {
#endif
! 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);
***************
*** 626,635 ****
/* optionally send the host header info */
if (strcmp (host_name, "")) {
! buf = ssprintf (buf, "Host: %s\r\n", host_name);
send (sd, buf, strlen (buf), 0);
}
/* send user agent */
! buf = ssprintf (buf,
"User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
--- 622,631 ----
/* optionally send the host header info */
if (strcmp (host_name, "")) {
! asprintf (&buf, "Host: %s\r\n", host_name);
send (sd, buf, strlen (buf), 0);
}
/* send user agent */
! asprintf (&buf,
"User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
***************
*** 639,643 ****
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! buf = ssprintf (buf, "Authorization: Basic %s\r\n", auth);
send (sd, buf, strlen (buf), 0);
}
--- 635,639 ----
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! asprintf (&buf, "Authorization: Basic %s\r\n", auth);
send (sd, buf, strlen (buf), 0);
}
***************
*** 646,652 ****
/* written by Chris Henesy <lurker at shadowtech.org> */
if (http_post_data) {
! buf = ssprintf (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));
send (sd, buf, strlen (buf), 0);
http_post_data = strscat (http_post_data, "\r\n");
--- 642,648 ----
/* written by Chris Henesy <lurker at shadowtech.org> */
if (http_post_data) {
! asprintf (&buf, "Content-Type: application/x-www-form-urlencoded\r\n");
send (sd, buf, strlen (buf), 0);
! 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");
***************
*** 655,659 ****
/* send a newline so the server knows we're done with the request */
! buf = ssprintf (buf, "\r\n\r\n");
send (sd, buf, strlen (buf), 0);
#ifdef HAVE_SSL
--- 651,655 ----
/* send a newline so the server knows we're done with the request */
! asprintf (&buf, "\r\n\r\n");
send (sd, buf, strlen (buf), 0);
#ifdef HAVE_SSL
***************
*** 664,668 ****
pagesize = (size_t) 0;
while ((i = my_recv ()) > 0) {
! buffer[i] = "\0";
full_page = strscat (full_page, buffer);
pagesize += i;
--- 660,664 ----
pagesize = (size_t) 0;
while ((i = my_recv ()) > 0) {
! buffer[i] = '\0';
full_page = strscat (full_page, buffer);
pagesize += i;
***************
*** 717,723 ****
if (!strstr (status_line, server_expect)) {
if (server_port == HTTP_PORT)
! msg = ssprintf (msg, "Invalid HTTP response received from host\n");
else
! msg = ssprintf (msg,
"Invalid HTTP response received from host on port %d\n",
server_port);
--- 713,719 ----
if (!strstr (status_line, server_expect)) {
if (server_port == HTTP_PORT)
! asprintf (&msg, "Invalid HTTP response received from host\n");
else
! asprintf (&msg,
"Invalid HTTP response received from host on port %d\n",
server_port);
***************
*** 728,732 ****
/* 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",
server_expect);
if (verbose)
--- 724,728 ----
/* Exit here if server_expect was set by user and not default */
if ( server_expect_yn ) {
! asprintf (&msg, "HTTP OK: Status line output matched \"%s\"\n",
server_expect);
if (verbose)
***************
*** 743,748 ****
strstr (status_line, "502") ||
strstr (status_line, "503")) {
! msg = ssprintf (msg, "HTTP CRITICAL: %s\n", status_line);
! terminate (STATE_CRITICAL, msg);
}
--- 739,743 ----
strstr (status_line, "502") ||
strstr (status_line, "503")) {
! terminate (STATE_CRITICAL, "HTTP CRITICAL: %s\n", status_line);
}
***************
*** 753,758 ****
strstr (status_line, "403") ||
strstr (status_line, "404")) {
! msg = ssprintf (msg, "HTTP WARNING: %s\n", status_line);
! terminate (STATE_WARNING, msg);
}
--- 748,752 ----
strstr (status_line, "403") ||
strstr (status_line, "404")) {
! terminate (STATE_WARNING, "HTTP WARNING: %s\n", status_line);
}
***************
*** 808,812 ****
if ((server_url[0] != '/') && (x = strrchr(orig_url, '/'))) {
*x = '\0';
! server_url = ssprintf (server_url, "%s/%s", orig_url, server_url);
}
check_http ();
--- 802,806 ----
if ((server_url[0] != '/') && (x = strrchr(orig_url, '/'))) {
*x = '\0';
! asprintf (&server_url, "%s/%s", orig_url, server_url);
}
check_http ();
***************
*** 829,833 ****
printf ("HTTP CRITICAL");
time (&end_time);
! msg = ssprintf (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));
--- 823,827 ----
printf ("HTTP CRITICAL");
time (&end_time);
! 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));
***************
*** 841,845 ****
/* check elapsed time */
time (&end_time);
! msg = ssprintf (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));
--- 835,839 ----
/* check elapsed time */
time (&end_time);
! 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));
***************
*** 890,894 ****
/* 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",
status_line, (int) (end_time - start_time),
timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time));
--- 884,888 ----
/* We only get here if all tests have been passed */
! 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));
More information about the Commits
mailing list