aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-map-handlers.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-27 19:51:59 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-27 19:51:59 +0200
commit3dcb90eaf58ce9c32532ae5524abf70100d34daa (patch)
tree7aaaa4b48b10840a2d7c841dc0efc161e24d6cff /web/js/nms-map-handlers.js
parente3f48c3241c9a9f06b908b14f45af0c5c6e29f7d (diff)
front: Tweak/fix ping scores
Specially bad was the foo == bar == undef thing which broke completely. Also, this makes sure that we don't cap out at 200 if the ping reply is 1000ms...
Diffstat (limited to 'web/js/nms-map-handlers.js')
-rw-r--r--web/js/nms-map-handlers.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js
index daafff3..21f2bb2 100644
--- a/web/js/nms-map-handlers.js
+++ b/web/js/nms-map-handlers.js
@@ -332,12 +332,16 @@ function pingInfo(sw)
try {
var v4 = nmsData.ping.switches[sw].latency4;
var v6 = nmsData.ping.switches[sw].latency6;
+ if (v4 == undefined)
+ v4 = undefined;
+ if (v6 == undefined)
+ v6 = undefined;
ret.data[0].value = v4;
ret.data[0].description = "IPv4 latency(ms)";
ret.data[1] = {};
ret.data[1].value = v6;
ret.data[1].description = "IPv6 latency(ms)";
- if (v4 == v6 == undefined) {
+ if (v4 == undefined && v6 == undefined) {
ret.score = 1000;
ret.why = "No IPv4 or IPv6 ping reply";
} else if(v6 == undefined) {
@@ -346,10 +350,13 @@ function pingInfo(sw)
} else if (v4 == undefined) {
ret.score = 199;
ret.why = "No IPv4 ping reply";
- } else {
- v4 = parseInt(v4);
- v6 = parseInt(v6);
- ret.score = (v4 > v6 ? v4 : v6) * 10;
+ }
+
+ v4 = parseFloat(v4) * 10;
+ v6 = parseFloat(v6) * 10;
+ if (v4 > ret.score || v6 > ret.score) {
+ ret.why = "Latency";
+ ret.score = parseInt(v4 > v6 ? v4 : v6);
}
if (nmsData.ping.switches[sw].age4 > 5 || nmsData.ping.switches[sw].age6 > 5) {
ret.why = "Old ping";