settings-system : Avoid division by zero in DNS metrics

Don't attempt to calculate a percentage if there are no replies yet

Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
Rob Gill
2025-06-26 09:09:56 +10:00
parent 471e53b6cf
commit ce991b2434

View File

@@ -134,7 +134,7 @@ function setMetrics(data, prefix) {
cacheData[val.name] = val.count;
} else if (typeof val === "object") {
setMetrics(val, prefix + key + "-");
} else if (prefix === "sysinfo-dns-replies-") {
} else if (prefix === "sysinfo-dns-replies-" && data.sum !== 0) {
// Compute and display percentage of DNS replies in addition to the absolute value
const lval = val.toLocaleString();
const percent = (100 * val) / data.sum;