summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 0d941f25..73fe815e 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -933,31 +933,43 @@ void set_all_thresholds(parameter_list_elem *path, char *warn_freespace_units,
933 933
934 if (warn_freespace_units) { 934 if (warn_freespace_units) {
935 tmp = mp_parse_range_string(warn_freespace_units); 935 tmp = mp_parse_range_string(warn_freespace_units);
936 tmp.range.start = mp_create_pd_value(0);
937 tmp.range.start_infinity = false;
936 path->freespace_units = mp_thresholds_set_warn(path->freespace_units, tmp.range); 938 path->freespace_units = mp_thresholds_set_warn(path->freespace_units, tmp.range);
937 } 939 }
938 940
939 if (crit_freespace_units) { 941 if (crit_freespace_units) {
940 tmp = mp_parse_range_string(crit_freespace_units); 942 tmp = mp_parse_range_string(crit_freespace_units);
943 tmp.range.start = mp_create_pd_value(0);
944 tmp.range.start_infinity = false;
941 path->freespace_units = mp_thresholds_set_crit(path->freespace_units, tmp.range); 945 path->freespace_units = mp_thresholds_set_crit(path->freespace_units, tmp.range);
942 } 946 }
943 947
944 if (warn_freespace_percent) { 948 if (warn_freespace_percent) {
945 tmp = mp_parse_range_string(warn_freespace_percent); 949 tmp = mp_parse_range_string(warn_freespace_percent);
950 tmp.range.start = mp_create_pd_value(0);
951 tmp.range.start_infinity = false;
946 path->freespace_percent = mp_thresholds_set_warn(path->freespace_percent, tmp.range); 952 path->freespace_percent = mp_thresholds_set_warn(path->freespace_percent, tmp.range);
947 } 953 }
948 954
949 if (crit_freespace_percent) { 955 if (crit_freespace_percent) {
950 tmp = mp_parse_range_string(crit_freespace_percent); 956 tmp = mp_parse_range_string(crit_freespace_percent);
957 tmp.range.start = mp_create_pd_value(0);
958 tmp.range.start_infinity = false;
951 path->freespace_percent = mp_thresholds_set_crit(path->freespace_percent, tmp.range); 959 path->freespace_percent = mp_thresholds_set_crit(path->freespace_percent, tmp.range);
952 } 960 }
953 961
954 if (warn_freeinodes_percent) { 962 if (warn_freeinodes_percent) {
955 tmp = mp_parse_range_string(warn_freeinodes_percent); 963 tmp = mp_parse_range_string(warn_freeinodes_percent);
964 tmp.range.start = mp_create_pd_value(0);
965 tmp.range.start_infinity = false;
956 path->freeinodes_percent = mp_thresholds_set_warn(path->freeinodes_percent, tmp.range); 966 path->freeinodes_percent = mp_thresholds_set_warn(path->freeinodes_percent, tmp.range);
957 } 967 }
958 968
959 if (crit_freeinodes_percent) { 969 if (crit_freeinodes_percent) {
960 tmp = mp_parse_range_string(crit_freeinodes_percent); 970 tmp = mp_parse_range_string(crit_freeinodes_percent);
971 tmp.range.start = mp_create_pd_value(0);
972 tmp.range.start_infinity = false;
961 path->freeinodes_percent = mp_thresholds_set_crit(path->freeinodes_percent, tmp.range); 973 path->freeinodes_percent = mp_thresholds_set_crit(path->freeinodes_percent, tmp.range);
962 } 974 }
963} 975}
@@ -1182,14 +1194,22 @@ mp_subcheck evaluate_filesystem(measurement_unit measurement_unit, bool display_
1182 humanize_byte_value((unsigned long long)measurement_unit.total_bytes, false)); 1194 humanize_byte_value((unsigned long long)measurement_unit.total_bytes, false));
1183 } 1195 }
1184 1196
1185 mp_perfdata used_space = perfdata_init(); 1197 // Free space just internally for computation
1186 used_space.label = measurement_unit.name; 1198 mp_perfdata free_space_pd = perfdata_init();
1187 used_space.value = mp_create_pd_value(measurement_unit.free_bytes); 1199 free_space_pd.label = measurement_unit.name;
1188 used_space = mp_set_pd_max_value(used_space, mp_create_pd_value(measurement_unit.total_bytes)); 1200 free_space_pd.value = mp_create_pd_value(measurement_unit.free_bytes);
1189 used_space = mp_set_pd_min_value(used_space, mp_create_pd_value(0)); 1201 free_space_pd =
1190 used_space.uom = "B"; 1202 mp_pd_set_thresholds(free_space_pd, measurement_unit.freespace_bytes_thresholds);
1191 used_space = mp_pd_set_thresholds(used_space, measurement_unit.freespace_bytes_thresholds); 1203 freespace_bytes_sc = mp_set_subcheck_state(freespace_bytes_sc, mp_get_pd_status(free_space_pd));
1192 freespace_bytes_sc = mp_set_subcheck_state(freespace_bytes_sc, mp_get_pd_status(used_space)); 1204
1205 // Used space for display
1206 mp_perfdata used_space_pd = perfdata_init();
1207 used_space_pd.label = measurement_unit.name;
1208 used_space_pd.value = mp_create_pd_value(measurement_unit.used_bytes);
1209 used_space_pd =
1210 mp_set_pd_max_value(used_space_pd, mp_create_pd_value(measurement_unit.total_bytes));
1211 used_space_pd = mp_set_pd_min_value(used_space_pd, mp_create_pd_value(0));
1212 used_space_pd.uom = "B";
1193 1213
1194 // special case for absolute space thresholds here: 1214 // special case for absolute space thresholds here:
1195 // if absolute values are not set, compute the thresholds from percentage thresholds 1215 // if absolute values are not set, compute the thresholds from percentage thresholds
@@ -1209,7 +1229,8 @@ mp_subcheck evaluate_filesystem(measurement_unit measurement_unit, bool display_
1209 } 1229 }
1210 measurement_unit.freespace_bytes_thresholds = 1230 measurement_unit.freespace_bytes_thresholds =
1211 mp_thresholds_set_crit(measurement_unit.freespace_bytes_thresholds, tmp_range); 1231 mp_thresholds_set_crit(measurement_unit.freespace_bytes_thresholds, tmp_range);
1212 used_space = mp_pd_set_thresholds(used_space, measurement_unit.freespace_bytes_thresholds); 1232 free_space_pd =
1233 mp_pd_set_thresholds(free_space_pd, measurement_unit.freespace_bytes_thresholds);
1213 } 1234 }
1214 1235
1215 if (!temp_thlds.warning_is_set && 1236 if (!temp_thlds.warning_is_set &&
@@ -1225,10 +1246,22 @@ mp_subcheck evaluate_filesystem(measurement_unit measurement_unit, bool display_
1225 } 1246 }
1226 measurement_unit.freespace_bytes_thresholds = 1247 measurement_unit.freespace_bytes_thresholds =
1227 mp_thresholds_set_warn(measurement_unit.freespace_bytes_thresholds, tmp_range); 1248 mp_thresholds_set_warn(measurement_unit.freespace_bytes_thresholds, tmp_range);
1228 used_space = mp_pd_set_thresholds(used_space, measurement_unit.freespace_bytes_thresholds); 1249 free_space_pd =
1250 mp_pd_set_thresholds(free_space_pd, measurement_unit.freespace_bytes_thresholds);
1229 } 1251 }
1230 1252
1231 mp_add_perfdata_to_subcheck(&freespace_bytes_sc, used_space); 1253 mp_thresholds thr_used_space = measurement_unit.freespace_bytes_thresholds;
1254 if (thr_used_space.critical_is_set) {
1255 thr_used_space.critical.alert_on_inside_range =
1256 !thr_used_space.critical.alert_on_inside_range;
1257 }
1258 if (thr_used_space.warning_is_set) {
1259 thr_used_space.warning.alert_on_inside_range =
1260 !thr_used_space.warning.alert_on_inside_range;
1261 }
1262 used_space_pd = mp_pd_set_thresholds(used_space_pd, thr_used_space);
1263
1264 mp_add_perfdata_to_subcheck(&freespace_bytes_sc, used_space_pd);
1232 mp_add_subcheck_to_subcheck(&result, freespace_bytes_sc); 1265 mp_add_subcheck_to_subcheck(&result, freespace_bytes_sc);
1233 1266
1234 // ========================== 1267 // ==========================
@@ -1264,7 +1297,8 @@ mp_subcheck evaluate_filesystem(measurement_unit measurement_unit, bool display_
1264 1297
1265 mp_perfdata inode_percentage_pd = perfdata_init(); 1298 mp_perfdata inode_percentage_pd = perfdata_init();
1266 inode_percentage_pd = mp_set_pd_value(inode_percentage_pd, free_inode_percentage); 1299 inode_percentage_pd = mp_set_pd_value(inode_percentage_pd, free_inode_percentage);
1267 inode_percentage_pd = mp_pd_set_thresholds(inode_percentage_pd, measurement_unit.freeinodes_percent_thresholds); 1300 inode_percentage_pd = mp_pd_set_thresholds(inode_percentage_pd,
1301 measurement_unit.freeinodes_percent_thresholds);
1268 1302
1269 if (verbose > 0) { 1303 if (verbose > 0) {
1270 printf("free inode percentage computed: %g\n", free_inode_percentage); 1304 printf("free inode percentage computed: %g\n", free_inode_percentage);