aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rwxr-xr-xweb/api/public/distro-tree (renamed from web/api/read/distro-tree)0
-rwxr-xr-xweb/api/public/switch-state22
-rwxr-xr-xweb/api/read/switches-management4
-rw-r--r--web/css/nms.css1
-rw-r--r--web/index.html4
-rw-r--r--web/js/nms-map-handlers.js60
-rw-r--r--web/js/nms.js10
7 files changed, 73 insertions, 28 deletions
diff --git a/web/api/read/distro-tree b/web/api/public/distro-tree
index 5d93e1b..5d93e1b 100755
--- a/web/api/read/distro-tree
+++ b/web/api/public/distro-tree
diff --git a/web/api/public/switch-state b/web/api/public/switch-state
index 8e98205..36dfeaf 100755
--- a/web/api/public/switch-state
+++ b/web/api/public/switch-state
@@ -40,7 +40,7 @@ while ( my $ref = $q->fetchrow_hashref() ) {
$json{'switches'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'};
}
if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
- $data{'ports'}{$porti}{'ifAlias'} =~ m/trunk/i) {
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) {
$json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
$json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
if ($port{'ifOperStatus'} eq "up") {
@@ -48,6 +48,15 @@ while ( my $ref = $q->fetchrow_hashref() ) {
}
$json{'switches'}{$sysname}{'uplinks'}{'total'} += 1;
}
+ if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) {
+ $json{'switches'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'switches'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ if ($port{'ifOperStatus'} eq "up") {
+ $json{'switches'}{$sysname}{'clients'}{'live'} += 1;
+ }
+ $json{'switches'}{$sysname}{'clients'}{'total'} += 1;
+ }
$json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0;
$json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'} || 0;
$json{'switches'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0;
@@ -91,7 +100,7 @@ while ( my $ref = $q2->fetchrow_hashref() ) {
$json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'};
}
if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
- $data{'ports'}{$porti}{'ifAlias'} =~ m/trunk/i) {
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) {
$json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
$json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
if ($port{'ifOperStatus'} eq "up") {
@@ -99,6 +108,15 @@ while ( my $ref = $q2->fetchrow_hashref() ) {
}
$json{'then'}{$sysname}{'uplinks'}{'total'} += 1;
}
+ if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) {
+ $json{'then'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'then'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ if ($port{'ifOperStatus'} eq "up") {
+ $json{'then'}{$sysname}{'clients'}{'live'} += 1;
+ }
+ $json{'then'}{$sysname}{'clients'}{'total'} += 1;
+ }
$json{'then'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0;
$json{'then'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'} || 0;
diff --git a/web/api/read/switches-management b/web/api/read/switches-management
index 425262e..9d8bc53 100755
--- a/web/api/read/switches-management
+++ b/web/api/read/switches-management
@@ -20,9 +20,9 @@ $nms::web::cc{'max-age'} = "5";
$nms::web::cc{'stale-while-revalidate'} = "30";
if (!defined($switch)) {
- $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null');
+ $q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,subnet4,subnet6,host(mgmt_v6_addr) as mgmt_v6_addr,host(mgmt_v4_gw) as mgmt_v4_gw,host(mgmt_v6_gw) as mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null');
} else {
- $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ';');
+ $q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,subnet4,subnet6,host(mgmt_v6_addr) as mgmt_v6_addr,host(mgmt_v4_gw) as mgmt_v4_gw,host(mgmt_v6_gw) as mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ';');
}
$q2->execute();
diff --git a/web/css/nms.css b/web/css/nms.css
index 17f4ff9..9c783af 100644
--- a/web/css/nms.css
+++ b/web/css/nms.css
@@ -127,4 +127,5 @@ div.map-mode-legend button {
.graph {
max-width: 100%;
width: 100%;
+ height: 240px;
}
diff --git a/web/index.html b/web/index.html
index 9c66a41..7ea26e3 100644
--- a/web/index.html
+++ b/web/index.html
@@ -92,7 +92,7 @@
</div>
<p class="navbar-text" id="dhcp-summary">(...)</p>
<div class="navbar-text" id="navbar-graph-div">
- <img id="navbar-graph" title="Blue: Average latency. Green: Total traffic. Time frame: last 60 minutes."/>
+ <img id="navbar-graph" style="display:none" title="Blue: Average latency. Green: Total traffic. Time frame: last 60 minutes."/>
</div>
</li>
</ul>
@@ -317,7 +317,7 @@
</div>
</div>
- <div style="display:none;"><img id="source" src="img/tg16-salkart-clean-big.png" ></div>
+ <div style="display:none;"><img id="source" src="img/tg15-salkart-clean-big.png" ></div>
</div>
</div><!--/.fluid-container-->
<script src="js/jquery.min.js" type="text/javascript"></script>
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