From: Johannes Truschnigg Date: Sun, 4 Sep 2022 07:40:13 +0000 (+0200) Subject: Don't div by zero if there are too few reliable ping peers X-Git-Url: https://johannes.truschnigg.info/gitweb/?a=commitdiff_plain;h=cf3e3df9e87532f199efe8a7db44b14b206c6f96;p=sqm_lagthrottle Don't div by zero if there are too few reliable ping peers --- 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) {