diff options
Diffstat (limited to 'plugins/check_disk.c')
| -rw-r--r-- | plugins/check_disk.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index bd84c825..05e55022 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -131,9 +131,6 @@ bool stat_path (struct parameter_list *p); | |||
| 131 | void get_stats (struct parameter_list *p, struct fs_usage *fsp); | 131 | void get_stats (struct parameter_list *p, struct fs_usage *fsp); |
| 132 | void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); | 132 | void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); |
| 133 | 133 | ||
| 134 | double w_dfp = -1.0; | ||
| 135 | double c_dfp = -1.0; | ||
| 136 | char *path; | ||
| 137 | char *exclude_device; | 134 | char *exclude_device; |
| 138 | char *units; | 135 | char *units; |
| 139 | uintmax_t mult = 1024 * 1024; | 136 | uintmax_t mult = 1024 * 1024; |
| @@ -587,7 +584,7 @@ process_arguments (int argc, char **argv) | |||
| 587 | 584 | ||
| 588 | /* Awful mistake where the range values do not make sense. Normally, | 585 | /* Awful mistake where the range values do not make sense. Normally, |
| 589 | you alert if the value is within the range, but since we are using | 586 | you alert if the value is within the range, but since we are using |
| 590 | freespace, we have to alert if outside the range. Thus we artifically | 587 | freespace, we have to alert if outside the range. Thus we artificially |
| 591 | force @ at the beginning of the range, so that it is backwards compatible | 588 | force @ at the beginning of the range, so that it is backwards compatible |
| 592 | */ | 589 | */ |
| 593 | case 'c': /* critical threshold */ | 590 | case 'c': /* critical threshold */ |
| @@ -626,21 +623,36 @@ process_arguments (int argc, char **argv) | |||
| 626 | if (! strcasecmp (optarg, "bytes")) { | 623 | if (! strcasecmp (optarg, "bytes")) { |
| 627 | mult = (uintmax_t)1; | 624 | mult = (uintmax_t)1; |
| 628 | units = strdup ("B"); | 625 | units = strdup ("B"); |
| 629 | } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { | 626 | } else if (!strcmp(optarg, "KiB")) { |
| 630 | mult = (uintmax_t)1024; | 627 | mult = (uintmax_t)1024; |
| 631 | units = strdup ("kiB"); | 628 | units = strdup ("KiB"); |
| 632 | } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { | 629 | } else if (! strcmp (optarg, "kB")) { |
| 630 | mult = (uintmax_t)1000; | ||
| 631 | units = strdup ("kB"); | ||
| 632 | } else if (!strcmp(optarg, "MiB")) { | ||
| 633 | mult = (uintmax_t)1024 * 1024; | 633 | mult = (uintmax_t)1024 * 1024; |
| 634 | units = strdup ("MiB"); | 634 | units = strdup ("MiB"); |
| 635 | } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { | 635 | } else if (! strcmp (optarg, "MB")) { |
| 636 | mult = (uintmax_t)1000 * 1000; | ||
| 637 | units = strdup ("MB"); | ||
| 638 | } else if (!strcmp(optarg, "GiB")) { | ||
| 636 | mult = (uintmax_t)1024 * 1024 * 1024; | 639 | mult = (uintmax_t)1024 * 1024 * 1024; |
| 637 | units = strdup ("GiB"); | 640 | units = strdup ("GiB"); |
| 638 | } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { | 641 | } else if (! strcmp (optarg, "GB")){ |
| 642 | mult = (uintmax_t)1000 * 1000 * 1000; | ||
| 643 | units = strdup ("GB"); | ||
| 644 | } else if (!strcmp(optarg, "TiB")) { | ||
| 639 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024; | 645 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024; |
| 640 | units = strdup ("TiB"); | 646 | units = strdup ("TiB"); |
| 641 | } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { | 647 | } else if (! strcmp (optarg, "TB")) { |
| 648 | mult = (uintmax_t)1000 * 1000 * 1000 * 1000; | ||
| 649 | units = strdup ("TB"); | ||
| 650 | } else if (!strcmp(optarg, "PiB")) { | ||
| 642 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; | 651 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; |
| 643 | units = strdup ("PiB"); | 652 | units = strdup ("PiB"); |
| 653 | } else if (! strcmp (optarg, "PB")){ | ||
| 654 | mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000; | ||
| 655 | units = strdup ("PB"); | ||
| 644 | } else { | 656 | } else { |
| 645 | die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); | 657 | die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); |
| 646 | } | 658 | } |
| @@ -874,7 +886,7 @@ process_arguments (int argc, char **argv) | |||
| 874 | if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) | 886 | if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) |
| 875 | crit_usedspace_percent = argv[c++]; | 887 | crit_usedspace_percent = argv[c++]; |
| 876 | 888 | ||
| 877 | if (argc > c && path == NULL) { | 889 | if (argc > c) { |
| 878 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); | 890 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); |
| 879 | path_selected = TRUE; | 891 | path_selected = TRUE; |
| 880 | set_all_thresholds(se); | 892 | set_all_thresholds(se); |
| @@ -1115,7 +1127,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
| 1115 | p->available_to_root = fsp->fsu_bfree; | 1127 | p->available_to_root = fsp->fsu_bfree; |
| 1116 | p->used = fsp->fsu_blocks - fsp->fsu_bfree; | 1128 | p->used = fsp->fsu_blocks - fsp->fsu_bfree; |
| 1117 | if (freespace_ignore_reserved) { | 1129 | if (freespace_ignore_reserved) { |
| 1118 | /* option activated : we substract the root-reserved space from the total */ | 1130 | /* option activated : we subtract the root-reserved space from the total */ |
| 1119 | p->total = fsp->fsu_blocks - p->available_to_root + p->available; | 1131 | p->total = fsp->fsu_blocks - p->available_to_root + p->available; |
| 1120 | } else { | 1132 | } else { |
| 1121 | /* default behaviour : take all the blocks into account */ | 1133 | /* default behaviour : take all the blocks into account */ |
| @@ -1130,7 +1142,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
| 1130 | p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */ | 1142 | p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */ |
| 1131 | p->inodes_used = fsp->fsu_files - fsp->fsu_ffree; | 1143 | p->inodes_used = fsp->fsu_files - fsp->fsu_ffree; |
| 1132 | if (freespace_ignore_reserved) { | 1144 | if (freespace_ignore_reserved) { |
| 1133 | /* option activated : we substract the root-reserved inodes from the total */ | 1145 | /* option activated : we subtract the root-reserved inodes from the total */ |
| 1134 | /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */ | 1146 | /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */ |
| 1135 | /* for others, fsp->fsu_ffree == fsp->fsu_favail */ | 1147 | /* for others, fsp->fsu_ffree == fsp->fsu_favail */ |
| 1136 | p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free; | 1148 | p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free; |
