summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM. Sean Finney <seanius@users.sourceforge.net>2005-06-28 00:26:53 +0000
committerM. Sean Finney <seanius@users.sourceforge.net>2005-06-28 00:26:53 +0000
commitd4c0948266f261525e12c58d58e0fc68987a9818 (patch)
treee7d8e6afe6c425a1e51446ace47b0fc4e99dcfd0
parentf573447d1f6dbf25b58bbfea81226a2ae3736555 (diff)
downloadmonitoring-plugins-d4c0948266f261525e12c58d58e0fc68987a9818.tar.gz
scanf parsing fix for check_swap from tracker id 1123292. now use floor(3)
to round down floating point numbers. requires -lm on many systems, so support for testing for this was added to the configure.in and automake template git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1194 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--configure.in7
-rw-r--r--plugins/Makefile.am3
-rw-r--r--plugins/check_swap.c18
3 files changed, 18 insertions, 10 deletions
diff --git a/configure.in b/configure.in
index df516c54..b209d19a 100644
--- a/configure.in
+++ b/configure.in
@@ -137,6 +137,11 @@ AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
137AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv") 137AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
138AC_SUBST(SOCKETLIBS) 138AC_SUBST(SOCKETLIBS)
139 139
140dnl
141dnl check for math-related functions needing -lm
142AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
143AC_SUBST(MATHLIBS)
144
140dnl Check for PostgreSQL libraries 145dnl Check for PostgreSQL libraries
141_SAVEDLIBS="$LIBS" 146_SAVEDLIBS="$LIBS"
142_SAVEDCPPFLAGS="$CPPFLAGS" 147_SAVEDCPPFLAGS="$CPPFLAGS"
@@ -567,7 +572,7 @@ AC_TRY_COMPILE([#include <sys/time.h>],
567 AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed]))) 572 AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
568 573
569dnl Checks for library functions. 574dnl Checks for library functions.
570AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul) 575AC_CHECK_FUNCS(memmove select socket strdup strstr strtod strtol strtoul, floor)
571 576
572AC_MSG_CHECKING(return type of socket size) 577AC_MSG_CHECKING(return type of socket size)
573AC_TRY_COMPILE([#include <stdlib.h> 578AC_TRY_COMPILE([#include <stdlib.h>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d983192b..87a97a9f 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -9,6 +9,7 @@ datadir = @datadir@
9localedir = $(datadir)/locale 9localedir = $(datadir)/locale
10DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ 10DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
11LIBS = @LIBINTL@ @LIBS@ @SSLINCLUDE@ 11LIBS = @LIBINTL@ @LIBS@ @SSLINCLUDE@
12MATHLIBS = @MATHLIBS@
12 13
13libexec_PROGRAMS = check_dhcp check_disk check_dummy check_http check_load \ 14libexec_PROGRAMS = check_dhcp check_disk check_dummy check_http check_load \
14 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ 15 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
@@ -72,7 +73,7 @@ check_real_LDADD = $(NETLIBS)
72check_snmp_LDADD = $(BASEOBJS) popen.o 73check_snmp_LDADD = $(BASEOBJS) popen.o
73check_smtp_LDADD = $(NETLIBS) $(SSLLIBS) 74check_smtp_LDADD = $(NETLIBS) $(SSLLIBS)
74check_ssh_LDADD = $(NETLIBS) 75check_ssh_LDADD = $(NETLIBS)
75check_swap_LDADD = $(BASEOBJS) popen.o 76check_swap_LDADD = $(MATHLIBS) $(BASEOBJS) popen.o
76check_tcp_LDADD = $(NETLIBS) $(SSLLIBS) 77check_tcp_LDADD = $(NETLIBS) $(SSLLIBS)
77check_time_LDADD = $(NETLIBS) 78check_time_LDADD = $(NETLIBS)
78check_udp_LDADD = $(NETLIBS) 79check_udp_LDADD = $(NETLIBS)
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index fe9254d2..8f5ebf8e 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -42,8 +42,8 @@ void print_help (void);
42 42
43int warn_percent = 0; 43int warn_percent = 0;
44int crit_percent = 0; 44int crit_percent = 0;
45float warn_size = 0; 45double warn_size = 0;
46float crit_size = 0; 46double crit_size = 0;
47int verbose; 47int verbose;
48int allswaps; 48int allswaps;
49 49
@@ -376,12 +376,13 @@ process_arguments (int argc, char **argv)
376 switch (c) { 376 switch (c) {
377 case 'w': /* warning size threshold */ 377 case 'w': /* warning size threshold */
378 if (is_intnonneg (optarg)) { 378 if (is_intnonneg (optarg)) {
379 warn_size = (float) atoi (optarg); 379 warn_size = (double) atoi (optarg);
380 break; 380 break;
381 } 381 }
382 else if (strstr (optarg, ",") && 382 else if (strstr (optarg, ",") &&
383 strstr (optarg, "%") && 383 strstr (optarg, "%") &&
384 sscanf (optarg, "%.0f,%d%%", &warn_size, &warn_percent) == 2) { 384 sscanf (optarg, "%g,%d%%", &warn_size, &warn_percent) == 2) {
385 warn_size = floor(warn_size);
385 break; 386 break;
386 } 387 }
387 else if (strstr (optarg, "%") && 388 else if (strstr (optarg, "%") &&
@@ -393,12 +394,13 @@ process_arguments (int argc, char **argv)
393 } 394 }
394 case 'c': /* critical size threshold */ 395 case 'c': /* critical size threshold */
395 if (is_intnonneg (optarg)) { 396 if (is_intnonneg (optarg)) {
396 crit_size = (float) atoi (optarg); 397 crit_size = (double) atoi (optarg);
397 break; 398 break;
398 } 399 }
399 else if (strstr (optarg, ",") && 400 else if (strstr (optarg, ",") &&
400 strstr (optarg, "%") && 401 strstr (optarg, "%") &&
401 sscanf (optarg, "%.0f,%d%%", &crit_size, &crit_percent) == 2) { 402 sscanf (optarg, "%g,%d%%", &crit_size, &crit_percent) == 2) {
403 crit_size = floor(crit_size);
402 break; 404 break;
403 } 405 }
404 else if (strstr (optarg, "%") && 406 else if (strstr (optarg, "%") &&
@@ -439,12 +441,12 @@ process_arguments (int argc, char **argv)
439 if (c == argc) 441 if (c == argc)
440 return validate_arguments (); 442 return validate_arguments ();
441 if (warn_size == 0 && is_intnonneg (argv[c])) 443 if (warn_size == 0 && is_intnonneg (argv[c]))
442 warn_size = (float) atoi (argv[c++]); 444 warn_size = (double) atoi (argv[c++]);
443 445
444 if (c == argc) 446 if (c == argc)
445 return validate_arguments (); 447 return validate_arguments ();
446 if (crit_size == 0 && is_intnonneg (argv[c])) 448 if (crit_size == 0 && is_intnonneg (argv[c]))
447 crit_size = atoi (argv[c++]); 449 crit_size = (double) atoi (argv[c++]);
448 450
449 return validate_arguments (); 451 return validate_arguments ();
450} 452}