aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-info-box.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-21 13:31:11 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-21 13:31:11 +0200
commit0900959bea04ba2c489b4ed521701429d9785193 (patch)
tree465389c3871b495f909b0d98c16bc87df007615a /web/js/nms-info-box.js
parentcdc3d60d5e7baa09afba42bb19ae7ed9723d03ff (diff)
Expose handler-data/combo data in infobox
Fixes #15 Still lots of things that _should_ be done, but this is the groundwork needed for a combined map. Theoretically, all map handlers should just expose getInfo somehow now.
Diffstat (limited to 'web/js/nms-info-box.js')
-rw-r--r--web/js/nms-info-box.js70
1 files changed, 5 insertions, 65 deletions
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index e6817dc..46762c2 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -878,53 +878,12 @@ var switchSummaryPanel = function() {
};
this.refresh = function(reason) {
var content = [];
-
- //Get DHCP info
- var lastDhcp = undefined;
- try {
- var tempDhcp = nmsData.dhcp.dhcp[this.sw];
- var now = Date.now();
- now = Math.floor(now / 1000);
- tempDhcp = now - parseInt(tempDhcp);
- tempDhcp = tempDhcp + " s";
- } catch(e) {}
-
- //Get SNMP status
- var snmpStatus = undefined;
- try {
- if (nmsData.snmp.snmp[this.sw].misc.sysName[0] != sw) {
- snmpStatus = "Sysname mismatch";
- } else {
- snmpStatus = "OK";
- }
- } catch(e) {}
-
- //Get CPU usage
- var cpuUsage = undefined;
- try {
- var cpu = 0;
- for (var u in nmsData.snmp.snmp[this.sw].misc.jnxOperatingCPU) {
- var local = nmsData.snmp.snmp[this.sw].misc['jnxOperatingCPU'][u];
- cpu = Math.max(nmsData.snmp.snmp[this.sw].misc.jnxOperatingCPU[u],cpu);
- }
- cpuUsage = cpu + " %";
- } catch (e) {}
-
- //Get traffic data
- var uplinkTraffic = undefined;
- try {
- var speed = 0;
- var t = parseInt(nmsData.switchstate.then[this.sw].uplinks.ifHCOutOctets);
- var n = parseInt(nmsData.switchstate.switches[this.sw].uplinks.ifHCOutOctets);
- var tt = parseInt(nmsData.switchstate.then[this.sw].time);
- var nt = parseInt(nmsData.switchstate.switches[this.sw].time);
- var tdiff = nt - tt;
- var diff = n - t;
- speed = diff / tdiff;
- if(!isNaN(speed)) {
- uplinkTraffic = byteCount(speed*8,0);
+ for ( var h in handlers ) {
+ if (handlers[h].getInfo != undefined) {
+ var tmp = handlers[h].getInfo(this.sw);
+ content.push([tmp.description,tmp.value]);
}
- } catch (e) {};
+ }
//Get uptime data
var uptime = "";
@@ -933,12 +892,6 @@ var switchSummaryPanel = function() {
uptime = Math.floor(uptime) + " t";
} catch(e) {}
- //Get temperature data
- var temp = "";
- try {
- temp = nmsData.switchstate.switches[this.sw].temp + " °C";
- } catch(e) {}
-
//Get management data
var mgmtV4 = "";
var mgmtV6 = "";
@@ -951,20 +904,7 @@ var switchSummaryPanel = function() {
subnetV6 = nmsData.smanagement.switches[this.sw].subnet6;
} catch(e) {}
- //Get ping data
- var ping = undefined;
- try {
- nmsData.ping.switches[this.sw].latency + " ms";
- } catch (e) {}
-
-
- content.push(["Ping latency:",ping]);
- content.push(["Last DHCP lease:",lastDhcp]);
- content.push(["SNMP status:",snmpStatus]);
- content.push(["CPU usage:",cpuUsage]);
- content.push(["Uplink traffic:",uplinkTraffic]);
content.push(["System uptime:",uptime]);
- content.push(["Temperature",temp]);
content.push(["Management (v4):",mgmtV4]);
content.push(["Management (v6):",mgmtV6]);
content.push(["Subnet (v4):",subnetV4]);