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/api/public/switch-state | 57 ++++++++++++++++++++++++++++----------------- web/api/read/oplog | 3 +++ 2 files changed, 39 insertions(+), 21 deletions(-) (limited to 'web/api') diff --git a/web/api/public/switch-state b/web/api/public/switch-state index 36dfeaf..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; @@ -41,21 +43,25 @@ while ( my $ref = $q->fetchrow_hashref() ) { } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and $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") { - $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1; + 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; } - $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; + 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}{'clients'}{'total'} += 1; } $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0; $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'} || 0; @@ -67,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'}; } @@ -94,28 +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/LAG member/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; + 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; } - $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; + 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}{'clients'}{'total'} += 1; } $json{'then'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0; @@ -128,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'}; } diff --git a/web/api/read/oplog b/web/api/read/oplog index 92511bb..15c6177 100755 --- a/web/api/read/oplog +++ b/web/api/read/oplog @@ -16,6 +16,9 @@ while (my $ref = $query->fetchrow_hashref()) { $meh{'id'} = $ref->{'id'}; $meh{'systems'} = $ref->{'systems'}; $meh{'timestamp'} = $ref->{'timestamp'}; + $meh{'timestamp'} =~ s/ /T/; + $meh{'timestamp'} =~ s/\+00$/Z/; + push @{$nms::web::json{'oplog'}},\%meh; } -- cgit v1.2.3