aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/js/nms-map-handlers.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly@.no>2016-03-24 16:59:36 +0100
committerKristian Lyngstol <kly@kly@.no>2016-03-24 16:59:36 +0100
commiteec36f7d4259bf0dd049e478c99f1c5e834b13a7 (patch)
tree61ac97e537424004d0e532de34756ef68e4a3e73 /web/nms.gathering.org/js/nms-map-handlers.js
parent04bd92868c0a4c91936283bd126eacf71bee1999 (diff)
NMS: Add CPU map
Diffstat (limited to 'web/nms.gathering.org/js/nms-map-handlers.js')
-rw-r--r--web/nms.gathering.org/js/nms-map-handlers.js35
1 files changed, 34 insertions, 1 deletions
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");
+}