diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7bed4d43960dccbda14f0434a8a591ef9873b0a8..bd060218a8aba6504220faeca8252b17a068c357 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
units,
free_space_pct,
(!strcmp(file_system, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
- asprintf (&details, _("%s\n%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%d crit:%d warn%%:%.0f%% crit%%:%.0f%%"),
- details,
- free_space,
- total_space,
- units,
- free_space_pct,
- me->me_devname,
- me->me_type,
- me->me_mountdir,
- w_df, c_df, w_dfp, c_dfp);
+ asprintf (&details, _("%s\n\
+%.0f of %.0f %s (%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
+ details, free_space, total_space, units, free_space_pct,
+ me->me_devname, me->me_type, me->me_mountdir,
+ (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
}
}
struct name_list *temp_list;
int result = OK;
+ unsigned long l;
+
int option_index = 0;
static struct option long_options[] = {
{"timeout", required_argument, 0, 't'},
}
else if (strpbrk (optarg, ",:") &&
strstr (optarg, "%") &&
- sscanf (optarg, "%ul%*[:,]%lf%%", &w_df, &w_dfp) == 2) {
+ sscanf (optarg, "%lu%*[:,]%lf%%", &l, &w_dfp) == 2) {
+ w_df = (uintmax_t)l;
break;
}
else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &w_dfp) == 1) {
}
else if (strpbrk (optarg, ",:") &&
strstr (optarg, "%") &&
- sscanf (optarg, "%ul%*[,:]%lf%%", &c_df, &c_dfp) == 2) {
+ sscanf (optarg, "%lu%*[,:]%lf%%", &l, &c_dfp) == 2) {
+ c_df = (uintmax_t)l;
break;
}
else if (strstr (optarg, "%") && sscanf (optarg, "%lf%%", &c_dfp) == 1) {
usage (_("Critical threshold must be integer or percentage!\n"));
}
case 'u':
+ if (units)
+ free(units);
if (! strcmp (optarg, "bytes")) {
mult = (uintmax_t)1;
- units = "B";
+ units = strdup ("B");
} else if (! strcmp (optarg, "kB")) {
mult = (uintmax_t)1024;
- units = "kB";
+ units = strdup ("kB");
} else if (! strcmp (optarg, "MB")) {
mult = (uintmax_t)1024 * 1024;
- units = "MB";
+ units = strdup ("MB");
} else if (! strcmp (optarg, "GB")) {
mult = (uintmax_t)1024 * 1024 * 1024;
- units = "GB";
+ units = strdup ("GB");
} else if (! strcmp (optarg, "TB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
- units = "TB";
+ units = strdup ("TB");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}
+ if (units == NULL)
+ die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
break;
case 'k': /* display mountpoint */
mult = 1024;
- units = "kB";
+ if (units)
+ free(units);
+ units = strdup ("kB");
break;
case 'm': /* display mountpoint */
mult = 1024 * 1024;
- units = "MB";
+ if (units)
+ free(units);
+ units = strdup ("kB");
break;
case 'l':
show_local_fs = 1;
@@ -476,9 +483,12 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
print_path (path);
return ERROR;
}
- else {
- return OK;
+
+ if (units == NULL) {
+ units = strdup ("MB");
+ mult = (uintmax_t)1024 * 1024;
}
+ return OK;
}