|
| 1 | +package GLPI::Agent::SNMP::MibSupport::Lexmark; |
| 2 | + |
| 3 | +use strict; |
| 4 | +use warnings; |
| 5 | + |
| 6 | +use parent 'GLPI::Agent::SNMP::MibSupportTemplate'; |
| 7 | + |
| 8 | +use GLPI::Agent::Tools; |
| 9 | +use GLPI::Agent::Tools::SNMP; |
| 10 | + |
| 11 | +use constant enterprises => '.1.3.6.1.4.1'; |
| 12 | + |
| 13 | +# LEXMARK-ROOT-MIB |
| 14 | +use constant lexmark => enterprises . '.641'; |
| 15 | + |
| 16 | +# LEXMARK-PVT-MIB |
| 17 | +use constant printer => lexmark . '.2'; |
| 18 | + |
| 19 | +use constant prtgenInfoEntry => printer . '1.2.1'; |
| 20 | + |
| 21 | +use constant prtgenPrinterName => prtgenInfoEntry . '.2.1' ; |
| 22 | +use constant prtgenCodeRevision => prtgenInfoEntry . '.4.1' ; |
| 23 | +use constant prtgenSerialNo => prtgenInfoEntry . '.6.1' ; |
| 24 | + |
| 25 | +# LEXMARK-MPS-MIB |
| 26 | +use constant mps => lexmark . '.6' ; |
| 27 | + |
| 28 | +use constant device => mps . '.2'; |
| 29 | +use constant inventory => mps . '.3'; |
| 30 | + |
| 31 | +# OID name for the 2 following are extrapolated |
| 32 | +use constant deviceModel => device . '.3.1.4.1'; |
| 33 | +use constant deviceSerial => device . '.3.1.5.1'; |
| 34 | + |
| 35 | +use constant hwInventorySerialNumber => inventory . '.1.1.7.1.1'; |
| 36 | +use constant swInventoryRevision => inventory . '.3.1.7.1.1' ; |
| 37 | + |
| 38 | +# Printer-MIB |
| 39 | +use constant prtGeneralSerialNumber => '.1.3.6.1.2.1.43.5.1.1.17.1'; |
| 40 | + |
| 41 | +# HOST-RESOURCES-MIB |
| 42 | +use constant hrDeviceDescr => '.1.3.6.1.2.1.25.3.2.1.3.1'; |
| 43 | + |
| 44 | +our $mibSupport = [ |
| 45 | + { |
| 46 | + name => "lexmark-printer", |
| 47 | + sysobjectid => getRegexpOidMatch(lexmark) |
| 48 | + } |
| 49 | +]; |
| 50 | + |
| 51 | +sub getModel { |
| 52 | + my ($self) = @_; |
| 53 | + |
| 54 | + my $model; |
| 55 | + foreach my $oid (deviceModel, prtgenPrinterName) { |
| 56 | + $model = getCanonicalString($self->get($oid)) |
| 57 | + and last; |
| 58 | + } |
| 59 | + |
| 60 | + unless ($model) { |
| 61 | + $model = getCanonicalString($self->get(hrDeviceDescr)) |
| 62 | + or return; |
| 63 | + ($model) = $model =~ /^(Lexmark\s+\S+)/; |
| 64 | + } |
| 65 | + |
| 66 | + return unless $model; |
| 67 | + |
| 68 | + # Strip manufacturer |
| 69 | + $model =~ s/^Lexmark\s+//i; |
| 70 | + |
| 71 | + return $model; |
| 72 | +} |
| 73 | + |
| 74 | +sub getFirmware { |
| 75 | + my ($self) = @_; |
| 76 | + |
| 77 | + my $firmware; |
| 78 | + foreach my $oid (swInventoryRevision, prtgenCodeRevision) { |
| 79 | + $firmware = getCanonicalString($self->get($oid)) |
| 80 | + and last; |
| 81 | + } |
| 82 | + |
| 83 | + return $firmware; |
| 84 | +} |
| 85 | + |
| 86 | +sub getSerial { |
| 87 | + my ($self) = @_; |
| 88 | + |
| 89 | + my $serial; |
| 90 | + foreach my $oid (prtGeneralSerialNumber, deviceSerial, prtgenSerialNo) { |
| 91 | + $serial = getCanonicalString($self->get($oid)) |
| 92 | + and last; |
| 93 | + } |
| 94 | + |
| 95 | + return $serial; |
| 96 | +} |
| 97 | + |
| 98 | +1; |
| 99 | + |
| 100 | +__END__ |
| 101 | +
|
| 102 | +=head1 NAME |
| 103 | +
|
| 104 | +GLPI::Agent::SNMP::MibSupport::Lexmark - Inventory module for Lexmark Printers |
| 105 | +
|
| 106 | +=head1 DESCRIPTION |
| 107 | +
|
| 108 | +The module enhances Lexmark printers devices support. |
0 commit comments