aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xweb/nms.gathering.org/api/public/switch-state13
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js52
2 files changed, 36 insertions, 29 deletions
diff --git a/web/nms.gathering.org/api/public/switch-state b/web/nms.gathering.org/api/public/switch-state
index 62d0078..6f7573c 100755
--- a/web/nms.gathering.org/api/public/switch-state
+++ b/web/nms.gathering.org/api/public/switch-state
@@ -20,7 +20,7 @@ while ( my $ref = $q->fetchrow_hashref() ) {
my %port = %{$data{'ports'}{$porti}};
my $smallport = $porti;
$smallport =~ s/[0-9-].*$//;
- if ($porti =~ /ge-0\/0\/4[4-7]/ or $porti eq 'eth0') {
+ if ($porti =~ /ge-0\/0\/4[4-7]/) {
$json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
$json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
if ($port{'ifOperStatus'} eq "up") {
@@ -29,12 +29,15 @@ while ( my $ref = $q->fetchrow_hashref() ) {
$json{'switches'}{$sysname}{'uplinks'}{'total'} += 1;
}
- $json{'switches'}{$sysname}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'};
- $json{'switches'}{$sysname}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ $json{'switches'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'switches'}{$sysname}{totals}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
if ($port{'ifOperStatus'} eq "up") {
- $json{'switches'}{$sysname}{$smallport}{'live'} += 1;
+ $json{'switches'}{$sysname}{ifs}{$smallport}{'live'} += 1;
+ $json{'switches'}{$sysname}{totals}{'live'} += 1;
}
- $json{'switches'}{$sysname}{$smallport}{'total'} += 1;
+ $json{'switches'}{$sysname}{totals}{'total'} += 1;
}
$json{'switches'}{$sysname}{'time'} = $ref->{'time'};
}
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index 5f16ec2..545e62a 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -393,33 +393,37 @@ nmsInfoBox._makeCommentTable = function(content) {
}
nmsInfoBox._searchSmart = function(id, sw) {
- if (nmsData.smanagement.switches[sw].distro == id) {
- console.log("ieh");
- return true;
- }
- if (id.match("[a-z]+.active")) {
- console.log("hei: " + sw);
- var family = id.match("[a-z]+");
- var limit = id;
- limit = limit.replace(family + ".active>","");
- limit = limit.replace(family + ".active<","");
- limit = limit.replace(family + ".active=","");
- var operator = id.replace(family + ".active","")[0];
- if (limit == parseInt(limit)) {
- if (operator == ">" ) {
- if (nmsData.switchstate.switches[sw][family].live > limit) {
- return true;
- }
- } else if (operator == "<") {
- if (nmsData.switchstate.switches[sw][family].live < limit) {
- return true;
- }
- } else if (operator == "=") {
- if (nmsData.switchstate.switches[sw][family].live == limit) {
- return true;
+ try {
+ if (nmsData.smanagement.switches[sw].distro == id) {
+ return true;
+ }
+ if (id.match("active")) {
+ var limit = id;
+ limit = limit.replace("active>","");
+ limit = limit.replace("active<","");
+ limit = limit.replace("active=","");
+ var operator = id.replace("active","")[0];
+ if (limit == parseInt(limit)) {
+ if (operator == ">" ) {
+ if (nmsData.switchstate.switches[sw]['totals'].live > limit) {
+ return true;
+ }
+ } else if (operator == "<") {
+ if (nmsData.switchstate.switches[sw]['totals'].live < limit) {
+ return true;
+ }
+ } else if (operator == "=") {
+ if (nmsData.switchstate.switches[sw]['totals'].live == limit) {
+ return true;
+ }
}
}
}
+ if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) {
+ return true;
+ }
+ } catch (e) {
+ return false;
}
return false;
}