#370 Missing Map Links due to inability to parse port speeds

This commit is contained in:
Oliver Gorwits
2018-03-05 21:42:02 +00:00
parent b940b799ac
commit 66ecb203a7
6 changed files with 26 additions and 16 deletions

View File

@@ -1,3 +1,9 @@
2.039015 -
[BUG FIXES]
* #370 Missing Map Links due to inability to parse port speeds
2.039014 - 2018-03-03 2.039014 - 2018-03-03
[BUG FIXES] [BUG FIXES]

View File

@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
); );
our # try to hide from kwalitee our # try to hide from kwalitee
$VERSION = 48; # schema version used for upgrades, keep as integer $VERSION = 49; # schema version used for upgrades, keep as integer
use Path::Class; use Path::Class;
use File::ShareDir 'dist_dir'; use File::ShareDir 'dist_dir';

View File

@@ -17,16 +17,13 @@ __PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
SELECT dp.ip AS left_ip, ld.dns AS left_dns, ld.name AS left_name, SELECT dp.ip AS left_ip, ld.dns AS left_dns, ld.name AS left_name,
array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr, array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr,
sum(btrim(dp.speed, ' MGTbps')::float sum( COALESCE(dpp.raw_speed,0) ) as aggspeed,
* (CASE btrim(dp.speed, ' 0123456789.')
WHEN 'Gbps' THEN 1000
WHEN 'Tbps' THEN 1000000
ELSE 1 END)) AS aggspeed,
count(*) AS aggports, count(*) AS aggports,
dp2.ip AS right_ip, rd.dns AS right_dns, rd.name AS right_name, dp2.ip AS right_ip, rd.dns AS right_dns, rd.name AS right_name,
array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr
FROM device_port dp FROM device_port dp
LEFT OUTER JOIN device_port_properties dpp USING (ip, port)
INNER JOIN device ld ON dp.ip = ld.ip INNER JOIN device ld ON dp.ip = ld.ip
INNER JOIN device_ip di ON dp.remote_ip = di.alias INNER JOIN device_ip di ON dp.remote_ip = di.alias
INNER JOIN device rd ON di.ip = rd.ip INNER JOIN device rd ON di.ip = rd.ip
@@ -34,7 +31,6 @@ __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
WHERE dp.remote_port IS NOT NULL WHERE dp.remote_port IS NOT NULL
AND dp.type = 'ethernetCsmacd' AND dp.type = 'ethernetCsmacd'
AND dp.speed LIKE '%bps'
AND dp.ip <= dp2.ip AND dp.ip <= dp2.ip
GROUP BY left_ip, left_dns, left_name, right_ip, right_dns, right_name GROUP BY left_ip, left_dns, left_name, right_ip, right_dns, right_name
ORDER BY dp.ip ORDER BY dp.ip

View File

@@ -67,9 +67,7 @@ ajax '/ajax/data/device/netmappositions' => require_login sub {
sub to_speed { sub to_speed {
my $speed = shift or return ''; my $speed = shift or return '';
$speed = SNMP::Info::munge_highspeed($speed); return SNMP::Info::munge_highspeed($speed / 1_000_000);
$speed =~ s/(?:\s|bps)//g;
return $speed;
} }
sub make_node_infostring { sub make_node_infostring {

View File

@@ -19,13 +19,19 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
or return Status->defer("discover failed: could not SNMP connect to $device"); or return Status->defer("discover failed: could not SNMP connect to $device");
my $interfaces = $snmp->interfaces || {}; my $interfaces = $snmp->interfaces || {};
my %properties = ();
my $raw_speed = $snmp->i_speed_raw || {};
foreach my $idx (keys %$raw_speed) {
my $port = $interfaces->{$idx} or next;
$properties{ $port }->{raw_speed} = $raw_speed->{$idx};
}
my $err_cause = $snmp->i_err_disable_cause || {}; my $err_cause = $snmp->i_err_disable_cause || {};
my %properties = ();
foreach my $idx (keys %$err_cause) { foreach my $idx (keys %$err_cause) {
my $port = $interfaces->{$idx}; my $port = $interfaces->{$idx} or next;
next unless $port;
$properties{ $port }->{error_disable_cause} = $err_cause->{$idx}; $properties{ $port }->{error_disable_cause} = $err_cause->{$idx};
} }
@@ -40,8 +46,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my $rem_serial = $snmp->lldp_rem_serial || {}; my $rem_serial = $snmp->lldp_rem_serial || {};
foreach my $idx (keys %$c_if) { foreach my $idx (keys %$c_if) {
my $port = $interfaces->{ $c_if->{$idx} }; my $port = $interfaces->{ $c_if->{$idx} } or next;
next unless $port;
my $remote_cap = $c_cap->{$idx} || []; my $remote_cap = $c_cap->{$idx} || [];
my $remote_type = Encode::decode('UTF-8', $c_platform->{$idx} || ''); my $remote_type = Encode::decode('UTF-8', $c_platform->{$idx} || '');

View File

@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE device_port_properties ADD COLUMN "raw_speed" bigint DEFAULT 0;
COMMIT;