aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/js/nms-map-handlers.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly@.no>2016-03-24 21:15:50 +0100
committerKristian Lyngstol <kly@kly@.no>2016-03-24 21:15:50 +0100
commit7ac4551ed94c1f1393bc69e595a90dbe15bc8f6c (patch)
treed68fbc18f69cc33aaabec82b1092ba147a32b346 /web/nms-public.gathering.org/js/nms-map-handlers.js
parentf0a12faa1dceb7c21e1688164342aa58e8f136f2 (diff)
NMS: Update public api
Diffstat (limited to 'web/nms-public.gathering.org/js/nms-map-handlers.js')
-rw-r--r--web/nms-public.gathering.org/js/nms-map-handlers.js47
1 files changed, 41 insertions, 6 deletions
diff --git a/web/nms-public.gathering.org/js/nms-map-handlers.js b/web/nms-public.gathering.org/js/nms-map-handlers.js
index 5537332..868d26d 100644
--- a/web/nms-public.gathering.org/js/nms-map-handlers.js
+++ b/web/nms-public.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
];
/*
@@ -145,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");
}
@@ -166,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));
+ }
}
}
@@ -208,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;
@@ -454,3 +463,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");
+}