A Bash report can derive a capacity reserve number and classify it with fixed thresholds.

Program

Play the script to choose demand and inspect the reserve status line.

demand
capacity_reserve_reliability_report.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash

demand=72
capacity=100
reserve=$((capacity - demand))
if (( reserve >= 25 )); then
    status="stable"
elif (( reserve >= 10 )); then
    status="watch"
else
    status="tight"
fi
echo "demand=$demand reserve=$reserve status=$status"
#!/usr/bin/env bash

demand=88
capacity=100
reserve=$((capacity - demand))
if (( reserve >= 25 )); then
    status="stable"
elif (( reserve >= 10 )); then
    status="watch"
else
    status="tight"
fi
echo "demand=$demand reserve=$reserve status=$status"
#!/usr/bin/env bash

demand=95
capacity=100
reserve=$((capacity - demand))
if (( reserve >= 25 )); then
    status="stable"
elif (( reserve >= 10 )); then
    status="watch"
else
    status="tight"
fi
echo "demand=$demand reserve=$reserve status=$status"
  1. demand ← 72

    3demand=724capacity=100
    values this step72demand
  2. capacity ← 100

    3demand=724capacity=1005reserve=$((capacity - demand))
    values this step100capacity
  3. reserve ← 28

    4capacity=1005reserve=$((capacity - demand))6if (( reserve >= 25 )); then
    values this step28reserve100capacity72demand
  4. if (( reserve >= 25 )); then

    5reserve=$((capacity - demand))6if (( reserve >= 25 )); then7    status="stable"
    values this step28reserve
  5. status ← stable

    6if (( reserve >= 25 )); then7    status="stable"8elif (( reserve >= 10 )); then
    values this stepstablestatus
  6. echo "demand=$demand reserve=$reserve status=$status"

    12fi13echo "demand=$demand reserve=$reserve status=$status"
    outputdemand=72 reserve=28 status=stable
    values this step72demand28reservestablestatus
  1. demand ← 88

    3demand=884capacity=100
    values this step88demand
  2. capacity ← 100

    3demand=884capacity=1005reserve=$((capacity - demand))
    values this step100capacity
  3. reserve ← 12

    4capacity=1005reserve=$((capacity - demand))6if (( reserve >= 25 )); then
    values this step12reserve100capacity88demand
  4. if (( reserve >= 25 )); then

    5reserve=$((capacity - demand))6if (( reserve >= 25 )); then7    status="stable"
    values this step12reserve
  5. elif (( reserve >= 10 )); then

    7    status="stable"8elif (( reserve >= 10 )); then9    status="watch"
    values this step12reserve
  6. status ← watch

    8elif (( reserve >= 10 )); then9    status="watch"10else
    values this stepwatchstatus
  7. echo "demand=$demand reserve=$reserve status=$status"

    12fi13echo "demand=$demand reserve=$reserve status=$status"
    outputdemand=88 reserve=12 status=watch
    values this step88demand12reservewatchstatus
  1. demand ← 95

    3demand=954capacity=100
    values this step95demand
  2. capacity ← 100

    3demand=954capacity=1005reserve=$((capacity - demand))
    values this step100capacity
  3. reserve ← 5

    4capacity=1005reserve=$((capacity - demand))6if (( reserve >= 25 )); then
    values this step5reserve100capacity95demand
  4. if (( reserve >= 25 )); then

    5reserve=$((capacity - demand))6if (( reserve >= 25 )); then7    status="stable"
    values this step5reserve
  5. elif (( reserve >= 10 )); then

    7    status="stable"8elif (( reserve >= 10 )); then9    status="watch"
    values this step5reserve
  6. status ← tight

    10else11    status="tight"12fi
    values this steptightstatus
  7. echo "demand=$demand reserve=$reserve status=$status"

    12fi13echo "demand=$demand reserve=$reserve status=$status"
    outputdemand=95 reserve=5 status=tight
    values this step95demand5reservetightstatus
reserve The script derives reserve from fixed capacity minus selected demand.
classification The branch labels the margin as stable, watch, or tight.
deterministic input Demand is the only selector; no host capacity data is read.