summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM. Sean Finney <seanius@users.sourceforge.net>2005-10-31 20:03:19 +0000
committerM. Sean Finney <seanius@users.sourceforge.net>2005-10-31 20:03:19 +0000
commit3038819fef47495af2730b0d2df2a5a8475fc7bb (patch)
tree978a1706ef546a153bfc41af7f33959b4543678c
parent0ff7d99a5e75683e778943884e60a11251183f45 (diff)
downloadmonitoring-plugins-3038819fef47495af2730b0d2df2a5a8475fc7bb.tar.gz
code cleanups, largely resulting from turning on -Wall. mostly
unused variables and explicit casting issues, but there were a couple gotchas in there too. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1267 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--configure.in5
-rw-r--r--plugins/check_game.c1
-rw-r--r--plugins/check_http.c7
-rw-r--r--plugins/check_nagios.c4
-rw-r--r--plugins/check_snmp.c4
-rw-r--r--plugins/check_swap.c4
-rw-r--r--plugins/check_tcp.c8
-rw-r--r--plugins/common.h2
-rw-r--r--plugins/netutils.c6
-rw-r--r--plugins/netutils.h2
-rw-r--r--plugins/sslutils.c1
11 files changed, 24 insertions, 20 deletions
diff --git a/configure.in b/configure.in
index 368bbf75..a3dbd725 100644
--- a/configure.in
+++ b/configure.in
@@ -162,6 +162,7 @@ AC_SUBST(SOCKETLIBS)
162 162
163dnl 163dnl
164dnl check for math-related functions needing -lm 164dnl check for math-related functions needing -lm
165AC_CHECK_HEADERS(math.h)
165AC_CHECK_LIB(m,floor,MATHLIBS="-lm") 166AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
166AC_SUBST(MATHLIBS) 167AC_SUBST(MATHLIBS)
167 168
@@ -909,6 +910,10 @@ if test -n "$ac_cv_ps_varlist" ; then
909 AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols, 910 AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols,
910 [Number of columns in ps command]) 911 [Number of columns in ps command])
911 EXTRAS="$EXTRAS check_procs check_nagios" 912 EXTRAS="$EXTRAS check_procs check_nagios"
913 if echo "$ac_cv_ps_varlist" | grep -q "procetime"; then
914 AC_DEFINE(PS_USES_PROCETIME,"yes",
915 [Whether the ps utility uses the "procetime" field])
916 fi
912fi 917fi
913 918
914AC_PATH_PROG(PATH_TO_PING,ping) 919AC_PATH_PROG(PATH_TO_PING,ping)
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 912072c2..8548bbdb 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -56,7 +56,6 @@ main (int argc, char **argv)
56{ 56{
57 char *command_line; 57 char *command_line;
58 int result = STATE_UNKNOWN; 58 int result = STATE_UNKNOWN;
59 FILE *fp;
60 char *p, *ret[QSTAT_MAX_RETURN_ARGS]; 59 char *p, *ret[QSTAT_MAX_RETURN_ARGS];
61 size_t i = 0; 60 size_t i = 0;
62 output chld_out; 61 output chld_out;
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 413d501d..9ff572e9 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -746,9 +746,6 @@ check_http (void)
746 double elapsed_time; 746 double elapsed_time;
747 int page_len = 0; 747 int page_len = 0;
748 int result = STATE_UNKNOWN; 748 int result = STATE_UNKNOWN;
749#ifdef HAVE_SSL
750 int sslerr;
751#endif
752 749
753 /* try to connect to the host at the given port number */ 750 /* try to connect to the host at the given port number */
754 if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) 751 if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
@@ -793,7 +790,7 @@ check_http (void)
793 asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); 790 asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
794 } 791 }
795 792
796 asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); 793 asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
797 asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 794 asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
798 } 795 }
799 else { 796 else {
@@ -858,7 +855,7 @@ check_http (void)
858 if (verbose) 855 if (verbose)
859 printf ("%s://%s:%d%s is %d characters\n", 856 printf ("%s://%s:%d%s is %d characters\n",
860 use_ssl ? "https" : "http", server_address, 857 use_ssl ? "https" : "http", server_address,
861 server_port, server_url, pagesize); 858 server_port, server_url, (int)pagesize);
862 859
863 /* find status line and null-terminate it */ 860 /* find status line and null-terminate it */
864 status_line = page; 861 status_line = page;
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index 0ae488ff..ab9c877b 100644
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
@@ -55,9 +55,9 @@ main (int argc, char **argv)
55 int procrss = 0; 55 int procrss = 0;
56 float procpcpu = 0; 56 float procpcpu = 0;
57 char procstat[8]; 57 char procstat[8];
58 /* procetime is unused in most configurations, but may be in PS_VAR_LIST 58#ifdef PS_USES_PROCETIME
59 * so it must be here in spite of it producing compiler warnings */
60 char procetime[MAX_INPUT_BUFFER]; 59 char procetime[MAX_INPUT_BUFFER];
60#endif /* PS_USES_PROCETIME */
61 char procprog[MAX_INPUT_BUFFER]; 61 char procprog[MAX_INPUT_BUFFER];
62 char *procargs; 62 char *procargs;
63 int pos, cols; 63 int pos, cols;
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 97c86a3a..db106f26 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -578,7 +578,7 @@ process_arguments (int argc, char **argv)
578 labels_size += 8; 578 labels_size += 8;
579 labels = realloc (labels, labels_size); 579 labels = realloc (labels, labels_size);
580 if (labels == NULL) 580 if (labels == NULL)
581 die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), nlabels); 581 die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels);
582 } 582 }
583 labels[nlabels - 1] = optarg; 583 labels[nlabels - 1] = optarg;
584 ptr = thisarg (optarg); 584 ptr = thisarg (optarg);
@@ -607,7 +607,7 @@ process_arguments (int argc, char **argv)
607 unitv_size += 8; 607 unitv_size += 8;
608 unitv = realloc (unitv, unitv_size); 608 unitv = realloc (unitv, unitv_size);
609 if (unitv == NULL) 609 if (unitv == NULL)
610 die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), nunits); 610 die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits);
611 } 611 }
612 unitv[nunits - 1] = optarg; 612 unitv[nunits - 1] = optarg;
613 ptr = thisarg (optarg); 613 ptr = thisarg (optarg);
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index aeeb9ba0..74b9daf6 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -385,7 +385,7 @@ process_arguments (int argc, char **argv)
385 } 385 }
386 else if (strstr (optarg, ",") && 386 else if (strstr (optarg, ",") &&
387 strstr (optarg, "%") && 387 strstr (optarg, "%") &&
388 sscanf (optarg, "%g,%d%%", &warn_size, &warn_percent) == 2) { 388 sscanf (optarg, "%lf,%d%%", &warn_size, &warn_percent) == 2) {
389 warn_size = floor(warn_size); 389 warn_size = floor(warn_size);
390 break; 390 break;
391 } 391 }
@@ -403,7 +403,7 @@ process_arguments (int argc, char **argv)
403 } 403 }
404 else if (strstr (optarg, ",") && 404 else if (strstr (optarg, ",") &&
405 strstr (optarg, "%") && 405 strstr (optarg, "%") &&
406 sscanf (optarg, "%g,%d%%", &crit_size, &crit_percent) == 2) { 406 sscanf (optarg, "%lf,%d%%", &crit_size, &crit_percent) == 2) {
407 crit_size = floor(crit_size); 407 crit_size = floor(crit_size);
408 break; 408 break;
409 } 409 }
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 2a77637c..cb7a869d 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -31,7 +31,6 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
31#ifdef HAVE_SSL 31#ifdef HAVE_SSL
32static int check_cert = FALSE; 32static int check_cert = FALSE;
33static int days_till_exp; 33static int days_till_exp;
34static char *randbuff = "";
35# define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) 34# define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
36# define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) 35# define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
37#else 36#else
@@ -51,7 +50,6 @@ static char *QUIT = NULL;
51static int PROTOCOL = IPPROTO_TCP; /* most common is default */ 50static int PROTOCOL = IPPROTO_TCP; /* most common is default */
52static int PORT = 0; 51static int PORT = 0;
53 52
54static char timestamp[17] = "";
55static int server_port = 0; 53static int server_port = 0;
56static char *server_address = NULL; 54static char *server_address = NULL;
57static char *server_send = NULL; 55static char *server_send = NULL;
@@ -199,7 +197,7 @@ main (int argc, char **argv)
199 if(flags & FLAG_VERBOSE) { 197 if(flags & FLAG_VERBOSE) {
200 printf("Using service %s\n", SERVICE); 198 printf("Using service %s\n", SERVICE);
201 printf("Port: %d\n", PORT); 199 printf("Port: %d\n", PORT);
202 printf("flags: 0x%x\n", flags); 200 printf("flags: 0x%x\n", (int)flags);
203 } 201 }
204 202
205 if(EXPECT && !server_expect_count) 203 if(EXPECT && !server_expect_count)
@@ -242,7 +240,7 @@ main (int argc, char **argv)
242 } 240 }
243 241
244 if(flags & FLAG_VERBOSE) { 242 if(flags & FLAG_VERBOSE) {
245 printf("server_expect_count: %d\n", server_expect_count); 243 printf("server_expect_count: %d\n", (int)server_expect_count);
246 for(i = 0; i < server_expect_count; i++) 244 for(i = 0; i < server_expect_count; i++)
247 printf("\t%d: %s\n", i, server_expect[i]); 245 printf("\t%d: %s\n", i, server_expect[i]);
248 } 246 }
@@ -274,7 +272,7 @@ main (int argc, char **argv)
274 /* print raw output if we're debugging */ 272 /* print raw output if we're debugging */
275 if(flags & FLAG_VERBOSE) 273 if(flags & FLAG_VERBOSE)
276 printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n", 274 printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n",
277 len + 1, status); 275 (int)len + 1, status);
278 while(isspace(status[len])) status[len--] = '\0'; 276 while(isspace(status[len])) status[len--] = '\0';
279 277
280 for (i = 0; i < server_expect_count; i++) { 278 for (i = 0; i < server_expect_count; i++) {
diff --git a/plugins/common.h b/plugins/common.h
index 5eac63e4..b4699cef 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -45,7 +45,7 @@
45#include <stdlib.h> 45#include <stdlib.h>
46#include <errno.h> 46#include <errno.h>
47 47
48#ifdef HUGE_VAL_NEEDS_MATH_H 48#ifdef HAVE_MATH_H
49#include <math.h> 49#include <math.h>
50#endif 50#endif
51 51
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 6f3a1510..b4c3944b 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -31,6 +31,8 @@
31* 31*
32****************************************************************************/ 32****************************************************************************/
33 33
34#define LOCAL_TIMEOUT_ALARM_HANDLER
35
34#include "common.h" 36#include "common.h"
35#include "netutils.h" 37#include "netutils.h"
36 38
@@ -217,14 +219,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
217 /* else the hostname is interpreted as a path to a unix socket */ 219 /* else the hostname is interpreted as a path to a unix socket */
218 else { 220 else {
219 if(strlen(host_name) >= UNIX_PATH_MAX){ 221 if(strlen(host_name) >= UNIX_PATH_MAX){
220 die(_("Supplied path too long unix domain socket")); 222 die(STATE_UNKNOWN, _("Supplied path too long unix domain socket"));
221 } 223 }
222 memset(&su, 0, sizeof(su)); 224 memset(&su, 0, sizeof(su));
223 su.sun_family = AF_UNIX; 225 su.sun_family = AF_UNIX;
224 strncpy(su.sun_path, host_name, UNIX_PATH_MAX); 226 strncpy(su.sun_path, host_name, UNIX_PATH_MAX);
225 *sd = socket(PF_UNIX, SOCK_STREAM, 0); 227 *sd = socket(PF_UNIX, SOCK_STREAM, 0);
226 if(sd < 0){ 228 if(sd < 0){
227 die(_("Socket creation failed")); 229 die(STATE_UNKNOWN, _("Socket creation failed"));
228 } 230 }
229 result = connect(*sd, (struct sockaddr *)&su, sizeof(su)); 231 result = connect(*sd, (struct sockaddr *)&su, sizeof(su));
230 if (result < 0 && errno == ECONNREFUSED) 232 if (result < 0 && errno == ECONNREFUSED)
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 8bc7bd61..1168f9f8 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -37,6 +37,7 @@
37 37
38#include "config.h" 38#include "config.h"
39#include "common.h" 39#include "common.h"
40#include "utils.h"
40#include <netinet/in.h> 41#include <netinet/in.h>
41#include <arpa/inet.h> 42#include <arpa/inet.h>
42 43
@@ -77,6 +78,7 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
77int is_host (const char *); 78int is_host (const char *);
78int is_addr (const char *); 79int is_addr (const char *);
79int resolve_host_or_addr (const char *, int); 80int resolve_host_or_addr (const char *, int);
81void host_or_die(const char *str);
80#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) 82#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
81#ifdef USE_IPV6 83#ifdef USE_IPV6
82# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) 84# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index d785fb75..66c72995 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -31,6 +31,7 @@
31* 31*
32****************************************************************************/ 32****************************************************************************/
33 33
34#define LOCAL_TIMEOUT_ALARM_HANDLER
34#include "common.h" 35#include "common.h"
35#include "netutils.h" 36#include "netutils.h"
36 37