Skip to content

Commit

Permalink
fix: Updated Lexmark printers support
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Dec 20, 2024
1 parent 03af48e commit c887d36
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ netdiscovery/netinventory:
* Added Raritan PDU devices support
* Updated sysobject.ids
* Added Avaya J100 series IP Phones support
* Updated Lexmark printers support

deploy:
* Fix checks on command run and clarify reason of success or failure. This fixes
Expand Down
1 change: 0 additions & 1 deletion lib/GLPI/Agent/SNMP/Device.pm
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ sub setSerial {
'.1.3.6.1.4.1.248.14.1.1.9.1.10.1', # Hirschman MIB
'.1.3.6.1.4.1.253.8.53.3.2.1.3.1', # Xerox-MIB
'.1.3.6.1.4.1.367.3.2.1.2.1.4.0', # Ricoh-MIB
'.1.3.6.1.4.1.641.2.1.2.1.6.1', # Lexmark-MIB
'.1.3.6.1.4.1.1602.1.2.1.4.0', # Canon-MIB
'.1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.1.0', # Brother-MIB
'.1.3.6.1.4.1.318.1.1.4.1.5.0', # MasterSwitch-MIB
Expand Down
108 changes: 108 additions & 0 deletions lib/GLPI/Agent/SNMP/MibSupport/Lexmark.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package GLPI::Agent::SNMP::MibSupport::Lexmark;

use strict;
use warnings;

use parent 'GLPI::Agent::SNMP::MibSupportTemplate';

use GLPI::Agent::Tools;
use GLPI::Agent::Tools::SNMP;

use constant enterprises => '.1.3.6.1.4.1';

# LEXMARK-ROOT-MIB
use constant lexmark => enterprises . '.641';

# LEXMARK-PVT-MIB
use constant printer => lexmark . '.2';

use constant prtgenInfoEntry => printer . '1.2.1';

use constant prtgenPrinterName => prtgenInfoEntry . '.2.1' ;
use constant prtgenCodeRevision => prtgenInfoEntry . '.4.1' ;
use constant prtgenSerialNo => prtgenInfoEntry . '.6.1' ;

# LEXMARK-MPS-MIB
use constant mps => lexmark . '.6' ;

use constant device => mps . '.2';
use constant inventory => mps . '.3';

# OID name for the 2 following are extrapolated
use constant deviceModel => device . '.3.1.4.1';
use constant deviceSerial => device . '.3.1.5.1';

use constant hwInventorySerialNumber => inventory . '.1.1.7.1.1';
use constant swInventoryRevision => inventory . '.3.1.7.1.1' ;

# Printer-MIB
use constant prtGeneralSerialNumber => '.1.3.6.1.2.1.43.5.1.1.17.1';

# HOST-RESOURCES-MIB
use constant hrDeviceDescr => '.1.3.6.1.2.1.25.3.2.1.3.1';

our $mibSupport = [
{
name => "lexmark-printer",
sysobjectid => getRegexpOidMatch(lexmark)
}
];

sub getModel {
my ($self) = @_;

my $model;
foreach my $oid (deviceModel, prtgenPrinterName) {
$model = getCanonicalString($self->get($oid))
and last;
}

unless ($model) {
$model = getCanonicalString($self->get(hrDeviceDescr))
or return;
($model) = $model =~ /^(Lexmark\s+\S+)/;
}

return unless $model;

# Strip manufacturer
$model =~ s/^Lexmark\s+//i;

return $model;
}

sub getFirmware {
my ($self) = @_;

my $firmware;
foreach my $oid (swInventoryRevision, prtgenCodeRevision) {
$firmware = getCanonicalString($self->get($oid))
and last;
}

return $firmware;
}

sub getSerial {
my ($self) = @_;

my $serial;
foreach my $oid (prtGeneralSerialNumber, deviceSerial, prtgenSerialNo) {
$serial = getCanonicalString($self->get($oid))
and last;
}

return $serial;
}

1;

__END__
=head1 NAME
GLPI::Agent::SNMP::MibSupport::Lexmark - Inventory module for Lexmark Printers
=head1 DESCRIPTION
The module enhances Lexmark printers devices support.

0 comments on commit c887d36

Please sign in to comment.