Author: Stephen Baynes Description: Calculate performance data thresholds with non-root figures so consistent with % free and check status. --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -160,9 +160,9 @@ char *perf; char *preamble; double inode_space_pct; - uintmax_t total, available, available_to_root, used; + uintmax_t total, total_not_root, available, available_to_root, used; double dfree_pct = -1, dused_pct = -1; - double dused_units, dfree_units, dtotal_units; + double dused_units, dfree_units, dtotal_units, dtotal_not_root_units; double dused_inodes_percent, dfree_inodes_percent; double warning_high_tide; double critical_high_tide; @@ -308,23 +308,25 @@ available = fsp.fsu_bavail > fsp.fsu_bfree ? 0 : fsp.fsu_bavail; available_to_root = fsp.fsu_bfree; used = total - available_to_root; + total_not_root = used + available; if (verbose >= 3) - printf ("For %s, total=%llu, available=%llu, available_to_root=%llu, used=%llu, fsp.fsu_files=%llu, fsp.fsu_ffree=%llu\n", - me->me_mountdir, total, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree); + printf ("For %s, total=%llu, total_not_root=%llu, available=%llu, available_to_root=%llu, used=%llu, fsp.fsu_files=%llu, fsp.fsu_ffree=%llu\n", + me->me_mountdir, total, total_not_root, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree); - dused_pct = calculate_percent( used, used + available ); /* used + available can never be > uintmax */ + dused_pct = calculate_percent( used, total_not_root ); /* used + available can never be > uintmax */ dfree_pct = 100 - dused_pct; dused_units = used*fsp.fsu_blocksize/mult; dfree_units = available*fsp.fsu_blocksize/mult; dtotal_units = total*fsp.fsu_blocksize/mult; + dtotal_not_root_units = total_not_root*fsp.fsu_blocksize/mult; dused_inodes_percent = calculate_percent(fsp.fsu_files - fsp.fsu_ffree, fsp.fsu_files); dfree_inodes_percent = 100 - dused_inodes_percent; if (verbose >= 3) { - printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", - me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult); + printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g total_not_root_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", + me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dtotal_not_root_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult); } /* Threshold comparisons */ @@ -368,13 +370,13 @@ warning_high_tide = dtotal_units - path->freespace_units->warning->end; } if (path->freespace_percent->warning != NULL) { - warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units )); + warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_not_root_units )); } if (path->freespace_units->critical != NULL) { critical_high_tide = dtotal_units - path->freespace_units->critical->end; } if (path->freespace_percent->critical != NULL) { - critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units )); + critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_not_root_units )); } /* Nb: *_high_tide are unset when == UINT_MAX */