From 867d787c4ab152719dfe13b1f13ab3e303a4780e Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 25 Apr 2015 19:10:33 +0200 Subject: NMS: Monster-commit after local .git corruption This constitutes ... I don't know.... 20 commits or something like that. Unfortunately my local .git directory got corrupted while the check out was OK (after the VM froze). Instead of trying to recreate the local history, I'm just hurrying the hell up and getting this work OFF my local laptop and VM so I don't lose anything for good. --- web/nms.gathering.org/nms2/js/nms-map-handlers.js | 127 +++++++++++----------- 1 file changed, 66 insertions(+), 61 deletions(-) (limited to 'web/nms.gathering.org/nms2/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/nms2/js/nms-map-handlers.js b/web/nms.gathering.org/nms2/js/nms-map-handlers.js index 762788a..f85b06f 100644 --- a/web/nms.gathering.org/nms2/js/nms-map-handlers.js +++ b/web/nms.gathering.org/nms2/js/nms-map-handlers.js @@ -53,6 +53,7 @@ var handler_comment = { init:commentInit, name:"Fresh comment spotter" }; + /* * Update function for uplink map * Run periodically when uplink map is active. @@ -78,29 +79,42 @@ function uplinkUpdater() } } if (uplinks == 0) { - setSwitchColor(sw,"blue"); + setSwitchColor(sw,"white"); } else if (uplinks == 1) { - setSwitchColor(sw,"red"); + setSwitchColor(sw,red); } else if (uplinks == 2) { - setSwitchColor(sw, "yellow"); + setSwitchColor(sw, orange); } else if (uplinks == 3) { - setSwitchColor(sw, "green"); + setSwitchColor(sw, green); } else if (uplinks > 3) { - setSwitchColor(sw, "white"); + setSwitchColor(sw, blue); } } } +/* + * Init-function for uplink map + */ +function uplinkInit() +{ + setLegend(1,"white","0 uplinks"); + setLegend(2,red,"1 uplink"); + setLegend(3,orange,"2 uplinks"); + setLegend(4,green,"3 uplinks"); + setLegend(5,blue,"4 uplinks"); +} + /* * Init-function for uplink map */ function trafficInit() { - setLegend(1,"blue","0 (N/A)"); - setLegend(5,"red", "1000Mb/s or more"); - setLegend(4,"yellow","100Mb/s to 800Mb/s"); - setLegend(3,"green", "5Mb/s to 100Mb/s"); - setLegend(2,"white","0 to 5Mb/s"); + var m = 1024 * 1024 / 8; + setLegend(1,colorFromSpeed(0),"0 (N/A)"); + setLegend(5,colorFromSpeed(2000 * m) , "2000Mb/s"); + setLegend(4,colorFromSpeed(1200 * m),"1200Mb/s"); + setLegend(3,colorFromSpeed(500 * m),"500Mb/s"); + setLegend(2,colorFromSpeed(10 * m),"10Mb/s"); } function trafficUpdater() @@ -115,37 +129,27 @@ function trafficUpdater() /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"])); } } - var m = 1024 * 1024 / 8; - if (speed == 0) { - setSwitchColor(sw,"blue"); - } else if (speed > (1000 * m)) { - setSwitchColor(sw,"red"); - } else if (speed > (800 * m)) { - setSwitchColor(sw, "yellow"); - } else if (speed > (5 * m)) { - setSwitchColor(sw, "green"); - } else { - setSwitchColor(sw, "white"); - } + setSwitchColor(sw,colorFromSpeed(speed)); } } -/* - * Init-function for uplink map - */ -function uplinkInit() +function colorFromSpeed(speed) { - setLegend(1,"blue","0 uplinks"); - setLegend(2,"red","1 uplink"); - setLegend(3,"yellow","2 uplinks"); - setLegend(4,"green","3 uplinks"); - setLegend(5,"white","4 uplinks"); + var m = 1024 * 1024 / 8; + if (speed == 0) + return blue; + speed = speed < 0 ? 0 : speed; + return rgb_from_max2( 100 * (speed / (2 * (1000 * m)))); } @@ -158,7 +162,7 @@ function temp_color(t) { if (t == undefined) { console.log("Temp_color, but temp is undefined"); - return "blue"; + return blue; } t = parseInt(t) - 20; t = Math.floor((t / 15) * 100); @@ -189,13 +193,13 @@ function tempInit() function pingUpdater() { for (var sw in nms.switches_now["switches"]) { - var c = "blue"; + var c = blue; if (nms.ping_data['switches'] && nms.ping_data['switches'][sw]) c = gradient_from_latency(nms.ping_data["switches"][sw]["latency"]); setSwitchColor(sw, c); } for (var ln in nms.switches_now["linknets"]) { - var c1 = "blue"; + var c1 = blue; var c2 = c1; if (nms.ping_data['linknets'] && nms.ping_data['linknets'][ln]) { c1 = gradient_from_latency(nms.ping_data["linknets"][ln][0]); @@ -210,53 +214,54 @@ function pingInit() setLegend(1,gradient_from_latency(1),"1ms"); setLegend(2,gradient_from_latency(30),"30ms"); setLegend(3,gradient_from_latency(60),"60ms"); - setLegend(4,gradient_from_latency(80),"80ms"); - setLegend(5,"#0000ff" ,"No response"); + setLegend(4,gradient_from_latency(100),"100ms"); + setLegend(5,blue ,"No response"); } function commentUpdater() { var realnow = Date.now(); - if (nms.now) { - realnow = Date.parse(nms.now); - } var now = Math.floor(realnow / 1000); for (var sw in nms.switches_now["switches"]) { - var c = "green"; + var c = "white"; var s = nms.switches_now["switches"][sw]; if (s["comments"] && s["comments"].length > 0) { var then = 0; + var active = 0; + var persist = 0; c = "yellow"; for (var v in s["comments"]) { var then_test = parseInt(s["comments"][v]["time"]); - if (then_test > then && then_test <= now) + if (then_test > then && s["comments"][v]["state"] != "inactive") then = then_test; + if (s["comments"][v]["state"] == "active") { + active++; + } + if (s["comments"][v]["state"] == "persist") + persist++; } if (then > (now - (60*15))) { - c = "red"; - } else if (then > (now - (120*60))) { - c = "orange"; - } else if (then < (now - (60*60*24))) { - c = "white"; + c = red; + } else if (active > 0) { + c = orange; + } else if (persist > 0) { + c = blue; + } else { + c = green; } - /* - * Special case during time travel: We have - * comments, but are not showing them yet. - */ - if (then == 0) - c = "green"; } setSwitchColor(sw, c); } } + function commentInit() { - setLegend(1,"green","0 comments"); - setLegend(2,"white","1d+ old"); - setLegend(3,"red", "0 - 15m old"); - setLegend(4,"orange","15m - 120m old"); - setLegend(5,"yellow" ,"2h - 24h old"); + setLegend(1,"white","0 comments"); + setLegend(2,blue,"Persistent comments"); + setLegend(3,red, "New comments"); + setLegend(4,orange,"Active comments"); + setLegend(5,green ,"Old/inactive only"); } /* * Testing-function to randomize colors of linknets and switches @@ -274,10 +279,10 @@ function randomizeColors() function discoInit() { setNightMode(true); - setLegend(1,"blue","Y"); - setLegend(2,"red", "M"); - setLegend(3,"yellow","C"); - setLegend(4,"green", "A"); + setLegend(1,blue,"Y"); + setLegend(2,red, "M"); + setLegend(3,orange,"C"); + setLegend(4,green, "A"); setLegend(5,"white","!"); } -- cgit v1.2.3 From a4888a9176ed48ddaf2e5b81ddd77c6bd8e70872 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 27 Apr 2015 18:55:22 +0200 Subject: NMS: Add real gradient support for all maps This so beats custom-gradient-functions for latency, custom for temperature and custom for speed... --- web/nms.gathering.org/nms2/js/nms-map-handlers.js | 34 ++++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'web/nms.gathering.org/nms2/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/nms2/js/nms-map-handlers.js b/web/nms.gathering.org/nms2/js/nms-map-handlers.js index f85b06f..5966692 100644 --- a/web/nms.gathering.org/nms2/js/nms-map-handlers.js +++ b/web/nms.gathering.org/nms2/js/nms-map-handlers.js @@ -110,9 +110,10 @@ function uplinkInit() 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(1200 * m),"1200Mb/s"); + setLegend(4,colorFromSpeed(1500 * m),"1500Mb/s"); setLegend(3,colorFromSpeed(500 * m),"500Mb/s"); setLegend(2,colorFromSpeed(10 * m),"10Mb/s"); } @@ -149,7 +150,8 @@ function colorFromSpeed(speed) if (speed == 0) return blue; speed = speed < 0 ? 0 : speed; - return rgb_from_max2( 100 * (speed / (2 * (1000 * m)))); + return getColorStop( 1000 * (speed / (2 * (1000 * m)))); +// return rgb_from_max2( 100 * (speed / (2 * (1000 * m)))); } @@ -164,9 +166,9 @@ function temp_color(t) console.log("Temp_color, but temp is undefined"); return blue; } - t = parseInt(t) - 20; - t = Math.floor((t / 15) * 100); - return rgb_from_max(t); + t = parseInt(t) - 12; + t = Math.floor((t / 23) * 1000); + return getColorStop(t); } function tempUpdater() @@ -183,15 +185,20 @@ function tempUpdater() function tempInit() { - setLegend(1,temp_color(20),"20 °C"); - setLegend(2,temp_color(22),"22 °C"); - setLegend(3,temp_color(27),"27 °C"); - setLegend(4,temp_color(31),"31 °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(30),"30 °C"); setLegend(5,temp_color(35),"35 °C"); } function pingUpdater() { + if (!nms.ping_data || !nms.ping_data["switches"]) { + resetColors(); + return; + } for (var sw in nms.switches_now["switches"]) { var c = blue; if (nms.ping_data['switches'] && nms.ping_data['switches'][sw]) @@ -211,11 +218,12 @@ function pingUpdater() function pingInit() { + drawGradient([green,lightgreen,orange,red]); setLegend(1,gradient_from_latency(1),"1ms"); setLegend(2,gradient_from_latency(30),"30ms"); setLegend(3,gradient_from_latency(60),"60ms"); setLegend(4,gradient_from_latency(100),"100ms"); - setLegend(5,blue ,"No response"); + setLegend(5,gradient_from_latency(undefined) ,"No response"); } function commentUpdater() @@ -258,9 +266,9 @@ function commentUpdater() function commentInit() { setLegend(1,"white","0 comments"); - setLegend(2,blue,"Persistent comments"); - setLegend(3,red, "New comments"); - setLegend(4,orange,"Active comments"); + setLegend(2,blue,"Persistent"); + setLegend(3,red, "New"); + setLegend(4,orange,"Active"); setLegend(5,green ,"Old/inactive only"); } /* -- cgit v1.2.3 From 9502fc0d398de46cea301a921b16f945289fdffd Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 28 Apr 2015 10:30:14 +0200 Subject: NMS: Better refresh/sticky maps --- web/nms.gathering.org/nms2/js/nms-map-handlers.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'web/nms.gathering.org/nms2/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/nms2/js/nms-map-handlers.js b/web/nms.gathering.org/nms2/js/nms-map-handlers.js index 5966692..531b686 100644 --- a/web/nms.gathering.org/nms2/js/nms-map-handlers.js +++ b/web/nms.gathering.org/nms2/js/nms-map-handlers.js @@ -21,39 +21,54 @@ var handler_uplinks = { updater:uplinkUpdater, init:uplinkInit, + tag:"uplink", name:"Uplink map" }; var handler_temp = { updater:tempUpdater, init:tempInit, + tag:"temp", name:"Temperature map" }; var handler_ping = { updater:pingUpdater, init:pingInit, + tag:"ping", name:"IPv4 Ping map" }; var handler_traffic = { updater:trafficUpdater, init:trafficInit, + tag:"traffic", name:"Uplink traffic map" }; var handler_disco = { updater:randomizeColors, init:discoInit, + tag:"disco", name:"Disco fever" }; var handler_comment = { updater:commentUpdater, init:commentInit, + tag:"comment", name:"Fresh comment spotter" }; +var handlers = [ + handler_uplinks, + handler_temp, + handler_ping, + handler_traffic, + handler_disco, + handler_comment + ]; + /* * Update function for uplink map * Run periodically when uplink map is active. -- cgit v1.2.3 From 2c9231ff1b71e608b369df8666b3b1ec2f32bb74 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 29 Apr 2015 12:26:45 +0200 Subject: NMS: Add "total switch speed" map I'm thinking of factoring ifhighspeed for the scaling... --- web/nms.gathering.org/nms2/js/nms-map-handlers.js | 50 +++++++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'web/nms.gathering.org/nms2/js/nms-map-handlers.js') diff --git a/web/nms.gathering.org/nms2/js/nms-map-handlers.js b/web/nms.gathering.org/nms2/js/nms-map-handlers.js index 531b686..9b2d44c 100644 --- a/web/nms.gathering.org/nms2/js/nms-map-handlers.js +++ b/web/nms.gathering.org/nms2/js/nms-map-handlers.js @@ -46,6 +46,13 @@ var handler_traffic = { name:"Uplink traffic map" }; +var handler_traffic_tot = { + updater:trafficTotUpdater, + init:trafficTotInit, + tag:"traffictot", + name:"Switch traffic map" +}; + var handler_disco = { updater:randomizeColors, init:discoInit, @@ -66,7 +73,8 @@ var handlers = [ handler_ping, handler_traffic, handler_disco, - handler_comment + handler_comment, + handler_traffic_tot ]; /* @@ -159,14 +167,48 @@ function trafficUpdater() } } -function colorFromSpeed(speed) +/* + * Init-function for uplink map + */ +function trafficTotInit() +{ + var m = 1024 * 1024 / 8; + drawGradient([lightgreen,green,orange,red]); + setLegend(1,colorFromSpeed(0),"0 (N/A)"); + setLegend(5,colorFromSpeed(5000 * m,5) , "5000Mb/s"); + setLegend(4,colorFromSpeed(3000 * m,5),"3000Mb/s"); + setLegend(3,colorFromSpeed(1000 * m,5),"1000Mb/s"); + setLegend(2,colorFromSpeed(100 * m,5),"100Mb/s"); +} + +function trafficTotUpdater() +{ + if (!nms.switches_now["switches"]) + return; + for (sw in nms.switches_now["switches"]) { + var speed = 0; + for (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)); + } +} + +function colorFromSpeed(speed,factor) { var m = 1024 * 1024 / 8; + if (factor == undefined) + factor = 2; if (speed == 0) return blue; speed = speed < 0 ? 0 : speed; - return getColorStop( 1000 * (speed / (2 * (1000 * m)))); -// return rgb_from_max2( 100 * (speed / (2 * (1000 * m)))); + return getColorStop( 1000 * (speed / (factor * (1000 * m)))); } -- cgit v1.2.3