From 0f3703e641f0f995a8abb40056cb5430b6c228c4 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Fri, 14 Apr 2023 14:37:47 +0000 Subject: Fix a lot of typos reported by codespell --- plugins/check_disk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index bd84c825..a99f35e3 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -587,7 +587,7 @@ process_arguments (int argc, char **argv) /* Awful mistake where the range values do not make sense. Normally, you alert if the value is within the range, but since we are using - freespace, we have to alert if outside the range. Thus we artifically + freespace, we have to alert if outside the range. Thus we artificially force @ at the beginning of the range, so that it is backwards compatible */ case 'c': /* critical threshold */ @@ -1115,7 +1115,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { p->available_to_root = fsp->fsu_bfree; p->used = fsp->fsu_blocks - fsp->fsu_bfree; if (freespace_ignore_reserved) { - /* option activated : we substract the root-reserved space from the total */ + /* option activated : we subtract the root-reserved space from the total */ p->total = fsp->fsu_blocks - p->available_to_root + p->available; } else { /* default behaviour : take all the blocks into account */ @@ -1130,7 +1130,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */ p->inodes_used = fsp->fsu_files - fsp->fsu_ffree; if (freespace_ignore_reserved) { - /* option activated : we substract the root-reserved inodes from the total */ + /* option activated : we subtract the root-reserved inodes from the total */ /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */ /* for others, fsp->fsu_ffree == fsp->fsu_favail */ p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free; -- cgit v1.2.3-74-g34f1 From bf8eb6dcc7f9d1318ddeac16fe62a5b5f818524b Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 26 May 2023 08:43:24 +0200 Subject: check_disk: Display SI units correctly --- plugins/check_disk.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index a99f35e3..39dc6cd2 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -626,21 +626,36 @@ process_arguments (int argc, char **argv) if (! strcasecmp (optarg, "bytes")) { mult = (uintmax_t)1; units = strdup ("B"); - } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { + } else if (!strcmp(optarg, "KiB")) { mult = (uintmax_t)1024; - units = strdup ("kiB"); - } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { + units = strdup ("KiB"); + } else if (! strcmp (optarg, "kB")) { + mult = (uintmax_t)1000; + units = strdup ("kB"); + } else if (!strcmp(optarg, "MiB")) { mult = (uintmax_t)1024 * 1024; units = strdup ("MiB"); - } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { + } else if (! strcmp (optarg, "MB")) { + mult = (uintmax_t)1000 * 1000; + units = strdup ("MB"); + } else if (!strcmp(optarg, "GiB")) { mult = (uintmax_t)1024 * 1024 * 1024; units = strdup ("GiB"); - } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { + } else if (! strcmp (optarg, "GB")){ + mult = (uintmax_t)1000 * 1000 * 1000; + units = strdup ("GB"); + } else if (!strcmp(optarg, "TiB")) { mult = (uintmax_t)1024 * 1024 * 1024 * 1024; units = strdup ("TiB"); - } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { + } else if (! strcmp (optarg, "TB")) { + mult = (uintmax_t)1000 * 1000 * 1000 * 1000; + units = strdup ("TB"); + } else if (!strcmp(optarg, "PiB")) { mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; units = strdup ("PiB"); + } else if (! strcmp (optarg, "PB")){ + mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000; + units = strdup ("PB"); } else { die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); } -- cgit v1.2.3-74-g34f1 From 53ea2304aa8364f74e76f82430b67833fccf402f Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:50:55 +0200 Subject: check_disk: Remove some dead variables --- plugins/check_disk.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 39dc6cd2..05e55022 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -131,9 +131,6 @@ bool stat_path (struct parameter_list *p); void get_stats (struct parameter_list *p, struct fs_usage *fsp); void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); -double w_dfp = -1.0; -double c_dfp = -1.0; -char *path; char *exclude_device; char *units; uintmax_t mult = 1024 * 1024; @@ -889,7 +886,7 @@ process_arguments (int argc, char **argv) if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) crit_usedspace_percent = argv[c++]; - if (argc > c && path == NULL) { + if (argc > c) { se = np_add_parameter(&path_select_list, strdup(argv[c++])); path_selected = TRUE; set_all_thresholds(se); -- cgit v1.2.3-74-g34f1