From 9f2d2bc0faba3eef6ddfd7cfaf87dc28988acecf Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Mon, 21 Mar 2016 12:21:16 +0100 Subject: NMS: Adjust temperature handler to new schema --- web/nms.gathering.org/js/nms-map-handlers.js | 49 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index fa33bad..b1d31f0 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -204,45 +204,52 @@ function colorFromSpeed(speed,factor) } -/* - * Tweaked this to scale from roughly 20C to 35C. Hence the -20 and /15 - * thing (e.g., "0" is 20 and "15" is 35 by the time we pass it to - * rgb_from_max()); - */ function temp_color(t) { if (t == undefined) { console.log("Temp_color, but temp is undefined"); return blue; } - t = parseInt(t) - 12; - t = Math.floor((t / 23) * 1000); + t = parseInt(t); + t = Math.floor(t * 10); return getColorStop(t); } function tempUpdater() { - for (sw in nms.switches_now["switches"]) { + if(!nmsData.switches) + return; + + for (sw in nmsData.switches["switches"]) { var t = "white"; var temp = ""; - if (nms.switches_now["switches"][sw]["temp"]) { - t = temp_color(nms.switches_now["switches"][sw]["temp"]); - temp = nms.switches_now["switches"][sw]["temp"] + "°C"; - } - - setSwitchColor(sw, t); - switchInfoText(sw, temp); + + if(!nmsData.snmp || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) + continue; + + tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; + Object.keys(tempObj).forEach(function (key) { + if(key == "") { + temp = tempObj[key] + "°C"; + t = temp_color(temp); + } + }); + + nmsMap.setSwitchColor(sw, t); + nmsMap.setSwitchInfo(sw, temp); } } function tempInit() -{ - drawGradient(["black",blue,lightblue,lightgreen,green,orange,red]); - setLegend(1,temp_color(15),"15 °C"); - setLegend(2,temp_color(20),"20 °C"); +{ + //Padded the gradient with extra colors for the upper unused values + drawGradient([blue,lightgreen,green,orange,red,red,red,red,red,red]); + setLegend(1,temp_color(0),"0 °C"); + setLegend(2,temp_color(15),"15 °C"); setLegend(3,temp_color(25),"25 °C"); - setLegend(4,temp_color(30),"30 °C"); - setLegend(5,temp_color(35),"35 °C"); + setLegend(4,temp_color(35),"35 °C"); + setLegend(5,temp_color(45),"45 °C"); + nmsData.addHandler("switchstate","mapHandler",tempUpdater); } function pingUpdater() -- cgit v1.2.3 From 90632b710fa8798c0eeda1bb10ff25b328634e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Kir=C3=B8?= Date: Mon, 21 Mar 2016 16:25:14 +0100 Subject: js linting / code fixup. --- web/nms.gathering.org/js/nms-map-handlers.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index b1d31f0..b98a944 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -84,7 +84,7 @@ function uplinkUpdater() return; if (!nmsData.switchstate.switches) return; - for (sw in nmsData.switches.switches) { + for (var sw in nmsData.switches.switches) { var uplinks=0; if (nmsData.switchstate.switches[sw] == undefined || nmsData.switchstate.switches[sw].uplinks == undefined) { uplinks=0; @@ -139,9 +139,9 @@ function trafficUpdater() { if (!nms.switches_now["switches"]) return; - for (sw in nms.switches_now["switches"]) { + for (var sw in nms.switches_now["switches"]) { var speed = 0; - for (port in nms.switches_now["switches"][sw]["ports"]) { + for (var port in nms.switches_now["switches"][sw]["ports"]) { if (/ge-0\/0\/44$/.exec(port) || /ge-0\/0\/45$/.exec(port) || /ge-0\/0\/46$/.exec(port) || @@ -177,9 +177,9 @@ function trafficTotUpdater() { if (!nms.switches_now["switches"]) return; - for (sw in nms.switches_now["switches"]) { + for (var sw in nms.switches_now["switches"]) { var speed = 0; - for (port in nms.switches_now["switches"][sw]["ports"]) { + for (var port in nms.switches_now["switches"][sw]["ports"]) { if (!nms.switches_then["switches"][sw] || !nms.switches_then["switches"][sw]["ports"] || !nms.switches_then["switches"][sw]["ports"][port]) @@ -220,14 +220,14 @@ function tempUpdater() if(!nmsData.switches) return; - for (sw in nmsData.switches["switches"]) { + for ( var sw in nmsData.switches["switches"]) { var t = "white"; var temp = ""; if(!nmsData.snmp || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) continue; - tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; + var tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; Object.keys(tempObj).forEach(function (key) { if(key == "") { temp = tempObj[key] + "°C"; @@ -259,6 +259,7 @@ function pingUpdater() } for (var sw in nmsData.switches.switches) { try { + var c; if (nmsData.ping.switches[sw].age > 0) { c = red; } else { -- cgit v1.2.3 From ef480bf237b88e667ff525a1dfb881cb8bd7cf0a Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 13:04:23 +0100 Subject: NMS: Ping increase delay, better search --- web/nms.gathering.org/js/nms-map-handlers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index b1d31f0..d3becde 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -223,8 +223,8 @@ function tempUpdater() for (sw in nmsData.switches["switches"]) { var t = "white"; var temp = ""; - - if(!nmsData.snmp || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) + + if(!nmsData.snmp || !nmsData.snmp.snmp || ! nmsData.snmp.snmp[sw] || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) continue; tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; -- cgit v1.2.3 From 89c78bc9eab3b69fe31babe5e64f0343386f67be Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 15:06:50 +0100 Subject: NMS: DHCP map --- web/nms.gathering.org/js/nms-map-handlers.js | 74 ++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 9 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 04aabd2..1ae5d72 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -49,6 +49,12 @@ var handler_traffic_tot = { name:"Switch traffic map" }; +var handler_dhcp = { + init:dhcpInit, + tag:"dhcp", + name:"DHCP map" +}; + var handler_disco = { init:discoInit, tag:"disco", @@ -68,7 +74,8 @@ var handlers = [ handler_traffic, handler_disco, handler_comment, - handler_traffic_tot + handler_traffic_tot, + handler_dhcp ]; /* @@ -95,12 +102,12 @@ function uplinkUpdater() if (uplinks == 0) { nmsMap.setSwitchColor(sw,"white"); - } else if (nuplinks == uplinks) { - nmsMap.setSwitchColor(sw,green); - } else if (nuplinks - uplinks == 1) { - nmsMap.setSwitchColor(sw, orange); - } else if (nuplinks - uplinks == 2) { + } else if (uplinks == 1) { nmsMap. setSwitchColor(sw, red); + } else if (uplinks == 2) { + nmsMap.setSwitchColor(sw, orange); + } else if (uplinks == 3) { + nmsMap.setSwitchColor(sw,green); } else if (uplinks > 3) { nmsMap.setSwitchColor(sw, blue); } @@ -115,9 +122,9 @@ function uplinkInit() nmsData.addHandler("switches","mapHandler",uplinkUpdater); nmsData.addHandler("switchstate","mapHandler",uplinkUpdater); setLegend(1,"white","0 uplinks"); - setLegend(2,red,"2 missing"); - setLegend(3,orange,"1 missing"); - setLegend(4,green,"0 missing"); + setLegend(2,red,"1 uplink"); + setLegend(3,orange,"2 uplinks"); + setLegend(4,green,"3 uplinks"); setLegend(5,blue,"4 uplinks"); } @@ -337,6 +344,55 @@ function commentInit() setLegend(5,green ,"Old/inactive only"); } +function getDhcpColor(stop) +{ + stop = parseInt(stop); + stop = stop * 0.85; + if (stop < 0) + stop = 1000; + if (stop > 1000) + stop = 1000; + return getColorStop(stop); +} + +function dhcpUpdater() +{ + var realnow = Date.now(); + var now = Math.floor(realnow / 1000); + if (nmsData.dhcp == undefined || nmsData.dhcp.dhcp == undefined) { + return + } + if (nmsData.switches == undefined || nmsData.switches.switches == undefined) { + return; + } + try { + for (var sw in nmsData.switches.switches) { + var c = "white"; + if (nmsData.dhcp.dhcp[sw] == undefined) { + nmsMap.setSwitchColor(sw,c); + continue; + } + var s = nmsData.dhcp.dhcp[sw]; + var then = parseInt(s); + c = getDhcpColor(now - then); + nmsMap.setSwitchColor(sw, c); + } + } catch(e) { + console.log(e); + } +} + +function dhcpInit() +{ + drawGradient([green,lightgreen,orange,red]); + nmsData.addHandler("dhcp","mapHandler",dhcpUpdater); + setLegend(1,"white","Undefined"); + setLegend(2,getDhcpColor(1),"1 Second old"); + setLegend(3,getDhcpColor(300),"300 Seconds old"); + setLegend(4,getDhcpColor(900),"900 Seconds old"); + setLegend(5,getDhcpColor(1200),"1200 Seconds old"); +} + /* * Testing-function to randomize colors of linknets and switches */ -- cgit v1.2.3 From 110b939413ebc7a1b4ef1dc5a5988477d9c594bd Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Tue, 22 Mar 2016 16:08:33 +0100 Subject: NMS: Additonal check to switch map handler --- web/nms.gathering.org/js/nms-map-handlers.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 04aabd2..9584841 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -292,6 +292,8 @@ function commentUpdater() if (nmsData.comments == undefined || nmsData.comments.comments == undefined) { return } + if(!nmsData.switches) + return; for (var sw in nmsData.switches.switches) { var c = "white"; if (nmsData.comments.comments[sw] == undefined) { -- cgit v1.2.3 From c70e294a0425a7d417bcf41677a55970e9e59489 Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Tue, 22 Mar 2016 20:34:56 +0100 Subject: NMS: Make sure switch redraw also redraws infotext --- web/nms.gathering.org/js/nms-map-handlers.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 0bec084..dac630a 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -235,15 +235,13 @@ function tempUpdater() continue; var tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; - Object.keys(tempObj).forEach(function (key) { - if(key == "") { - temp = tempObj[key] + "°C"; - t = temp_color(temp); - } - }); + if(tempObj[""]) { + temp = tempObj[""] + "°C"; + t = temp_color(temp); + nmsMap.setSwitchColor(sw, t); + nmsMap.setSwitchInfo(sw, temp); + } - nmsMap.setSwitchColor(sw, t); - nmsMap.setSwitchInfo(sw, temp); } } -- cgit v1.2.3 From 7b5eee1f23bb66a6de8484c4ff5ad5b2021915ea Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 23 Mar 2016 00:38:49 +0100 Subject: NMS: Remove netsize and add traffic Not perfect, but getting closer --- web/nms.gathering.org/js/nms-map-handlers.js | 60 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 31 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index dac630a..82d0c4a 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -133,6 +133,8 @@ function uplinkInit() */ function trafficInit() { + nmsData.addHandler("switches","mapHandler",trafficUpdater); + nmsData.addHandler("switchstate","mapHandler",trafficUpdater); var m = 1024 * 1024 / 8; drawGradient([lightgreen,green,orange,red]); setLegend(1,colorFromSpeed(0),"0 (N/A)"); @@ -144,33 +146,28 @@ function trafficInit() function trafficUpdater() { - if (!nms.switches_now["switches"]) + if (!nmsData.switchstate.switches || !nmsData.switchstate.then) return; - for (var sw in nms.switches_now["switches"]) { + for (var sw in nmsData.switchstate.switches) { var speed = 0; - for (var port in nms.switches_now["switches"][sw]["ports"]) { - if (/ge-0\/0\/44$/.exec(port) || - /ge-0\/0\/45$/.exec(port) || - /ge-0\/0\/46$/.exec(port) || - /ge-0\/0\/47$/.exec(port)) - { - if (!nms.switches_then["switches"][sw] || - !nms.switches_then["switches"][sw]["ports"] || - !nms.switches_then["switches"][sw]["ports"][port]) - continue; - var t = nms.switches_then["switches"][sw]["ports"][port]; - var n = nms.switches_now["switches"][sw]["ports"][port]; - speed += (parseInt(t["ifhcoutoctets"]) -parseInt(n["ifhcoutoctets"])) / (parseInt(t["time"] - n["time"])); - speed += (parseInt(t["ifhcinoctets"]) -parseInt(n["ifhcinoctets"])) / (parseInt(t["time"] - n["time"])); - } - } + try { + var t = parseInt(nmsData.switchstate.then[sw].uplinks.ifHCOutOctets); + var n = parseInt(nmsData.switchstate.switches[sw].uplinks.ifHCOutOctets); + var tt = parseInt(nmsData.switchstate.then[sw].time); + var nt = parseInt(nmsData.switchstate.switches[sw].time); + } catch (e) { continue;}; + var tdiff = nt - tt; + var diff = n - t; + speed = diff / tdiff; if(!isNaN(speed)) - setSwitchColor(sw,colorFromSpeed(speed)); + nmsMap.setSwitchColor(sw,colorFromSpeed(speed)); } } function trafficTotInit() { + nmsData.addHandler("switches","mapHandler",trafficTotUpdater); + nmsData.addHandler("switchstate","mapHandler",trafficTotUpdater); var m = 1024 * 1024 / 8; drawGradient([lightgreen,green,orange,red]); setLegend(1,colorFromSpeed(0),"0 (N/A)"); @@ -182,20 +179,21 @@ function trafficTotInit() function trafficTotUpdater() { - if (!nms.switches_now["switches"]) + if (!nmsData.switchstate.switches || !nmsData.switchstate.then) return; - for (var sw in nms.switches_now["switches"]) { + for (var sw in nmsData.switchstate.switches) { var speed = 0; - for (var port in nms.switches_now["switches"][sw]["ports"]) { - if (!nms.switches_then["switches"][sw] || - !nms.switches_then["switches"][sw]["ports"] || - !nms.switches_then["switches"][sw]["ports"][port]) - continue; - var t = nms.switches_then["switches"][sw]["ports"][port]; - var n = nms.switches_now["switches"][sw]["ports"][port]; - speed += (parseInt(t["ifhcoutoctets"]) -parseInt(n["ifhcoutoctets"])) / (parseInt(t["time"] - n["time"])); - } - setSwitchColor(sw,colorFromSpeed(speed,5)); + try { + var t = parseInt(nmsData.switchstate.then[sw].totals.ifHCOutOctets); + var n = parseInt(nmsData.switchstate.switches[sw].totals.ifHCOutOctets); + var tt = parseInt(nmsData.switchstate.then[sw].time); + var nt = parseInt(nmsData.switchstate.switches[sw].time); + } catch (e) { continue;}; + var tdiff = nt - tt; + var diff = n - t; + speed = diff / tdiff; + if(!isNaN(speed)) + nmsMap.setSwitchColor(sw,colorFromSpeed(speed)); } } -- cgit v1.2.3 From 750c5c7224c0b6698780a2498ce7c0cffd65af3e Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 23 Mar 2016 05:35:17 +0100 Subject: NMS: SNMP map and remove switchtype and fix switch-add --- web/nms.gathering.org/js/nms-map-handlers.js | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 82d0c4a..6de2943 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -67,6 +67,12 @@ var handler_comment = { name:"Fresh comment spotter" }; +var handler_snmp = { + init:snmpInit, + tag:"snmp", + name:"SNMP state" +}; + var handlers = [ handler_uplinks, handler_temp, @@ -75,7 +81,8 @@ var handlers = [ handler_disco, handler_comment, handler_traffic_tot, - handler_dhcp + handler_dhcp, + handler_snmp ]; /* @@ -424,3 +431,24 @@ function discoInit() setLegend(5,"white","!"); } +function snmpUpdater() { + for (var sw in nmsData.switches.switches) { + if (nmsData.snmp.snmp[sw] == undefined || nmsData.snmp.snmp[sw].misc == undefined) { + nmsMap.setSwitchColor(sw, red); + } else if (nmsData.snmp.snmp[sw].misc.sysName[0] != sw) { + nmsMap.setSwitchColor(sw, orange); + } else { + nmsMap.setSwitchColor(sw, green); + } + } +} +function snmpInit() { + nmsData.addHandler("snmp", "mapHandler", snmpUpdater); + + setLegend(1,green,"OK"); + setLegend(2,orange, "Sysname mismatch"); + setLegend(3,red,"No SNMP data"); + setLegend(4,green, ""); + setLegend(5,green,""); + +} -- cgit v1.2.3 From 214178ac49d57a7396794e1411e395701eec90db Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 23 Mar 2016 17:49:06 +0100 Subject: NMS: Update temp map to use public api --- web/nms.gathering.org/js/nms-map-handlers.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 6de2943..7c13421 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -236,16 +236,14 @@ function tempUpdater() var t = "white"; var temp = ""; - if(!nmsData.snmp || !nmsData.snmp.snmp || ! nmsData.snmp.snmp[sw] || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) + if(!nmsData.switchstate || !nmsData.switchstate.switches || !nmsData.switchstate.switches[sw] || !nmsData.switchstate.switches[sw].temp) continue; - var tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; - if(tempObj[""]) { - temp = tempObj[""] + "°C"; - t = temp_color(temp); - nmsMap.setSwitchColor(sw, t); - nmsMap.setSwitchInfo(sw, temp); - } + var t = nmsData.switchstate.switches[sw].temp; + temp = t + "°C"; + t = temp_color(temp); + nmsMap.setSwitchColor(sw, t); + nmsMap.setSwitchInfo(sw, temp); } } -- cgit v1.2.3 From 85a031af6775a9a24fa51c63b6ed4b38ee52945b Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 01:04:40 +0100 Subject: NMS: Tweak temperature colors --- web/nms.gathering.org/js/nms-map-handlers.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 7c13421..5537332 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -215,15 +215,19 @@ function colorFromSpeed(speed,factor) return getColorStop( 1000 * (speed / (factor * (1000 * m)))); } - +/* + * Tweaked this to scale from roughly 20C to 35C. Hence the -20 and /15 + * thing (e.g., "0" is 20 and "15" is 35 by the time we pass it to + * rgb_from_max()); + */ function temp_color(t) { if (t == undefined) { console.log("Temp_color, but temp is undefined"); return blue; } - t = parseInt(t); - t = Math.floor(t * 10); + t = parseInt(t) - 12; + t = Math.floor((t / 23) * 1000); return getColorStop(t); } @@ -251,12 +255,12 @@ function tempUpdater() function tempInit() { //Padded the gradient with extra colors for the upper unused values - drawGradient([blue,lightgreen,green,orange,red,red,red,red,red,red]); - setLegend(1,temp_color(0),"0 °C"); - setLegend(2,temp_color(15),"15 °C"); + drawGradient(["black",blue,lightblue,lightgreen,green,orange,red]); + setLegend(1,temp_color(15),"15 °C"); + setLegend(2,temp_color(20),"20 °C"); setLegend(3,temp_color(25),"25 °C"); - setLegend(4,temp_color(35),"35 °C"); - setLegend(5,temp_color(45),"45 °C"); + setLegend(4,temp_color(30),"30 °C"); + setLegend(5,temp_color(35),"35 °C"); nmsData.addHandler("switchstate","mapHandler",tempUpdater); } -- cgit v1.2.3 From eec36f7d4259bf0dd049e478c99f1c5e834b13a7 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 16:59:36 +0100 Subject: NMS: Add CPU map --- web/nms.gathering.org/js/nms-map-handlers.js | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 5537332..33e6eb4 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -73,6 +73,12 @@ var handler_snmp = { name:"SNMP state" }; +var handler_cpu = { + init:cpuInit, + tag:"cpu", + name:"CPU utilization" +}; + var handlers = [ handler_uplinks, handler_temp, @@ -82,7 +88,8 @@ var handlers = [ handler_comment, handler_traffic_tot, handler_dhcp, - handler_snmp + handler_snmp, + handler_cpu ]; /* @@ -454,3 +461,29 @@ function snmpInit() { setLegend(5,green,""); } +function cpuUpdater() { + for (var sw in nmsData.switches.switches) { + try { + var cpu = 0; + for (var u in nmsData.snmp.snmp[sw].misc.jnxOperatingCPU) { + var local = nmsData.snmp.snmp[sw].misc['jnxOperatingCPU'][u]; + cpu = Math.max(nmsData.snmp.snmp[sw].misc.jnxOperatingCPU[u],cpu); + } + nmsMap.setSwitchColor(sw, getColorStop(cpu * 10)); + nmsMap.setSwitchInfo(sw, cpu + " % "); + } catch (e) { + nmsMap.setSwitchColor(sw, "white"); + nmsMap.setSwitchInfo(sw, "N/A"); + } + } +} + +function cpuInit() { + nmsData.addHandler("snmp", "mapHandler", cpuUpdater); + drawGradient([green,orange,red]); + setLegend(1,getColorStop(0),"0 %"); + setLegend(2,getColorStop(250),"25 %"); + setLegend(3,getColorStop(600),"60 %"); + setLegend(4,getColorStop(1000),"100 %"); + setLegend(5,"white","N/A"); +} -- cgit v1.2.3 From 5ed1a58290c97371ba4e7de40f3a467c3d0b6ebe Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 17:46:54 +0100 Subject: NMS: Tweak uplink traffic map --- web/nms.gathering.org/js/nms-map-handlers.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 33e6eb4..868d26d 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -152,9 +152,9 @@ function trafficInit() var m = 1024 * 1024 / 8; drawGradient([lightgreen,green,orange,red]); setLegend(1,colorFromSpeed(0),"0 (N/A)"); - setLegend(5,colorFromSpeed(2000 * m) , "2000Mb/s"); - setLegend(4,colorFromSpeed(1500 * m),"1500Mb/s"); - setLegend(3,colorFromSpeed(500 * m),"500Mb/s"); + setLegend(5,colorFromSpeed(1100 * m) , "1100Mb/s"); + setLegend(4,colorFromSpeed(600 * m),"600Mb/s"); + setLegend(3,colorFromSpeed(300 * m),"300Mb/s"); setLegend(2,colorFromSpeed(10 * m),"10Mb/s"); } @@ -173,8 +173,10 @@ function trafficUpdater() var tdiff = nt - tt; var diff = n - t; speed = diff / tdiff; - if(!isNaN(speed)) + if(!isNaN(speed)) { nmsMap.setSwitchColor(sw,colorFromSpeed(speed)); + nmsMap.setSwitchInfo(sw,byteCount(speed*8,0)); + } } } @@ -215,7 +217,7 @@ function colorFromSpeed(speed,factor) { var m = 1024 * 1024 / 8; if (factor == undefined) - factor = 2; + factor = 1.1; if (speed == 0) return blue; speed = speed < 0 ? 0 : speed; -- cgit v1.2.3 From dff176ae0469bc60604ddae2e9f651881c7026de Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 25 Mar 2016 15:49:37 +0100 Subject: NMS: Tweak colors for DHCP map --- web/nms.gathering.org/js/nms-map-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index 868d26d..474e8ef 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -383,7 +383,7 @@ function dhcpUpdater() } try { for (var sw in nmsData.switches.switches) { - var c = "white"; + var c = blue; if (nmsData.dhcp.dhcp[sw] == undefined) { nmsMap.setSwitchColor(sw,c); continue; -- cgit v1.2.3