summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
authorM. Sean Finney <seanius@users.sourceforge.net>2005-06-28 00:26:53 (GMT)
committerM. Sean Finney <seanius@users.sourceforge.net>2005-06-28 00:26:53 (GMT)
commitd4c0948266f261525e12c58d58e0fc68987a9818 (patch)
treee7d8e6afe6c425a1e51446ace47b0fc4e99dcfd0 /plugins/check_swap.c
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
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index fe9254d..8f5ebf8 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}