diff options
-rw-r--r-- | plugins/check_disk.c | 67 |
1 files changed, 8 insertions, 59 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 66c5dd3..7018c6f 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -171,7 +171,6 @@ main (int argc, char **argv) | |||
171 | char *perf_ilabel; | 171 | char *perf_ilabel; |
172 | char *preamble; | 172 | char *preamble; |
173 | char *flag_header; | 173 | char *flag_header; |
174 | double inode_space_pct; | ||
175 | int temp_result; | 174 | int temp_result; |
176 | 175 | ||
177 | struct mount_entry *me; | 176 | struct mount_entry *me; |
@@ -288,7 +287,7 @@ main (int argc, char **argv) | |||
288 | get_stats (path, &fsp); | 287 | get_stats (path, &fsp); |
289 | 288 | ||
290 | if (verbose >= 3) { | 289 | if (verbose >= 3) { |
291 | printf ("For %s, used_pct=%g free_pct=%g used_units=%llu free_units=%llu total_units=%llu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", | 290 | printf ("For %s, used_pct=%g free_pct=%g used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n", |
292 | me->me_mountdir, | 291 | me->me_mountdir, |
293 | path->dused_pct, | 292 | path->dused_pct, |
294 | path->dfree_pct, | 293 | path->dfree_pct, |
@@ -369,10 +368,10 @@ main (int argc, char **argv) | |||
369 | critical_high_tide = UINT64_MAX; | 368 | critical_high_tide = UINT64_MAX; |
370 | 369 | ||
371 | if (path->freeinodes_percent->warning != NULL) { | 370 | if (path->freeinodes_percent->warning != NULL) { |
372 | warning_high_tide = llabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total )); | 371 | warning_high_tide = (uint64_t) fabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total )); |
373 | } | 372 | } |
374 | if (path->freeinodes_percent->critical != NULL) { | 373 | if (path->freeinodes_percent->critical != NULL) { |
375 | critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total )); | 374 | critical_high_tide = (uint64_t) fabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total )); |
376 | } | 375 | } |
377 | 376 | ||
378 | xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); | 377 | xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); |
@@ -406,15 +405,7 @@ main (int argc, char **argv) | |||
406 | xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); | 405 | xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); |
407 | } | 406 | } |
408 | free(flag_header); | 407 | free(flag_header); |
409 | /* TODO: Need to do a similar debug line | ||
410 | xasprintf (&details, _("%s\n\%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"), | ||
411 | details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct, | ||
412 | me->me_devname, me->me_type, me->me_mountdir, | ||
413 | (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp); | ||
414 | */ | ||
415 | |||
416 | } | 408 | } |
417 | |||
418 | } | 409 | } |
419 | 410 | ||
420 | if (verbose >= 2) | 411 | if (verbose >= 2) |
@@ -689,6 +680,7 @@ process_arguments (int argc, char **argv) | |||
689 | break; | 680 | break; |
690 | case 'I': | 681 | case 'I': |
691 | cflags |= REG_ICASE; | 682 | cflags |= REG_ICASE; |
683 | // Intentional fallthrough | ||
692 | case 'i': | 684 | case 'i': |
693 | if (!path_selected) | 685 | if (!path_selected) |
694 | die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); | 686 | die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); |
@@ -728,8 +720,10 @@ process_arguments (int argc, char **argv) | |||
728 | 720 | ||
729 | case 'A': | 721 | case 'A': |
730 | optarg = strdup(".*"); | 722 | optarg = strdup(".*"); |
723 | // Intentional fallthrough | ||
731 | case 'R': | 724 | case 'R': |
732 | cflags |= REG_ICASE; | 725 | cflags |= REG_ICASE; |
726 | // Intentional fallthrough | ||
733 | case 'r': | 727 | case 'r': |
734 | if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || | 728 | if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || |
735 | crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || | 729 | crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || |
@@ -862,51 +856,6 @@ set_all_thresholds (struct parameter_list *path) | |||
862 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | 856 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); |
863 | } | 857 | } |
864 | 858 | ||
865 | /* TODO: Remove? | ||
866 | |||
867 | int | ||
868 | validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath) | ||
869 | { | ||
870 | if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) { | ||
871 | printf (_("INPUT ERROR: No thresholds specified")); | ||
872 | print_path (mypath); | ||
873 | return ERROR; | ||
874 | } | ||
875 | else if ((wp >= 0.0 || cp >= 0.0) && | ||
876 | (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) { | ||
877 | printf (_("\ | ||
878 | INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"), | ||
879 | cp, wp); | ||
880 | print_path (mypath); | ||
881 | return ERROR; | ||
882 | } | ||
883 | else if ((iwp >= 0.0 || icp >= 0.0) && | ||
884 | (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) { | ||
885 | printf (_("\ | ||
886 | INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"), | ||
887 | icp, iwp); | ||
888 | print_path (mypath); | ||
889 | return ERROR; | ||
890 | } | ||
891 | else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) { | ||
892 | printf (_("\ | ||
893 | INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"), | ||
894 | (unsigned long)c, (unsigned long)w); | ||
895 | print_path (mypath); | ||
896 | return ERROR; | ||
897 | } | ||
898 | |||
899 | return OK; | ||
900 | } | ||
901 | |||
902 | */ | ||
903 | |||
904 | |||
905 | |||
906 | |||
907 | |||
908 | |||
909 | |||
910 | void | 859 | void |
911 | print_help (void) | 860 | print_help (void) |
912 | { | 861 | { |
@@ -1042,7 +991,7 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
1042 | get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); | 991 | get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); |
1043 | get_path_stats(p_list, &tmpfsp); | 992 | get_path_stats(p_list, &tmpfsp); |
1044 | if (verbose >= 3) | 993 | if (verbose >= 3) |
1045 | printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%lu free_units=%llu total_units=%llu mult=%llu\n", | 994 | printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n", |
1046 | p_list->group, | 995 | p_list->group, |
1047 | tmpfsp.fsu_blocks, | 996 | tmpfsp.fsu_blocks, |
1048 | tmpfsp.fsu_blocksize, | 997 | tmpfsp.fsu_blocksize, |
@@ -1071,7 +1020,7 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
1071 | first = 0; | 1020 | first = 0; |
1072 | } | 1021 | } |
1073 | if (verbose >= 3) | 1022 | if (verbose >= 3) |
1074 | printf("Group %s now has: used_units=%llu free_units=%llu total_units=%llu fsu_blocksize=%llu mult=%llu\n", | 1023 | printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n", |
1075 | p->group, | 1024 | p->group, |
1076 | p->dused_units, | 1025 | p->dused_units, |
1077 | p->dfree_units, | 1026 | p->dfree_units, |