From cf3e3df9e87532f199efe8a7db44b14b206c6f96 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 4 Sep 2022 09:40:13 +0200 Subject: [PATCH] Don't div by zero if there are too few reliable ping peers --- sqm_lagthrottle_suggest_config.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sqm_lagthrottle_suggest_config.sh b/sqm_lagthrottle_suggest_config.sh index 8628c7f..448d266 100755 --- a/sqm_lagthrottle_suggest_config.sh +++ b/sqm_lagthrottle_suggest_config.sh @@ -205,6 +205,10 @@ END { printf("%5.2f stdev over %3d avg %-5.1f min %-5.1f max %-5.1f %s\n", stdev, peers_records[p], alat, peers_min[p], peers_max[p], p) | cmd_stats } } + if (peercnt == 0) { + printf("FATAL: Not enough reliable ping peers.\n") + exit + } printf("FUDGE_MS=\"%.1f\"\n", 1 + (stdevs/peercnt) ^ 1.7) for (p in peers_pinglist) { @@ -212,6 +216,8 @@ END { } }' "${fpo}" > "${cfgo}" +awk '/^FATAL:/{print; s=1} BEGIN{s=0} END{exit(s)}' "${cfgo}" 1>&2 + awk ' { if(NR<5) { -- 2.39.5