diff options
author | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-28 00:26:53 (GMT) |
---|---|---|
committer | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-28 00:26:53 (GMT) |
commit | d4c0948266f261525e12c58d58e0fc68987a9818 (patch) | |
tree | e7d8e6afe6c425a1e51446ace47b0fc4e99dcfd0 /plugins/check_swap.c | |
parent | f573447d1f6dbf25b58bbfea81226a2ae3736555 (diff) | |
download | monitoring-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.c | 18 |
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 | ||
43 | int warn_percent = 0; | 43 | int warn_percent = 0; |
44 | int crit_percent = 0; | 44 | int crit_percent = 0; |
45 | float warn_size = 0; | 45 | double warn_size = 0; |
46 | float crit_size = 0; | 46 | double crit_size = 0; |
47 | int verbose; | 47 | int verbose; |
48 | int allswaps; | 48 | int 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 | } |