aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/public
diff options
context:
space:
mode:
authorOle Mathias Heggem <ole@sdok.no>2017-04-19 23:16:07 +0200
committerOle Mathias Heggem <ole@sdok.no>2017-04-19 23:16:07 +0200
commit7b97188b728c85c498acc8acdce1750c472f2c85 (patch)
tree12c1436ab7eb97e9434e774671e8ffea134d61db /web/api/public
parentf70f65f7466a480a45a8260b35887cb7ed36b466 (diff)
parent7d404abf07d865d253ac2cfc353741e8d4af4867 (diff)
Merge remote-tracking branch 'refs/remotes/tech-server/master'
Diffstat (limited to 'web/api/public')
-rwxr-xr-xweb/api/public/distro-tree25
-rwxr-xr-xweb/api/public/switch-state59
2 files changed, 71 insertions, 13 deletions
diff --git a/web/api/public/distro-tree b/web/api/public/distro-tree
new file mode 100755
index 0000000..5d93e1b
--- /dev/null
+++ b/web/api/public/distro-tree
@@ -0,0 +1,25 @@
+#! /usr/bin/perl
+# vim:ts=8:sw=8
+
+use CGI qw(fatalsToBrowser);
+use DBI;
+use lib '/opt/gondul/include';
+use nms;
+use nms::web;
+use strict;
+use warnings;
+use Data::Dumper;
+
+$nms::web::cc{'max-age'} = "20";
+
+my $q2 = $nms::web::dbh->prepare('select sysname,distro_phy_port,distro_name from switches where placement is not null and distro_name is not null and distro_phy_port is not null');
+
+$q2->execute();
+while (my $ref = $q2->fetchrow_hashref()) {
+ my $sysname = $ref->{'sysname'};
+ my $phy = $ref->{'distro_phy_port'};
+ my $distro = $ref->{'distro_name'};
+ $nms::web::json{'distro-tree'}{$distro}{$phy} = $sysname;
+}
+
+finalize_output();
diff --git a/web/api/public/switch-state b/web/api/public/switch-state
index 8e98205..77350c7 100755
--- a/web/api/public/switch-state
+++ b/web/api/public/switch-state
@@ -25,6 +25,8 @@ while ( my $ref = $q->fetchrow_hashref() ) {
my %data = %{JSON::XS::decode_json($ref->{'data'})};
+ $json{'switches'}{$sysname}{'clients'}{'live'} = 0;
+ $json{'then'}{$sysname}{'clients'}{'live'} = 0;
for my $porti (keys %{$data{'ports'}}) {
if (defined($port) and $port ne "" and $port ne $porti) {
next;
@@ -40,13 +42,26 @@ 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) {
- $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
- $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
- if ($port{'ifOperStatus'} eq "up") {
- $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1;
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) {
+ if ($port{'ifAdminStatus'} eq "up") {
+ $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ if ($port{'ifOperStatus'} eq "up") {
+ $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1;
+ }
+ $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1;
+ }
+ }
+ if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) {
+ if ($port{'ifAdminStatus'} eq "up") {
+ $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}{'uplinks'}{'total'} += 1;
}
$json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0;
$json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'} || 0;
@@ -58,6 +73,9 @@ while ( my $ref = $q->fetchrow_hashref() ) {
}
$json{'switches'}{$sysname}{totals}{'total'} += 1;
}
+
+ $json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortInOctets} = $data{'vcp'}{'jnxVirtualChassisPortInOctets'};
+ $json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortOutOctets} = $data{'vcp'}{'jnxVirtualChassisPortOutOctets'};
$json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'};
$json{'switches'}{$sysname}{'time'} = $ref->{'time'};
}
@@ -85,19 +103,32 @@ while ( my $ref = $q2->fetchrow_hashref() ) {
if ($porti =~ m/\.0$/) {
next;
}
- if ($data{'ports'}{$porti}{'ifAlias'} =~ m/client/) {
+ if ($data{'ports'}{$porti}{'ifAlias'} =~ m/client/i) {
$smallport =~ s/[0-9-].*$//;
} else {
$json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'};
}
if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
- $data{'ports'}{$porti}{'ifAlias'} =~ m/trunk/i) {
- $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
- $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
- if ($port{'ifOperStatus'} eq "up") {
- $json{'then'}{$sysname}{'uplinks'}{'live'} += 1;
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) {
+ if ($port{'ifAdminStatus'} eq "up") {
+ $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'};
+ $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'};
+ if ($port{'ifOperStatus'} eq "up") {
+ $json{'then'}{$sysname}{'uplinks'}{'live'} += 1;
+ }
+ $json{'then'}{$sysname}{'uplinks'}{'total'} += 1;
+ }
+ }
+ if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and
+ $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) {
+ if ($port{'ifAdminStatus'} eq "up") {
+ $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}{'uplinks'}{'total'} += 1;
}
$json{'then'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0;
@@ -110,6 +141,8 @@ while ( my $ref = $q2->fetchrow_hashref() ) {
}
$json{'then'}{$sysname}{totals}{'total'} += 1;
}
+ $json{'then'}{$sysname}{vcp}{jnxVirtualChassisPortInOctets} = $data{'vcp'}{'jnxVirtualChassisPortInOctets'};
+ $json{'then'}{$sysname}{vcp}{jnxVirtualChassisPortOutOctets} = $data{'vcp'}{'jnxVirtualChassisPortOutOctets'};
$json{'then'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'};
$json{'then'}{$sysname}{'time'} = $ref->{'time'};
}