diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_disk.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index c3534060..b5a375d0 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -62,10 +62,10 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 62 | static int show_all_fs = 1; | 62 | static int show_all_fs = 1; |
| 63 | 63 | ||
| 64 | /* If nonzero, show only local filesystems. */ | 64 | /* If nonzero, show only local filesystems. */ |
| 65 | static int show_local_fs = 0; | 65 | static bool show_local_fs = false; |
| 66 | 66 | ||
| 67 | /* If nonzero, show only local filesystems but call stat() on remote ones. */ | 67 | /* If nonzero, show only local filesystems but call stat() on remote ones. */ |
| 68 | static int stat_remote_fs = 0; | 68 | static bool stat_remote_fs = false; |
| 69 | 69 | ||
| 70 | /* If positive, the units to use when printing sizes; | 70 | /* If positive, the units to use when printing sizes; |
| 71 | if negative, the human-readable base. */ | 71 | if negative, the human-readable base. */ |
| @@ -121,7 +121,7 @@ static int process_arguments(int /*argc*/, char ** /*argv*/); | |||
| 121 | static void set_all_thresholds(struct parameter_list *path); | 121 | static void set_all_thresholds(struct parameter_list *path); |
| 122 | static void print_help(void); | 122 | static void print_help(void); |
| 123 | void print_usage(void); | 123 | void print_usage(void); |
| 124 | static double calculate_percent(uintmax_t, uintmax_t); | 124 | static double calculate_percent(uintmax_t /*value*/, uintmax_t /*total*/); |
| 125 | static bool stat_path(struct parameter_list *p); | 125 | static bool stat_path(struct parameter_list *p); |
| 126 | static void get_stats(struct parameter_list *p, struct fs_usage *fsp); | 126 | static void get_stats(struct parameter_list *p, struct fs_usage *fsp); |
| 127 | static void get_path_stats(struct parameter_list *p, struct fs_usage *fsp); | 127 | static void get_path_stats(struct parameter_list *p, struct fs_usage *fsp); |
| @@ -198,7 +198,7 @@ int main(int argc, char **argv) { | |||
| 198 | /* If a list of paths has not been selected, find entire | 198 | /* If a list of paths has not been selected, find entire |
| 199 | mount list and create list of paths | 199 | mount list and create list of paths |
| 200 | */ | 200 | */ |
| 201 | if (path_selected == false && path_ignored == false) { | 201 | if (!path_selected && !path_ignored) { |
| 202 | for (me = mount_list; me; me = me->me_next) { | 202 | for (me = mount_list; me; me = me->me_next) { |
| 203 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) { | 203 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) { |
| 204 | path = np_add_parameter(&path_select_list, me->me_mountdir); | 204 | path = np_add_parameter(&path_select_list, me->me_mountdir); |
| @@ -209,7 +209,7 @@ int main(int argc, char **argv) { | |||
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | if (path_ignored == false) { | 212 | if (!path_ignored) { |
| 213 | np_set_best_match(path_select_list, mount_list, exact_match); | 213 | np_set_best_match(path_select_list, mount_list, exact_match); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -217,7 +217,7 @@ int main(int argc, char **argv) { | |||
| 217 | temp_list = path_select_list; | 217 | temp_list = path_select_list; |
| 218 | 218 | ||
| 219 | while (path_select_list) { | 219 | while (path_select_list) { |
| 220 | if (!path_select_list->best_match && ignore_missing == true) { | 220 | if (!path_select_list->best_match && ignore_missing) { |
| 221 | /* If the first element will be deleted, the temp_list must be updated with the new start address as well */ | 221 | /* If the first element will be deleted, the temp_list must be updated with the new start address as well */ |
| 222 | if (path_select_list == temp_list) { | 222 | if (path_select_list == temp_list) { |
| 223 | temp_list = path_select_list->name_next; | 223 | temp_list = path_select_list->name_next; |
| @@ -237,7 +237,7 @@ int main(int argc, char **argv) { | |||
| 237 | 237 | ||
| 238 | path_select_list = temp_list; | 238 | path_select_list = temp_list; |
| 239 | 239 | ||
| 240 | if (!path_select_list && ignore_missing == true) { | 240 | if (!path_select_list && ignore_missing) { |
| 241 | result = STATE_OK; | 241 | result = STATE_OK; |
| 242 | if (verbose >= 2) { | 242 | if (verbose >= 2) { |
| 243 | printf("None of the provided paths were found\n"); | 243 | printf("None of the provided paths were found\n"); |
| @@ -285,7 +285,7 @@ int main(int argc, char **argv) { | |||
| 285 | /* Skip remote filesystems if we're not interested in them */ | 285 | /* Skip remote filesystems if we're not interested in them */ |
| 286 | if (me->me_remote && show_local_fs) { | 286 | if (me->me_remote && show_local_fs) { |
| 287 | if (stat_remote_fs) { | 287 | if (stat_remote_fs) { |
| 288 | if (!stat_path(path) && ignore_missing == true) { | 288 | if (!stat_path(path) && ignore_missing) { |
| 289 | result = STATE_OK; | 289 | result = STATE_OK; |
| 290 | xasprintf(&ignored, "%s %s;", ignored, path->name); | 290 | xasprintf(&ignored, "%s %s;", ignored, path->name); |
| 291 | } | 291 | } |
| @@ -311,7 +311,7 @@ int main(int argc, char **argv) { | |||
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | if (!stat_path(path)) { | 313 | if (!stat_path(path)) { |
| 314 | if (ignore_missing == true) { | 314 | if (ignore_missing) { |
| 315 | result = STATE_OK; | 315 | result = STATE_OK; |
| 316 | xasprintf(&ignored, "%s %s;", ignored, path->name); | 316 | xasprintf(&ignored, "%s %s;", ignored, path->name); |
| 317 | } | 317 | } |
| @@ -398,8 +398,8 @@ int main(int argc, char **argv) { | |||
| 398 | /* Nb: *_high_tide are unset when == UINT64_MAX */ | 398 | /* Nb: *_high_tide are unset when == UINT64_MAX */ |
| 399 | xasprintf(&perf, "%s %s", perf, | 399 | xasprintf(&perf, "%s %s", perf, |
| 400 | perfdata_uint64((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, | 400 | perfdata_uint64((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, |
| 401 | path->dused_units * mult, "B", (warning_high_tide == UINT64_MAX ? false : true), warning_high_tide, | 401 | path->dused_units * mult, "B", (warning_high_tide != UINT64_MAX ), warning_high_tide, |
| 402 | (critical_high_tide == UINT64_MAX ? false : true), critical_high_tide, true, 0, true, | 402 | (critical_high_tide != UINT64_MAX ), critical_high_tide, true, 0, true, |
| 403 | path->dtotal_units * mult)); | 403 | path->dtotal_units * mult)); |
| 404 | 404 | ||
| 405 | if (display_inodes_perfdata) { | 405 | if (display_inodes_perfdata) { |
| @@ -420,8 +420,8 @@ int main(int argc, char **argv) { | |||
| 420 | (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); | 420 | (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); |
| 421 | /* Nb: *_high_tide are unset when == UINT64_MAX */ | 421 | /* Nb: *_high_tide are unset when == UINT64_MAX */ |
| 422 | xasprintf(&perf, "%s %s", perf, | 422 | xasprintf(&perf, "%s %s", perf, |
| 423 | perfdata_uint64(perf_ilabel, path->inodes_used, "", (warning_high_tide != UINT64_MAX ? true : false), | 423 | perfdata_uint64(perf_ilabel, path->inodes_used, "", (warning_high_tide != UINT64_MAX), |
| 424 | warning_high_tide, (critical_high_tide != UINT64_MAX ? true : false), critical_high_tide, true, 0, | 424 | warning_high_tide, (critical_high_tide != UINT64_MAX), critical_high_tide, true, 0, |
| 425 | true, path->inodes_total)); | 425 | true, path->inodes_total)); |
| 426 | } | 426 | } |
| 427 | 427 | ||
| @@ -669,13 +669,13 @@ int process_arguments(int argc, char **argv) { | |||
| 669 | units = strdup("MiB"); | 669 | units = strdup("MiB"); |
| 670 | break; | 670 | break; |
| 671 | case 'L': | 671 | case 'L': |
| 672 | stat_remote_fs = 1; | 672 | stat_remote_fs = true; |
| 673 | /* fallthrough */ | 673 | /* fallthrough */ |
| 674 | case 'l': | 674 | case 'l': |
| 675 | show_local_fs = 1; | 675 | show_local_fs = true; |
| 676 | break; | 676 | break; |
| 677 | case 'P': | 677 | case 'P': |
| 678 | display_inodes_perfdata = 1; | 678 | display_inodes_perfdata = true; |
| 679 | break; | 679 | break; |
| 680 | case 'p': /* select path */ | 680 | case 'p': /* select path */ |
| 681 | if (!(warn_freespace_units || crit_freespace_units || warn_freespace_percent || crit_freespace_percent || | 681 | if (!(warn_freespace_units || crit_freespace_units || warn_freespace_percent || crit_freespace_percent || |
| @@ -688,7 +688,7 @@ int process_arguments(int argc, char **argv) { | |||
| 688 | if (!(se = np_find_parameter(path_select_list, optarg))) { | 688 | if (!(se = np_find_parameter(path_select_list, optarg))) { |
| 689 | se = np_add_parameter(&path_select_list, optarg); | 689 | se = np_add_parameter(&path_select_list, optarg); |
| 690 | 690 | ||
| 691 | if (stat(optarg, &stat_buf[0]) && ignore_missing == true) { | 691 | if (stat(optarg, &stat_buf[0]) && ignore_missing) { |
| 692 | path_ignored = true; | 692 | path_ignored = true; |
| 693 | break; | 693 | break; |
| 694 | } | 694 | } |
| @@ -832,7 +832,7 @@ int process_arguments(int argc, char **argv) { | |||
| 832 | } | 832 | } |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | if (!fnd && ignore_missing == true) { | 835 | if (!fnd && ignore_missing) { |
| 836 | path_ignored = true; | 836 | path_ignored = true; |
| 837 | path_selected = true; | 837 | path_selected = true; |
| 838 | break; | 838 | break; |
| @@ -852,7 +852,7 @@ int process_arguments(int argc, char **argv) { | |||
| 852 | break; | 852 | break; |
| 853 | case 'C': | 853 | case 'C': |
| 854 | /* add all mount entries to path_select list if no partitions have been explicitly defined using -p */ | 854 | /* add all mount entries to path_select list if no partitions have been explicitly defined using -p */ |
| 855 | if (path_selected == false) { | 855 | if (!path_selected) { |
| 856 | struct parameter_list *path; | 856 | struct parameter_list *path; |
| 857 | for (me = mount_list; me; me = me->me_next) { | 857 | for (me = mount_list; me; me = me->me_next) { |
| 858 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) { | 858 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) { |
| @@ -1055,7 +1055,7 @@ bool stat_path(struct parameter_list *p) { | |||
| 1055 | if (verbose >= 3) { | 1055 | if (verbose >= 3) { |
| 1056 | printf("stat failed on %s\n", p->name); | 1056 | printf("stat failed on %s\n", p->name); |
| 1057 | } | 1057 | } |
| 1058 | if (ignore_missing == true) { | 1058 | if (ignore_missing) { |
| 1059 | return false; | 1059 | return false; |
| 1060 | } | 1060 | } |
| 1061 | printf("DISK %s - ", _("CRITICAL")); | 1061 | printf("DISK %s - ", _("CRITICAL")); |
