From a3409066f2deaf325633ac4a005ff8a97e682eed Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Fri, 10 Nov 2023 18:01:36 +0100 Subject: [PATCH] fix: Enhanced Zebra printers support --- Changes | 1 + lib/GLPI/Agent/SNMP/MibSupport/Zebra.pm | 57 ++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 308cfdfb2..467c4bfb5 100644 --- a/Changes +++ b/Changes @@ -50,6 +50,7 @@ netdiscovery/netinventory: * Enhanced CheckPoint devices support * Enhanced Cisco devices support * Enhanced Citrix devices support +* Enhanced Zebra printers support * PR #500: Enhanced Synology NAS support with drives & storages support * Use Parallel::ForkManager for netdiscovery & netinventory tasks * Preload mibsupport as optimization diff --git a/lib/GLPI/Agent/SNMP/MibSupport/Zebra.pm b/lib/GLPI/Agent/SNMP/MibSupport/Zebra.pm index 140a75690..759ee09f8 100644 --- a/lib/GLPI/Agent/SNMP/MibSupport/Zebra.pm +++ b/lib/GLPI/Agent/SNMP/MibSupport/Zebra.pm @@ -15,11 +15,21 @@ use constant model2 => esi . '.6.2.3.2.1.15.1' ; use constant serial => esi . '.1.5.0' ; use constant fw2 => esi . '.1.9.0' ; +# See ZEBRA-MIB + +use constant zebra => '.1.3.6.1.4.1.10642' ; +use constant zbrGeneralInfo => zebra . '.1' ; + +use constant zbrGeneralModel => zbrGeneralInfo . '.1' ; +use constant zbrGeneralFirmwareVersion => zbrGeneralInfo . '.2.0' ; +use constant zbrGeneralName => zbrGeneralInfo . '.4.0' ; +use constant zbrGeneralUniqueId => zbrGeneralInfo . '.9.0' ; +use constant zbrGeneralCompanyName => zbrGeneralInfo . '.11.0' ; +use constant zbrGeneralLINKOSVersion => zbrGeneralInfo . '.18.0' ; + # See ZEBRA-QL-MIB -use constant zebra => '.1.3.6.1.4.1.10642' ; -use constant model1 => zebra . '.1.1.0' ; -use constant fw1 => zebra . '.1.2.0' ; +use constant model1 => zbrGeneralModel . '.0' ; use constant zql_zebra_ql => zebra . '.200' ; use constant model3 => zql_zebra_ql . '.19.7.0' ; @@ -29,14 +39,30 @@ our $mibSupport = [ { name => "zebra-printer", sysobjectid => getRegexpOidMatch(esi) + }, + { + name => "zebra-printer-zt", + sysobjectid => getRegexpOidMatch(zbrGeneralModel) } ]; +sub getSnmpHostname { + my ($self) = @_; + + return getCanonicalString($self->get(zbrGeneralName)); +} + +sub getManufacturer { + my ($self) = @_; + + return getCanonicalString($self->get(zbrGeneralCompanyName)) || 'Zebra Technologies'; +} + sub getSerial { my ($self) = @_; # serial3 is more accurate than serial on GK420 & ZE500 - return hex2char($self->get(serial3) || $self->get(serial)); + return getCanonicalString($self->get(zbrGeneralUniqueId)) || hex2char($self->get(serial3) || $self->get(serial)); } sub getModel { @@ -48,7 +74,28 @@ sub getModel { sub getFirmware { my ($self) = @_; - return hex2char($self->get(fw1) || $self->get(fw2)); + return hex2char($self->get(zbrGeneralFirmwareVersion) || $self->get(fw2)); +} + +sub run { + my ($self) = @_; + + my $device = $self->device + or return; + + my $manufacturer = $self->getManufacturer() + or return; + + my $linkos_version = $self->get(zbrGeneralLINKOSVersion); + unless (empty($linkos_version)) { + $device->addFirmware({ + NAME => "$manufacturer LinkOS", + DESCRIPTION => "$manufacturer LinkOS firmware", + TYPE => "system", + VERSION => getCanonicalString($linkos_version), + MANUFACTURER => $manufacturer + }); + } } 1;