scripts: Validate monitor intervals

Reject zero and nonnumeric sampling intervals before entering the
monitor loops, avoiding division errors and repeated failed sleep
calls.
This commit is contained in:
Gleb Chesnokov
2026-08-21 19:58:59 +03:00
parent 7057358960
commit 0aa6689c3a
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -2,6 +2,12 @@
interval="${1:-5}"
if ! [[ "$interval" =~ ^0*[1-9][0-9]*$ ]]; then
echo "Error: interval must be a positive integer." >&2
exit 1
fi
interval="${interval#"${interval%%[!0]*}"}"
echo "Interrupts per second:"
while true
do