A Bash incident report can count visible severities and keep high-severity incidents visible.

Program

Play the script to choose the minimum severity and inspect the queue count report.

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

min_severity=2
severities="1 3 2 3"
visible=0
high=0
for severity in $severities; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
    if (( severity == 3 )); then
        high=$((high + 1))
    fi
done
echo "min=$min_severity visible=$visible high=$high"
#!/usr/bin/env bash

min_severity=1
severities="1 3 2 3"
visible=0
high=0
for severity in $severities; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
    if (( severity == 3 )); then
        high=$((high + 1))
    fi
done
echo "min=$min_severity visible=$visible high=$high"
#!/usr/bin/env bash

min_severity=3
severities="1 3 2 3"
visible=0
high=0
for severity in $severities; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
    if (( severity == 3 )); then
        high=$((high + 1))
    fi
done
echo "min=$min_severity visible=$visible high=$high"
  1. min_severity ← 2

    3min_severity=24severities="1 3 2 3"
    values this step2min_severity
  2. severities ← 1 3 2 3

    3min_severity=24severities="1 3 2 3"5visible=0
    values this step1 3 2 3severities
  3. visible ← 0

    4severities="1 3 2 3"5visible=06high=0
    values this step0visible
  4. high ← 0

    5visible=06high=07for severity in $severities; do
    values this step0high
  5. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step1severity2min_severity
  6. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step1severity
  7. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity2min_severity
  8. visible ← 1

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step0 1visible
  9. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  10. high ← 1

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step0 1high
  11. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step2severity2min_severity
  12. visible ← 2

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step1 2visible
  13. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step2severity
  14. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity2min_severity
  15. visible ← 3

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step2 3visible
  16. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  17. high ← 2

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step1 2high
  18. echo "min=$min_severity visible=$visible high=$high"

    14done15echo "min=$min_severity visible=$visible high=$high"
    outputmin=2 visible=3 high=2
    values this step2min_severity3visible2high
  1. min_severity ← 1

    3min_severity=14severities="1 3 2 3"
    values this step1min_severity
  2. severities ← 1 3 2 3

    3min_severity=14severities="1 3 2 3"5visible=0
    values this step1 3 2 3severities
  3. visible ← 0

    4severities="1 3 2 3"5visible=06high=0
    values this step0visible
  4. high ← 0

    5visible=06high=07for severity in $severities; do
    values this step0high
  5. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step1severity1min_severity
  6. visible ← 1

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step0 1visible
  7. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step1severity
  8. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity1min_severity
  9. visible ← 2

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step1 2visible
  10. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  11. high ← 1

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step0 1high
  12. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step2severity1min_severity
  13. visible ← 3

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step2 3visible
  14. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step2severity
  15. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity1min_severity
  16. visible ← 4

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step3 4visible
  17. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  18. high ← 2

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step1 2high
  19. echo "min=$min_severity visible=$visible high=$high"

    14done15echo "min=$min_severity visible=$visible high=$high"
    outputmin=1 visible=4 high=2
    values this step1min_severity4visible2high
  1. min_severity ← 3

    3min_severity=34severities="1 3 2 3"
    values this step3min_severity
  2. severities ← 1 3 2 3

    3min_severity=34severities="1 3 2 3"5visible=0
    values this step1 3 2 3severities
  3. visible ← 0

    4severities="1 3 2 3"5visible=06high=0
    values this step0visible
  4. high ← 0

    5visible=06high=07for severity in $severities; do
    values this step0high
  5. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step1severity3min_severity
  6. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step1severity
  7. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity3min_severity
  8. visible ← 1

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step0 1visible
  9. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  10. high ← 1

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step0 1high
  11. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step2severity3min_severity
  12. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step2severity
  13. if (( severity >= min_severity )); then

    7for severity in $severities; do8    if (( severity >= min_severity )); then9        visible=$((visible + 1))
    values this step3severity3min_severity
  14. visible ← 2

    8if (( severity >= min_severity )); then9    visible=$((visible + 1))10fi
    values this step1 2visible
  15. if (( severity == 3 )); then

    10fi11if (( severity == 3 )); then12    high=$((high + 1))
    values this step3severity
  16. high ← 2

    11if (( severity == 3 )); then12    high=$((high + 1))13fi
    values this step1 2high
  17. echo "min=$min_severity visible=$visible high=$high"

    14done15echo "min=$min_severity visible=$visible high=$high"
    outputmin=3 visible=2 high=2
    values this step3min_severity2visible2high
severity threshold `min_severity` controls which incident values count as visible.
loop counters The script uses scalar counters so every update is replayable.
high count Severity 3 incidents stay visible in a separate total.