mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-23 13:45:18 +02:00
optimize qsan request
This commit is contained in:
parent
b2ff97e1bd
commit
c74cdbf8af
@ -22,16 +22,16 @@ package storage::qsan::nas::snmp::mode::components::fan;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use storage::qsan::nas::snmp::mode::components::resources qw($mapping);
|
||||||
|
|
||||||
my $mapping = {
|
sub load {
|
||||||
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
|
my ($self) = @_;
|
||||||
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
|
|
||||||
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
|
if ($self->{monitor_loaded} == 0) {
|
||||||
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
|
storage::qsan::nas::snmp::mode::components::resources::load_monitor(request => $self->{request});
|
||||||
};
|
$self->{monitor_loaded} = 1;
|
||||||
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
|
}
|
||||||
|
}
|
||||||
sub load {}
|
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -41,11 +41,12 @@ sub check {
|
|||||||
return if ($self->check_filter(section => 'fan'));
|
return if ($self->check_filter(section => 'fan'));
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked);
|
my ($exit, $warn, $crit, $checked);
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results_monitor}})) {
|
||||||
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Cooling/i);
|
next if ($self->{results_monitor}->{$oid} !~ /Cooling/i);
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
|
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_monitor}, instance => $instance);
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||||
|
|
||||||
@ -76,4 +77,4 @@ sub check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -22,16 +22,16 @@ package storage::qsan::nas::snmp::mode::components::psu;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use storage::qsan::nas::snmp::mode::components::resources qw($mapping);
|
||||||
|
|
||||||
my $mapping = {
|
sub load {
|
||||||
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
|
my ($self) = @_;
|
||||||
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
|
|
||||||
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
|
if ($self->{monitor_loaded} == 0) {
|
||||||
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
|
storage::qsan::nas::snmp::mode::components::resources::load_monitor(request => $self->{request});
|
||||||
};
|
$self->{monitor_loaded} = 1;
|
||||||
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
|
}
|
||||||
|
}
|
||||||
sub load {}
|
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -41,12 +41,12 @@ sub check {
|
|||||||
return if ($self->check_filter(section => 'psu'));
|
return if ($self->check_filter(section => 'psu'));
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked);
|
my ($exit, $warn, $crit, $checked);
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results_monitor}})) {
|
||||||
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Power Supply/i);
|
next if ($self->{results_monitor}->{$oid} !~ /Power Supply/i);
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_monitor}, instance => $instance);
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||||
|
|
||||||
@ -61,4 +61,4 @@ sub check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
47
storage/qsan/nas/snmp/mode/components/resources.pm
Normal file
47
storage/qsan/nas/snmp/mode/components/resources.pm
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2017 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package storage::qsan::nas::snmp::mode::components::resources;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Exporter;
|
||||||
|
|
||||||
|
our $mapping;
|
||||||
|
|
||||||
|
our @ISA = qw(Exporter);
|
||||||
|
our @EXPORT_OK = qw($mapping);
|
||||||
|
|
||||||
|
$mapping = {
|
||||||
|
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
|
||||||
|
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
|
||||||
|
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
|
||||||
|
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
|
||||||
|
};
|
||||||
|
|
||||||
|
sub load_monitor {
|
||||||
|
my (%options) = @_;
|
||||||
|
|
||||||
|
push @{$options{request}}, { oid => $mapping->{ems_type}->{oid} },
|
||||||
|
{ oid => $mapping->{ems_item}->{oid} }, { oid => $mapping->{ems_value}->{oid} },
|
||||||
|
{ oid => $mapping->{ems_status}->{oid} };
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
@ -22,16 +22,16 @@ package storage::qsan::nas::snmp::mode::components::temperature;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use storage::qsan::nas::snmp::mode::components::resources qw($mapping);
|
||||||
|
|
||||||
my $mapping = {
|
sub load {
|
||||||
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
|
my ($self) = @_;
|
||||||
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
|
|
||||||
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
|
if ($self->{monitor_loaded} == 0) {
|
||||||
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
|
storage::qsan::nas::snmp::mode::components::resources::load_monitor(request => $self->{request});
|
||||||
};
|
$self->{monitor_loaded} = 1;
|
||||||
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
|
}
|
||||||
|
}
|
||||||
sub load {}
|
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -41,12 +41,12 @@ sub check {
|
|||||||
return if ($self->check_filter(section => 'temperature'));
|
return if ($self->check_filter(section => 'temperature'));
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked);
|
my ($exit, $warn, $crit, $checked);
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results_monitor}})) {
|
||||||
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Temperature/i);
|
next if ($self->{results_monitor}->{$oid} !~ /Temperature/i);
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_monitor}, instance => $instance);
|
||||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||||
|
|
||||||
# +72.0 (C) (hyst = +5.0 (C), high = +90.0 (C))
|
# +72.0 (C) (hyst = +5.0 (C), high = +90.0 (C))
|
||||||
@ -76,4 +76,4 @@ sub check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -22,16 +22,16 @@ package storage::qsan::nas::snmp::mode::components::voltage;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use storage::qsan::nas::snmp::mode::components::resources qw($mapping);
|
||||||
|
|
||||||
my $mapping = {
|
sub load {
|
||||||
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
|
my ($self) = @_;
|
||||||
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
|
|
||||||
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
|
if ($self->{monitor_loaded} == 0) {
|
||||||
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
|
storage::qsan::nas::snmp::mode::components::resources::load_monitor(request => $self->{request});
|
||||||
};
|
$self->{monitor_loaded} = 1;
|
||||||
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
|
}
|
||||||
|
}
|
||||||
sub load {}
|
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -41,12 +41,12 @@ sub check {
|
|||||||
return if ($self->check_filter(section => 'voltage'));
|
return if ($self->check_filter(section => 'voltage'));
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked);
|
my ($exit, $warn, $crit, $checked);
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results_monitor}})) {
|
||||||
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Voltage/i);
|
next if ($self->{results_monitor}->{$oid} !~ /Voltage/i);
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_monitor}, instance => $instance);
|
||||||
next if ($self->check_filter(section => 'voltage', instance => $instance));
|
next if ($self->check_filter(section => 'voltage', instance => $instance));
|
||||||
|
|
||||||
#+0.99 V (min = +0.75 V, max = +1.35 V)
|
#+0.99 V (min = +0.75 V, max = +1.35 V)
|
||||||
@ -76,4 +76,4 @@ sub check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::hardware);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use storage::qsan::nas::snmp::mode::components::resources qw($mapping);
|
||||||
|
|
||||||
sub set_system {
|
sub set_system {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
@ -45,6 +46,7 @@ sub set_system {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$self->{monitor_loaded} = 0;
|
||||||
$self->{components_path} = 'storage::qsan::nas::snmp::mode::components';
|
$self->{components_path} = 'storage::qsan::nas::snmp::mode::components';
|
||||||
$self->{components_module} = ['disk', 'voltage', 'temperature', 'psu', 'fan'];
|
$self->{components_module} = ['disk', 'voltage', 'temperature', 'psu', 'fan'];
|
||||||
}
|
}
|
||||||
@ -53,9 +55,11 @@ sub snmp_execute {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
|
|
||||||
push @{$self->{request}}, { oid => $oid_monitorEntry };
|
|
||||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||||
|
if ($self->{monitor_loaded} == 1) {
|
||||||
|
$self->{results_monitor} = { %{$self->{results}->{$mapping->{ems_type}->{oid}}}, %{$self->{results}->{$mapping->{ems_item}->{oid}}},
|
||||||
|
%{$self->{results}->{$mapping->{ems_value}->{oid}}}, %{$self->{results}->{$mapping->{ems_status}->{oid}}} };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user