|
| 1 | +package GLPI::Agent::SNMP::MibSupport::Htek; |
| 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 | +# UNICORN-MIB |
| 12 | +use constant htek => ".1.3.6.1.4.1.38241" ; |
| 13 | + |
| 14 | +use constant firmware => htek . ".1.1.0"; |
| 15 | +use constant model => htek . ".1.2.0"; |
| 16 | +use constant macaddr => htek . ".1.3.0"; |
| 17 | +use constant ip => htek . ".1.4.0"; |
| 18 | + |
| 19 | +our $mibSupport = [ |
| 20 | + { |
| 21 | + name => "htek", |
| 22 | + sysobjectid => getRegexpOidMatch(htek) |
| 23 | + } |
| 24 | +]; |
| 25 | + |
| 26 | +sub getMacAddress { |
| 27 | + my ($self) = @_; |
| 28 | + |
| 29 | + return getCanonicalMacAddress(getCanonicalString($self->get(macaddr))); |
| 30 | +} |
| 31 | + |
| 32 | +sub getFirmware { |
| 33 | + my ($self) = @_; |
| 34 | + |
| 35 | + my $device = $self->device |
| 36 | + or return; |
| 37 | + |
| 38 | + my $firmwares = getCanonicalString($self->get(firmware)); |
| 39 | + my ($firmware) = $firmwares =~ /^BOOT--([0-9.]+)/; |
| 40 | + return $firmware; |
| 41 | +} |
| 42 | + |
| 43 | +sub getModel { |
| 44 | + my ($self) = @_; |
| 45 | + |
| 46 | + return getCanonicalString($self->get(model)); |
| 47 | +} |
| 48 | + |
| 49 | +sub getIp { |
| 50 | + my ($self) = @_; |
| 51 | + |
| 52 | + return getCanonicalString($self->get(ip)); |
| 53 | +} |
| 54 | + |
| 55 | +sub run { |
| 56 | + my ($self) = @_; |
| 57 | + |
| 58 | + my $device = $self->device |
| 59 | + or return; |
| 60 | + |
| 61 | + # Fix IPS |
| 62 | + if (ref($device->{IPS}) eq 'HASH' && ref($device->{IPS}->{IP}) eq 'ARRAY') { |
| 63 | + my @ips = grep { ! empty($_) } @{$device->{IPS}->{IP}}; |
| 64 | + $device->{IPS}->{IP} = \@ips; |
| 65 | + } |
| 66 | + |
| 67 | + # Fix hostname |
| 68 | + if ($device->{SNMPHOSTNAME} =~ /^\(none\)\s+Description: (\S+).*MAC\s\d:\s(\S\S \S\S \S\S \S\S \S\S \S\S) /) { |
| 69 | + $device->{SNMPHOSTNAME} = "$1 $2"; |
| 70 | + } |
| 71 | + $device->{INFO}{NAME} = $device->{SNMPHOSTNAME} |
| 72 | + if $device->{INFO} && $device->{INFO}{NAME}; |
| 73 | +} |
| 74 | + |
| 75 | +1; |
| 76 | + |
| 77 | +__END__ |
| 78 | +
|
| 79 | +=head1 NAME |
| 80 | +
|
| 81 | +GLPI::Agent::SNMP::MibSupport::Htek - Inventory module for Htek IP phones devices |
| 82 | +
|
| 83 | +=head1 DESCRIPTION |
| 84 | +
|
| 85 | +The module enhances support for Htek IP phones devices |
0 commit comments