01 / INVENTORY AND CONFIGURATION · LESSON 02

Assess capacity thresholds

Compare exact disk utilisation against a threshold without rounding away the boundary.

16 min · learn at your pace

Decide with the original numbers

A dashboard may show 80% after rounding even when the actual ratio is below 80%. Conversely, a rounded display can hide how close an asset is to a threshold. Use original integer measurements for the decision and round only the presentation.

For a threshold of 80%, compare used * 100 >= total * 80. This avoids division and floating-point rounding at the decision boundary. The supplied totals are small enough for exact arithmetic, positive, and in the same unit. Comparing gigabytes with gibibytes without normalising units would not be meaningful.

State the boundary explicitly

The policy in this lesson flags utilisation at or above 80%. Exactly 80% therefore needs review. A value below the threshold stays within policy even if a different display format would round it upward. Use an integer floor percentage in the report so the displayed value has a clear meaning.

The input is a collector export rather than live output from df. Real df formats and options differ across platforms, so a production collector should normalise them before analysis. Keep the asset ID beside the result and sort data rows under LC_ALL=C; do not sort the header into the data.

Try an example.sh
used=79; total=100
printf 'used=%s total=%s\n' "$used" "$total"
YOUR TURN

Put it into practice.

capacity.tsv contains validated asset_id<TAB>used_mib<TAB>total_mib rows, with unique IDs, 0 <= used <= total <= 1000000 and total > 0. Print asset_id<TAB>used_percent<TAB>review for every row, sorted by asset ID in LC_ALL=C order. Display floor(used*100/total). Review is review when used*100 >= total*80, otherwise ok. Decide from the original ratio, not a rounded percentage.

See an explained solution
One way to solve it.sh
export LC_ALL=C
printf 'asset_id\tused_percent\treview\n'
awk -F '\t' 'NR>1 {printf "%s\t%d\t%s\n",$1,int($2*100/$3),($2*100 >= $3*80)?"review":"ok"}' capacity.tsv | sort

The decision compares cross-products of the original values, so rounding cannot move an asset across the threshold. The displayed percentage is deliberately floored and the report order is stable.