From bb70a05d30ac96e430b8f3dbf4142ed8cdeb5814 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 17 May 2017 10:37:59 +0200 Subject: [PATCH] + alcatel is so slow!! optimize the check --- network/alcatel/isam/snmp/mode/components/sfp.pm | 11 +++++++++-- network/alcatel/isam/snmp/mode/hardware.pm | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/network/alcatel/isam/snmp/mode/components/sfp.pm b/network/alcatel/isam/snmp/mode/components/sfp.pm index b35b1408c..662ea96ad 100644 --- a/network/alcatel/isam/snmp/mode/components/sfp.pm +++ b/network/alcatel/isam/snmp/mode/components/sfp.pm @@ -39,7 +39,9 @@ my $oid_sfpDiagEntry = '.1.3.6.1.4.1.637.61.1.56.5.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_sfpDiagEntry, start => $mapping->{sfpDiagLOS}->{oid}, end => $mapping->{sfpDiagTemperature}->{oid}, }; + foreach (keys %$mapping) { + push @{$self->{request}}, { oid => $mapping->{$_}->{oid} }; + } } sub check { @@ -49,6 +51,11 @@ sub check { $self->{components}->{sfp} = {name => 'sfp', total => 0, skip => 0}; return if ($self->check_filter(section => 'sfp')); + my $results = {}; + foreach (keys %$mapping) { + $results = { %$results, %{$self->{results}->{$mapping->{$_}->{oid}}} }; + } + my ($exit, $warn, $crit, $checked); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_sfpDiagEntry}})) { next if ($oid !~ /^$mapping->{sfpDiagLOS}->{oid}\.(.*?)\.(.*?)$/); @@ -56,7 +63,7 @@ sub check { my $result = $self->{snmp}->map_instance(mapping => $mapping_slot, results => { %{$self->{results}->{$mapping_slot->{eqptSlotActualType}->{oid}}}, %{$self->{results}->{$mapping_slot->{eqptBoardInventorySerialNumber}->{oid}}} }, instance => $slot_id); - my $result2 = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sfpDiagEntry}, instance => $slot_id . '.' . $sfp_faceplate_num); + my $result2 = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $slot_id . '.' . $sfp_faceplate_num); next if ($self->check_filter(section => 'sfp', instance => $slot_id . '.' . $sfp_faceplate_num)); diff --git a/network/alcatel/isam/snmp/mode/hardware.pm b/network/alcatel/isam/snmp/mode/hardware.pm index b1177e034..0d13abdf0 100644 --- a/network/alcatel/isam/snmp/mode/hardware.pm +++ b/network/alcatel/isam/snmp/mode/hardware.pm @@ -85,8 +85,8 @@ Can be: 'cardtemperature', 'sfp'. =item B<--filter> -Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) -Can also exclude specific instance: --filter=fan,101 +Exclude some parts (comma seperated list) (Example: --filter=cardtemperature) +Can also exclude specific instance: --filter=cardtemperature,1080.1 =item B<--no-component> @@ -101,13 +101,13 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(presentOK)$)' =item B<--warning> -Set warning threshold for 'temperature', 'fan', 'psu.fan', 'psu' (syntax: type,regexp,threshold) -Example: --warning='psu.fan,1.1,5000' +Set warning threshold for 'sfp.temperature', 'cardtemperature' (syntax: type,regexp,threshold) +Example: --warning='sfp.temperature,1.1,30' =item B<--critical> -Set critical threshold for 'temperature', 'fan', 'psu.fan', 'psu' (syntax: type,regexp,threshold) -Example: --critical='psu,.*,200' +Set critical threshold for 'sfp.temperature', 'cardtemperature' (syntax: type,regexp,threshold) +Example: --warning='sfp.temperature,1.1,40' =back