aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-map-handlers.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-20 20:09:08 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-20 20:09:08 +0200
commit29a2798de5c9e61e29ebc8bad6862c2f93217958 (patch)
treeee63aa143fee3c8ebc7c95696e5260e68b0f2561 /web/js/nms-map-handlers.js
parent86bf244293bdb72b4bf27d3204d6984ab0c60a12 (diff)
Add a combined health map
Only combines SNMP and ping for now, but the "API" it establishes should do what we need. References #15 Before I consider this done we need to add the infomration in the info-box, and also remove the manual information present there.
Diffstat (limited to 'web/js/nms-map-handlers.js')
-rw-r--r--web/js/nms-map-handlers.js77
1 files changed, 76 insertions, 1 deletions
diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js
index f4aba57..23c33e1 100644
--- a/web/js/nms-map-handlers.js
+++ b/web/js/nms-map-handlers.js
@@ -33,6 +33,7 @@ var handler_temp = {
var handler_ping = {
init:pingInit,
+ getInfo:pingInfo,
tag:"ping",
name:"IPv4 Ping"
};
@@ -63,6 +64,7 @@ var handler_disco = {
var handler_snmp = {
init:snmpInit,
+ getInfo:snmpInfo,
tag:"snmp",
name:"SNMP state"
};
@@ -73,6 +75,12 @@ var handler_cpu = {
name:"CPU utilization"
};
+var handler_combo = {
+ init:comboInit,
+ tag:"combo",
+ name:"Aggregated health"
+};
+
var handlers = [
handler_uplinks,
handler_temp,
@@ -82,7 +90,8 @@ var handlers = [
handler_traffic_tot,
handler_dhcp,
handler_snmp,
- handler_cpu
+ handler_cpu,
+ handler_combo
];
/*
@@ -286,6 +295,23 @@ function pingUpdater()
}
}
+function pingInfo(sw)
+{
+ var ret = { description: "Latency(ms)", switch: sw, why: "Latency" };
+ try {
+ ret.value = nmsData.ping.switches[sw].latency;
+ ret.score = ret.value + 10;
+ if (nmsData.ping.switches[sw].age > 0) {
+ ret.why = "Old ping";
+ ret.score = 900;
+ }
+ } catch(e) {
+ ret.why = "No ping replies";
+ ret.score = 1000;
+ }
+ return ret;
+}
+
function pingInit()
{
drawGradient([green,lightgreen,orange,red]);
@@ -391,6 +417,21 @@ function snmpUpdater() {
}
}
}
+function snmpInfo(sw) {
+ var ret = { description: "SNMP data", switch: sw, why: "No data" };
+ if (nmsData.snmp.snmp[sw] == undefined || nmsData.snmp.snmp[sw].misc == undefined) {
+ ret.score = 800;
+ ret.why = "No data";
+ } else if (nmsData.snmp.snmp[sw].misc.sysName[0] != sw) {
+ ret.score = 300;
+ ret.why = "SNMP sysName doesn't match Gondul sysname";
+ } else {
+ ret.score = 0;
+ nmsMap.setSwitchColor(sw, green);
+ }
+ return ret;
+}
+
function snmpInit() {
nmsData.addHandler("snmp", "mapHandler", snmpUpdater);
@@ -427,3 +468,37 @@ function cpuInit() {
setLegend(4,getColorStop(1000),"100 %");
setLegend(5,"white","N/A");
}
+
+function comboInfo(sw) {
+ var worst = { score: -1 };
+ for (var h in handlers) {
+ try {
+ if (handlers[h].tag== "combo")
+ continue;
+ var ret = handlers[h].getInfo(sw);
+ if (ret.score > worst.score) {
+ worst = ret;
+ }
+ } catch(e) {}
+ }
+ return worst;
+}
+
+function comboUpdater() {
+ if (nmsData.switches == undefined || nmsData.switches.switches == undefined)
+ return;
+ for (var sw in nmsData.switches.switches) {
+ var worst = comboInfo(sw);
+ nmsMap.setSwitchColor(sw, getColorStop(worst.score));
+ }
+}
+
+function comboInit() {
+ nmsData.addHandler("ping", "mapHandler", comboUpdater);
+ drawGradient([green,orange,red]);
+ setLegend(1,getColorStop(0),"All good");
+ setLegend(2,getColorStop(250),"Ok-ish");
+ setLegend(3,getColorStop(600),"Ick-ish");
+ setLegend(4,getColorStop(800),"Nasty");
+ setLegend(5,getColorStop(1000),"WTF?");
+}