From bb862773d69bc5997bd1628a3f0505827e7cfe5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Lyngst=C3=B8l?= Date: Mon, 10 Apr 2017 14:06:23 +0200 Subject: TG17 stuff ? --- web/js/nms-map-handlers.js | 60 +++++++++++++++++++++++++++++++++------------- web/js/nms.js | 10 ++++---- 2 files changed, 48 insertions(+), 22 deletions(-) (limited to 'web/js') diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index 42785ff..2214e2d 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -136,31 +136,53 @@ function uplinkInfo(sw) ret.score = 0; var u = 0; var t = 0; + var known_t = 0; if (testTree(nmsData,['switchstate','switches',sw,'uplinks','live'])) { u = parseInt(nmsData.switchstate.switches[sw].uplinks.live); t = parseInt(nmsData.switchstate.switches[sw].uplinks.total); + known_t = t; ret.data[0].value = u + " / " + t; ret.data[0].description = "Uplinks (live/configured)"; if (nmsData.switches.switches[sw].subnet4 == undefined || nmsData.switches.switches[sw].subnet4 == null) { - if (u == t) { - ret.score = 0 - ret.why = "All uplinks up"; - } else if (u == 1) { - ret.score = 800; - ret.why = "Only 1 of " + t + " uplinks alive"; - } else { - ret.score = 650; - ret.why = u + " of " + t + " uplinks alive"; - } + if (tagged(sw,'3up')) { + known_t = 3; + } else if (tagged(sw,'2up')) { + known_t = 2; + } else if (tagged(sw, '1up')) { + known_t = 1; + } else if (tagged(sw,'4up')) { + known_t = 4; + } + if (known_t != t) { + ret.data[0].value += "(Overridden: " + known_t + ")"; + } + + if (u == known_t) { + ret.score = 0 + ret.why = "All uplinks up"; + } else if (u == 1) { + ret.score = 800; + ret.why = "Only 1 of " + known_t + " uplinks alive"; + } else { + ret.score = 650; + ret.why = u + " of " + known_t + " uplinks alive"; + } } } + if (testTree(nmsData,['switchstate','switches',sw,'clients','live'])) { + var tu = parseInt(nmsData.switchstate.switches[sw].clients.live); + var tt = parseInt(nmsData.switchstate.switches[sw].clients.total); + ret.data[1] = {}; + ret.data[1].value = (tu) + " / " + (tt); + ret.data[1].description = "Client ports (live/total)"; + } if (testTree(nmsData,['switchstate','switches',sw,'totals','live'])) { var tu = parseInt(nmsData.switchstate.switches[sw].totals.live); var tt = parseInt(nmsData.switchstate.switches[sw].totals.total); - ret.data[1] = {}; - ret.data[1].value = (tu-u) + " / " + (tt-t); - ret.data[1].description = "Non-uplink ports (live/total)"; + ret.data[2] = {}; + ret.data[2].value = (tu-u) + " / " + (tt-t); + ret.data[2].description = "Non-uplink ports (live/total)"; } return ret; } @@ -422,7 +444,7 @@ function pingInfo(sw) ret.why = "Latency"; ret.score = parseInt(v4 > v6 ? v4 : v6); } - if (nmsData.ping.switches[sw].age4 > 5 || nmsData.ping.switches[sw].age6 > 5) { + if (nmsData.ping.switches[sw].age4 > 10 || nmsData.ping.switches[sw].age6 > 10) { ret.why = "Old ping"; ret.score = 900; } @@ -483,9 +505,14 @@ function dhcpInfo(sw) { var now = nmsData.dhcp.time; var then = nmsData.dhcp.dhcp[sw]; var diff = now - then; + var divider = 4; + if(tagged(sw,'slowdhcp')) { + divider = 10; + } + ret.data[0].value = diff; ret.why = "DHCP freshness"; - ret.score = diff/4> 500 ? 500 : parseInt(diff/4); + ret.score = diff/divider> 500 ? 500 : parseInt(diff/divider); } else { ret.data[0].value = "No DHCP data"; if (testTree(nmsData,['smanagement','switches',sw])) { @@ -509,9 +536,10 @@ function dhcpInfo(sw) { ret.data[1].description = "DHCP clients"; } if (testTree(nmsData,['switches','switches',sw, 'tags'])) { - if (nmsData.switches.switches[sw].tags.includes('ignoredhcp')) { + if (tagged(sw,'ignoredhcp')) { ret.score = 0; ret.why += "(Ignored)"; + ret.data[0].value += "(Ignored)"; } } return ret; diff --git a/web/js/nms.js b/web/js/nms.js index 362aebc..8f98c75 100644 --- a/web/js/nms.js +++ b/web/js/nms.js @@ -395,8 +395,8 @@ function initNMS() { nmsData.registerSource("snmp","/api/read/snmp"); nmsData.registerSource("smanagement","/api/read/switches-management"); nmsData.registerSource("oplog", "/api/read/oplog"); - setInterval(nmsUpdateNavbarGraph, 10000); - nmsUpdateNavbarGraph(); + // setInterval(nmsUpdateNavbarGraph, 30000); + // nmsUpdateNavbarGraph(); nmsOplog.init(); } @@ -624,11 +624,9 @@ function restoreSettings() */ function nmsUpdateNavbarGraph() { var img = document.getElementById("navbar-graph"); - var w = Math.floor(window.innerWidth / 4); - if (window.innerWidth > 2300) - w += 400; + var w = 200; - img.src = "/render/?target=movingAverage(averageSeries(ping.*.ipv4),%225min%22)&target=secondYAxis(averageSeries(perSecond(snmp.*.ports.*.{ifHCInOctets,ifHCOutOctets})))&bgcolor=%23ffffff00&width=" + w + "&height=20&format=svg&from=-60min&until=now&graphOnly=true&somerandomthing=" + Math.floor(new Date().getTime() / 10000); + img.src = "/render/?target=movingAverage(averageSeries(ping.*.*.ipv4),%225min%22)&target=secondYAxis(averageSeries(perSecond(snmp.*.*.ports.*.{ifHCInOctets,ifHCOutOctets})))&bgcolor=%23ffffff00&width=" + w + "&height=20&format=svg&from=-30min&until=now&graphOnly=true"; } /* * Test if the entire path specified in the arrary "ar" exists under the -- cgit v1.2.3 From 0b99608227d53c9eebb01fd7f98d1618cbb7a2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Lyngst=C3=B8l?= Date: Sun, 16 Apr 2017 01:47:57 +0200 Subject: TG17 monster commit --- web/js/nms-info-box.js | 17 ++++++- web/js/nms-map-handlers.js | 114 ++++++++++++++++++++++++++++++++++++++++----- web/js/nms-map.js | 2 +- web/js/nms-oplog.js | 5 +- web/js/nms-search.js | 16 +++++++ 5 files changed, 139 insertions(+), 15 deletions(-) (limited to 'web/js') diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js index 2cc6fc4..b902a69 100644 --- a/web/js/nms-info-box.js +++ b/web/js/nms-info-box.js @@ -832,10 +832,23 @@ var inventoryListingPanel = function() { value = nmsData.snmp.snmp[sw]["misc"]["sysDescr"][0]; break; case 'jnxBoxSerialNo': + if(testTree(nmsData,["snmp","snmp",sw,"misc","entPhysicalSerialNum"])) { + for (var x in nmsData.snmp.snmp[sw]["misc"]["entPhysicalSerialNum"]) { + value = "misc" + x + ":" + nmsData.snmp.snmp[sw]["misc"]["entPhysicalSerialNum"][x]; + resultArray.push([sw, value]); + } + } + if (testTree(nmsData,["snmp","snmp",sw,"misc","jnxVirtualChassisMemberSerialnumber"])) { + for (var x in nmsData.snmp.snmp[sw]["misc"]["jnxVirtualChassisMemberSerialnumber"]) { + value = "member " + x + ":" + nmsData.snmp.snmp[sw]["misc"]["jnxVirtualChassisMemberSerialnumber"][x]; + resultArray.push([sw, value]); + } + } value = nmsData.snmp.snmp[sw]["misc"]["jnxBoxSerialNo"][0]; break; } - } catch (e) {} + } catch (e) {console.log("sw: " + sw); console.log(e);} + resultArray.push([sw, value]); } @@ -1012,7 +1025,7 @@ var switchCommentsPanel = function () { var tmp = (date.getYear() + 1900) + "-" + (month < 10 ? "0": "") + month + "-" + (day < 10 ? "0" : "") + day + " " + date.toTimeString().replace(/:\d\d .*$/,""); td1.textContent = tmp; td1.classList.add("left"); - td2.textContent = "[" + logs[v]['username'] + "] " + logs[v]['log']; + td2.textContent = logs[v]['systems'] + "[" + logs[v]['username'] + "] " + logs[v]['log']; } domObj.appendChild(table); this._render(domObj); diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index 2214e2d..03f5c9e 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -68,6 +68,7 @@ var handler_snmp = { var handler_cpu = { init:cpuInit, + getInfo:cpuInfo, tag:"cpu", name:"CPU utilization" }; @@ -84,6 +85,11 @@ var handler_mgmt = { tag:"mgmt", name:"Management info" }; +var handler_snmpup = { + getInfo:snmpUpInfo, + tag:"snmpup", + name:"SNMP Uplink state" +}; var handlerInfo = function(tag,desc) { /* @@ -126,7 +132,8 @@ var handlers = [ handler_traffic_tot, handler_dhcp, handler_snmp, - handler_cpu + handler_cpu, + handler_snmpup ]; function uplinkInfo(sw) @@ -159,13 +166,16 @@ function uplinkInfo(sw) } if (u == known_t) { - ret.score = 0 - ret.why = "All uplinks up"; + ret.score = 0; + ret.why = "All uplinks up"; } else if (u == 1) { ret.score = 800; ret.why = "Only 1 of " + known_t + " uplinks alive"; - } else { - ret.score = 650; + } else if (u < known_t) { + ret.score = 450; + ret.why = u + " of " + known_t + " uplinks alive"; + } else if (u > known_t) { + ret.score = 350; ret.why = u + " of " + known_t + " uplinks alive"; } } @@ -453,6 +463,31 @@ function pingInfo(sw) ret.why = "No ping replies"; ret.score = 999; } + + if (testTree(nmsData,['smanagement','switches',sw])) { + try { + var distro = nmsData['smanagement']['switches'][sw]['distro_name']; + var phy = nmsData['smanagement']['switches'][sw]['distro_phy_port']; + if (!(distro == "" || phy == "" || distro == undefined || phy == undefined)) { + if (testTree(nmsData,['snmp','snmp',distro, 'ports',phy,'ifOperStatus'])) { + var x = nmsData['snmp']['snmp'][distro]['ports'][phy]['ifOperStatus']; + var ping = parseFloat(nmsData["ping"]["switches"][sw]["latency4"]); + var ping6 = parseFloat(nmsData["ping"]["switches"][sw]["latency6"]); + if (x == "up") { + ret.data[3] = {}; + ret.data[3].description = "Distro-port"; + ret.data[3].value = "Distro port is live"; + if (isNaN(ping) && isNaN(ping6)) { + ret.score = 850; + ret.why = "Distro port is alive, but no IPv4/IPv6 ping. ROLLBACK!"; + } + } + } + } + } catch(e) { + console.log("lol"); + } + } return ret; } @@ -500,19 +535,19 @@ function dhcpUpdater() function dhcpInfo(sw) { var ret = new handlerInfo("dhcp","DHCP state"); ret.why = "No DHCP data"; - ret.data[0].description = "DHCP age (seconds)"; + ret.data[0].description = "DHCP age"; if (testTree(nmsData,['dhcp','dhcp',sw])) { var now = nmsData.dhcp.time; var then = nmsData.dhcp.dhcp[sw]; var diff = now - then; - var divider = 4; + var divider = 6; if(tagged(sw,'slowdhcp')) { - divider = 10; + divider = 12; } - ret.data[0].value = diff; + ret.data[0].value = secondsToTime(diff); ret.why = "DHCP freshness"; - ret.score = diff/divider> 500 ? 500 : parseInt(diff/divider); + ret.score = diff/divider> 350 ? 350 : parseInt(diff/divider); } else { ret.data[0].value = "No DHCP data"; if (testTree(nmsData,['smanagement','switches',sw])) { @@ -522,7 +557,7 @@ function dhcpInfo(sw) { ret.score = 0; ret.why = "No subnet registered"; } else { - ret.score = 500; + ret.score = 350; ret.why = "No DHCP data"; } } else { @@ -658,6 +693,7 @@ function snmpInfo(sw) { return ret; } + function snmpInit() { nmsData.addHandler("snmp", "mapHandler", snmpUpdater); @@ -669,6 +705,59 @@ function snmpInit() { snmpUpdater(); } +function snmpUpInfo(sw) { + var ret = new handlerInfo("snmpup","SNMP uplink data"); + ret.why = "No SNMP data"; + ret.score = 0; + + if (testTree(nmsData,['snmp','snmp',sw, 'ports'])) { + var total_up = 0; + var seen_up = 0; + for (var port in nmsData.snmp.snmp[sw].ports) { + var x = nmsData.snmp.snmp[sw].ports[port]; + if (x["ifAlias"].match(/Uplink/i) && x["ifOperStatus"] == "up") { + total_up += parseInt(x["ifHighSpeed"]); + } + if (x["ifAlias"].match(/LAG Member/i) && x["ifOperStatus"] == "up") { + seen_up += parseInt(x["ifHighSpeed"]); + } + } + ret.data[0].value = "LAG member speed and total speed is " + seen_up; + if (total_up != seen_up) { + ret.score = 500; + ret.why = "LAG member (ge/xt/etc) speed is " + seen_up + " but logical (ae) is " + total_up; + ret.data[0].value = ret.why; + } + } + return ret; +} + +function cpuInfo(sw) { + var ret = new handlerInfo("cpu","CPU utilization"); + ret.why = "No CPU info"; + ret.score = 0; + + if (testTree(nmsData,['snmp','snmp',sw, 'misc','jnxOperatingCPU'])) { + 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); + } + if (cpu < 30) { + ret.score = 0; + } else if (cpu < 50) { + ret.score = 100; + } else if (cpu < 95) { + ret.score = cpu * 2; + } else { + ret.score = cpu * 4; + } + ret.why = "CPU utilization: " + cpu + "%"; + ret.data[0].value = cpu + "%"; + } + return ret; +} + function cpuUpdater() { for (var sw in nmsData.switches.switches) { try { @@ -714,6 +803,9 @@ function mgmtInfo(sw) { }, { value: mg.subnet6 || "N/A", description: "Subnet (v6)" + }, { + value: mg.distro_name || "N/A", + description: "Distro" }]; if ((mg.mgmt_v4_addr == undefined || mg.mgmt_v4_addr == "") && (mg.mgmt_v6_addr == undefined || mg.mgmt_v6_addr == "")) { ret.why = "No IPv4 or IPv6 mamagement IP"; diff --git a/web/js/nms-map.js b/web/js/nms-map.js index 5669acb..1ebcf92 100644 --- a/web/js/nms-map.js +++ b/web/js/nms-map.js @@ -38,7 +38,7 @@ var nmsMap = nmsMap || { textMargin: 4, xMargin: 10, yMargin: 20, - fontSize: 15, + fontSize: 14, fontFace: "sans-serif" }, scale: 1, diff --git a/web/js/nms-oplog.js b/web/js/nms-oplog.js index c418e33..7ac11c4 100644 --- a/web/js/nms-oplog.js +++ b/web/js/nms-oplog.js @@ -59,7 +59,7 @@ nmsOplog.commit = function() { } nmsOplog.updateComments = function() { - nmsOplog._updateComments(3,"-mini","time",100); + nmsOplog._updateComments(10,"-mini","time",100); nmsOplog._updateComments(0,"","timestamp"); } @@ -89,6 +89,9 @@ nmsOplog._updateComments = function(limit,prefix,timefield,cutoff) { table.classList.add("table-condensed"); var i = 0; for (var v in nmsData['oplog']['oplog']) { + if (cutoff && nmsData.oplog.oplog[v]['username'] == "system") { + continue; + } tr = table.insertRow(-1); td1 = tr.insertCell(0); td2 = tr.insertCell(1); diff --git a/web/js/nms-search.js b/web/js/nms-search.js index 1167b51..f435c81 100644 --- a/web/js/nms-search.js +++ b/web/js/nms-search.js @@ -96,6 +96,22 @@ nmsSearch.searchTest = function(id, sw) { } } } catch (e) {} + try { + for (var x in nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo) { + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == null) { + continue; + } + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == undefined) { + continue; + } + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == "") { + continue; + } + if (re.test(nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x])) { + return true; + } + } + } catch (e) {} if (re.test(nmsData.snmp.snmp[sw].misc.sysDescr[0])) { return true; } -- cgit v1.2.3