From 524b425a855c3a2f15060d30d672986adf1a060c Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:09:52 -0300 Subject: [PATCH 01/12] Improve serial and SSID detection Show SSID names instead of radio ifname on GLPI UI and fix Serial getting on UniFi AP series. --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 71 ++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index a7caf4ddd..d21355998 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -10,20 +10,40 @@ use GLPI::Agent::Tools::SNMP; # See UBNT-MIB -use constant ubnt => '.1.3.6.1.4.1.41112'; -use constant ubntWlStatApMac => ubnt . '.1.4.5.1.4.1'; +use constant ubnt => '.1.3.6.1.4.1.41112'; +use constant ubntWlStatApMac => ubnt . '.1.4.5.1.4.1'; + +# See UBNT-UniFi-MIB + +use constant unifiVapEssid => ubnt . '.1.6.1.2.1.6'; +use constant unifiVapName => ubnt . '.1.6.1.2.1.7'; +use constant unifiApSystemVersion => ubnt . '.1.6.3.6.0'; +use constant unifiApSystemModel => ubnt . '.1.6.3.3.0'; + our $mibSupport = [ { name => "ubnt", - oid => ubnt + sysobjectid => getRegexpOidMatch(ubnt) } ]; +sub getFirmware { + my ($self) = @_; + + return getCanonicalString($self->get(unifiApSystemVersion)); +} + +sub getModel { + my ($self) = @_; + + return getCanonicalString($self->get(unifiApSystemModel)); +} + sub getSerial { my ($self) = @_; - my $serial = getCanonicalMacAddress($self->get(ubntWlStatApMac)); + my $serial = $self->getMacAddress; $serial =~ s/://g; return $serial; @@ -31,8 +51,49 @@ sub getSerial { sub getMacAddress { my ($self) = @_; + + my $device = $self->device + or return; + + my $serial = getCanonicalMacAddress($self->get(ubntWlStatApMac)); + $serial = $device->{MAC} + if not defined ($serial); + + return $serial; +} - return $self->get(ubntWlStatApMac); + + +sub run { + my ($self) = @_; + + my $device = $self->device + or return; + + my $ports = $device->{PORTS}->{PORT}; + + my $unifiVapEssidValues = $self->walk(unifiVapEssid) || {}; + my $unifiVapNameValues = $self->walk(unifiVapName) || {}; + + foreach my $port (keys(%$ports)) { + my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; + next unless ($ifdescr !~ s/^(?!ra)//g); + + foreach my $index (keys(%$unifiVapNameValues)) { + if ($ifdescr eq $unifiVapNameValues->{$index}) { + $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; + $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); + + if($ifdescr =~ s/^ra(\d+)$//g) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; + } elsif($ifdescr =~ s/^rai(\d+)$//g) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; + } + + last; + } + } + } } 1; From be71a6265f33871cf01bd7ecbc140de1a6c425db Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:35:15 -0300 Subject: [PATCH 02/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index d21355998..bf5c62cb0 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -43,7 +43,10 @@ sub getModel { sub getSerial { my ($self) = @_; - my $serial = $self->getMacAddress; + my $device = $self->device + or return; + + my $serial = $device->{MAC} || getCanonicalMacAddress($self->get(ubntWlStatApMac)); $serial =~ s/://g; return $serial; From 78aeb4b00dd54dc0d66ce7691c470848e3c703f0 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:19:56 -0300 Subject: [PATCH 03/12] Enhance UniFi AP support --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 104 ++++++++++++++----------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index bf5c62cb0..e7f11e042 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -10,34 +10,44 @@ use GLPI::Agent::Tools::SNMP; # See UBNT-MIB -use constant ubnt => '.1.3.6.1.4.1.41112'; -use constant ubntWlStatApMac => ubnt . '.1.4.5.1.4.1'; +use constant ubnt => '.1.3.6.1.4.1.41112'; +use constant ubntWlStatApMac => ubnt . '.1.4.5.1.4.1'; # See UBNT-UniFi-MIB use constant unifiVapEssid => ubnt . '.1.6.1.2.1.6'; use constant unifiVapName => ubnt . '.1.6.1.2.1.7'; use constant unifiApSystemVersion => ubnt . '.1.6.3.6.0'; -use constant unifiApSystemModel => ubnt . '.1.6.3.3.0'; - +use constant unifiApSystemModel => ubnt . '.1.6.3.3.0'; our $mibSupport = [ { name => "ubnt", + oid => ubnt + }, + { + name => "ubnt-unifi", sysobjectid => getRegexpOidMatch(ubnt) } ]; sub getFirmware { my ($self) = @_; + + my $firmware = getCanonicalString($self->get(unifiApSystemVersion)); - return getCanonicalString($self->get(unifiApSystemVersion)); + return $firmware + if defined($firmware); } sub getModel { my ($self) = @_; + + my $device = $self->device + or return; - return getCanonicalString($self->get(unifiApSystemModel)); + return getCanonicalString($self->get(unifiApSystemModel)) + if not defined($device->{MODEL}); } sub getSerial { @@ -46,7 +56,7 @@ sub getSerial { my $device = $self->device or return; - my $serial = $device->{MAC} || getCanonicalMacAddress($self->get(ubntWlStatApMac)); + my $serial = getCanonicalMacAddress($self->get(ubntWlStatApMac)) || $device->{MAC}; $serial =~ s/://g; return $serial; @@ -54,49 +64,55 @@ sub getSerial { sub getMacAddress { my ($self) = @_; - - my $device = $self->device + + my $device = $self->device or return; - - my $serial = getCanonicalMacAddress($self->get(ubntWlStatApMac)); - $serial = $device->{MAC} - if not defined ($serial); - return $serial; + return getCanonicalMacAddress($self->get(ubntWlStatApMac)) || $device->{MAC}; } - - sub run { - my ($self) = @_; - - my $device = $self->device + my ($self) = @_; + + my $device = $self->device or return; - - my $ports = $device->{PORTS}->{PORT}; - - my $unifiVapEssidValues = $self->walk(unifiVapEssid) || {}; - my $unifiVapNameValues = $self->walk(unifiVapName) || {}; - - foreach my $port (keys(%$ports)) { - my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; - next unless ($ifdescr !~ s/^(?!ra)//g); - - foreach my $index (keys(%$unifiVapNameValues)) { - if ($ifdescr eq $unifiVapNameValues->{$index}) { - $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; - $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); - - if($ifdescr =~ s/^ra(\d+)$//g) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; - } elsif($ifdescr =~ s/^rai(\d+)$//g) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; - } - - last; - } - } - } + + # Get list of device ports (e.g. raX, raiX etc.) + my $ports = $device->{PORTS}->{PORT}; + + # Get list of SSID + my $unifiVapEssidValues = $self->walk(unifiVapEssid) || {}; + # Get list of Radios (e.g. ra0, rai0 etc.) + my $unifiVapNameValues = $self->walk(unifiVapName) || {}; + # The list of Radios is co-related to the list of SSIDs + # $unifiVapNameValues->{0} = ra0 + # $unifiVapEssidValues->{0} = + + foreach my $port (keys(%$ports)) { + # For each device Radio port (raX, raiX etc.) + # If you have more than one SSID there will also be more raX, raiX for each SSID. + my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; + next unless (defined($ifdescr) && $ifdescr !~ m/^(?!ra)/); + + foreach my $index (keys(%$unifiVapNameValues)) { + # Compares the device's current radio port name to the AP's radio list (e.g. raX eq raX) + if ($ifdescr eq $unifiVapNameValues->{$index}) { + # Defines the port alias with the name of the radio (e.g. raX) + $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; + # Replaces the radio port name with its respective + $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); + + # raX and raiX are the network interfaces for the 2.4GHz and 5GHz radios respectively + if($ifdescr =~ m/^ra(\d+)$/) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; + } elsif($ifdescr =~ m/^rai(\d+)$/) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; + } + + last; + } + } + } } 1; From a8b998f5aa6accfd162e8e0c5b64c4e6e60aa30a Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:24:19 -0300 Subject: [PATCH 04/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index e7f11e042..43c71671f 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -97,19 +97,19 @@ sub run { foreach my $index (keys(%$unifiVapNameValues)) { # Compares the device's current radio port name to the AP's radio list (e.g. raX eq raX) if ($ifdescr eq $unifiVapNameValues->{$index}) { - # Defines the port alias with the name of the radio (e.g. raX) - $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; - # Replaces the radio port name with its respective - $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); - - # raX and raiX are the network interfaces for the 2.4GHz and 5GHz radios respectively - if($ifdescr =~ m/^ra(\d+)$/) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; - } elsif($ifdescr =~ m/^rai(\d+)$/) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; - } - - last; + # Defines the port alias with the name of the radio (e.g. raX) + $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; + # Replaces the radio port name with its respective + $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); + + # raX and raiX are the network interfaces for the 2.4GHz and 5GHz radios respectively + if ($ifdescr =~ m/^ra\d+$/) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; + } elsif ($ifdescr =~ m/^rai\d+$/) { + $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; + } + + last; } } } From 427944f7650e82755dee4b4cdda11fe79c08ca04 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 09:01:26 -0300 Subject: [PATCH 05/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 43c71671f..4e1cda369 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -92,7 +92,7 @@ sub run { # For each device Radio port (raX, raiX etc.) # If you have more than one SSID there will also be more raX, raiX for each SSID. my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; - next unless (defined($ifdescr) && $ifdescr !~ m/^(?!ra)/); + next unless defined($ifdescr) && $ifdescr =~ /^ra/; foreach my $index (keys(%$unifiVapNameValues)) { # Compares the device's current radio port name to the AP's radio list (e.g. raX eq raX) From 9dfdb55c1cb33faab9e9859be0bb3e36852e3452 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 09:01:51 -0300 Subject: [PATCH 06/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 4e1cda369..6e8fd9048 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -34,10 +34,7 @@ our $mibSupport = [ sub getFirmware { my ($self) = @_; - my $firmware = getCanonicalString($self->get(unifiApSystemVersion)); - - return $firmware - if defined($firmware); + return getCanonicalString($self->get(unifiApSystemVersion)); } sub getModel { From 2ed339d12f2199dc59b444d10134d4a97dc1176a Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 09:09:22 -0300 Subject: [PATCH 07/12] Update Ubnt.pm --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 6e8fd9048..37f162824 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -40,11 +40,7 @@ sub getFirmware { sub getModel { my ($self) = @_; - my $device = $self->device - or return; - - return getCanonicalString($self->get(unifiApSystemModel)) - if not defined($device->{MODEL}); + return getCanonicalString($self->get(unifiApSystemModel)); } sub getSerial { @@ -62,10 +58,7 @@ sub getSerial { sub getMacAddress { my ($self) = @_; - my $device = $self->device - or return; - - return getCanonicalMacAddress($self->get(ubntWlStatApMac)) || $device->{MAC}; + return getCanonicalMacAddress($self->get(ubntWlStatApMac)); } sub run { From 45d0572d084aa840b0c34520178962c00ad9ccf1 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:07:57 -0300 Subject: [PATCH 08/12] Remove whitespaces and override default iftype --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 37f162824..dace3cc41 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -33,13 +33,13 @@ our $mibSupport = [ sub getFirmware { my ($self) = @_; - + return getCanonicalString($self->get(unifiApSystemVersion)); } sub getModel { my ($self) = @_; - + return getCanonicalString($self->get(unifiApSystemModel)); } @@ -99,6 +99,11 @@ sub run { $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; } + # Replaces the port iftype from "Ethernet" (6) to "WiFi" (71) + if($device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { + $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71 + } + last; } } From b463a5d2aaf0108f1dbb53d95b82bcfc45868449 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:59:47 -0300 Subject: [PATCH 09/12] Move iftype definition to after Radio match --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index dace3cc41..ded507507 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -83,6 +83,11 @@ sub run { # If you have more than one SSID there will also be more raX, raiX for each SSID. my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; next unless defined($ifdescr) && $ifdescr =~ /^ra/; + + # Replaces the port iftype from "Ethernet" (6) to "WiFi" (71) + if ($device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { + $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71 + } foreach my $index (keys(%$unifiVapNameValues)) { # Compares the device's current radio port name to the AP's radio list (e.g. raX eq raX) @@ -99,11 +104,6 @@ sub run { $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; } - # Replaces the port iftype from "Ethernet" (6) to "WiFi" (71) - if($device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { - $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71 - } - last; } } From 38b565bae27cc70b08c9df81d4a69a2b5301eff7 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 23 Apr 2024 14:53:15 -0300 Subject: [PATCH 10/12] Trim whitespace --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index ded507507..1f9110274 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -83,7 +83,7 @@ sub run { # If you have more than one SSID there will also be more raX, raiX for each SSID. my $ifdescr = $device->{PORTS}->{PORT}->{$port}->{IFDESCR}; next unless defined($ifdescr) && $ifdescr =~ /^ra/; - + # Replaces the port iftype from "Ethernet" (6) to "WiFi" (71) if ($device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71 From fe8a95695451dbafcee98e8428e9c5b12d5a3b64 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:47:23 -0300 Subject: [PATCH 11/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 1f9110274..4372b926c 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -85,8 +85,8 @@ sub run { next unless defined($ifdescr) && $ifdescr =~ /^ra/; # Replaces the port iftype from "Ethernet" (6) to "WiFi" (71) - if ($device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { - $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71 + if ($device->{PORTS}->{PORT}->{$port}->{IFTYPE} && $device->{PORTS}->{PORT}->{$port}->{IFTYPE} == 6) { + $device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71; } foreach my $index (keys(%$unifiVapNameValues)) { From b270a37d4cdc44a3ad057f73c25bb909039df5aa Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:47:49 -0300 Subject: [PATCH 12/12] Update lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm Co-authored-by: Guillaume Bougard --- lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm index 4372b926c..fed85def6 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Ubnt.pm @@ -95,13 +95,17 @@ sub run { # Defines the port alias with the name of the radio (e.g. raX) $device->{PORTS}->{PORT}->{$port}->{IFALIAS} = $ifdescr; # Replaces the radio port name with its respective - $device->{PORTS}->{PORT}->{$port}->{IFNAME} = getCanonicalString($unifiVapEssidValues->{$index}); + my $ifname = getCanonicalString($unifiVapEssidValues->{$index}); - # raX and raiX are the network interfaces for the 2.4GHz and 5GHz radios respectively - if ($ifdescr =~ m/^ra\d+$/) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (2.4GHz)"; - } elsif ($ifdescr =~ m/^rai\d+$/) { - $device->{PORTS}->{PORT}->{$port}->{IFNAME} .= " (5GHz)"; + unless (empty($ifname)) { + # raX and raiX are the network interfaces for the 2.4GHz and 5GHz radios respectively + if ($ifdescr =~ m/^ra\d+$/) { + $ifname .= " (2.4GHz)"; + } elsif ($ifdescr =~ m/^rai\d+$/) { + $ifname .= " (5GHz)"; + } + + $device->{PORTS}->{PORT}->{$port}->{IFNAME} = $ifname; } last;