(plugin) hardware::pdu::raritan::snmp - add external-sensors mode (#4182)

This commit is contained in:
qgarnier 2023-01-26 16:43:41 +00:00 committed by GitHub
parent 8a3790af0e
commit bdfc062669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 311 additions and 101 deletions

View File

@ -67,52 +67,66 @@ my %map_state = (
22 => 'i1OpenFault', 23 => 'i1ShortFault',
24 => 'i2OpenFault', 25 => 'i2ShortFault', 26 => 'fault',
27 => 'warning', 28 => 'critical',
29 => 'selfTest',
29 => 'selfTest'
);
$mapping = {
external_label => {
Label => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.4' } # externalSensorName
},
external => {
Unit => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.16', map => \%map_units }, # externalSensorUnits
Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.17' }, # externalSensorDecimalDigits
LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.31' }, # externalSensorLowerCriticalThreshold
LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.32' }, # externalSensorLowerWarningThreshold
UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.33' }, # externalSensorUpperCriticalThreshold
UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.34' }, # externalSensorUpperWarningThreshold
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.6.3.1.35' }, # externalSensorEnabledThresholds
State => { oid => '.1.3.6.1.4.1.13742.6.5.5.3.1.3', map => \%map_state }, # measurementsExternalSensorState
Value => { oid => '.1.3.6.1.4.1.13742.6.5.5.3.1.4' } # measurementsExternalSensorValue
},
inlet_label => {
Label => { oid => '.1.3.6.1.4.1.13742.6.3.3.3.1.2' }, # inletLabel
Label => { oid => '.1.3.6.1.4.1.13742.6.3.3.3.1.2' } # inletLabel
},
inlet => {
Unit => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.6', map => \%map_units }, # inletSensorUnits
Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.7' }, # inletSensorDecimalDigits
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.25' }, # inletSensorEnabledThresholds
LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.21' }, # inletSensorLowerCriticalThreshold
LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.22' }, # inletSensorLowerWarningThreshold
UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.23' }, # inletSensorUpperCriticalThreshold
UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.24' }, # inletSensorUpperWarningThreshold
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.3.4.1.25' }, # inletSensorEnabledThresholds
State => { oid => '.1.3.6.1.4.1.13742.6.5.2.3.1.3', map => \%map_state }, # measurementsInletSensorState
Value => { oid => '.1.3.6.1.4.1.13742.6.5.2.3.1.4' }, # measurementsInletSensorValue
Value => { oid => '.1.3.6.1.4.1.13742.6.5.2.3.1.4' } # measurementsInletSensorValue
},
outlet_label => {
Label => { oid => '.1.3.6.1.4.1.13742.6.3.5.3.1.2' }, # outletLabel
Label => { oid => '.1.3.6.1.4.1.13742.6.3.5.3.1.2' } # outletLabel
},
outlet => {
Unit => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.6', map => \%map_units }, # outletSensorUnits
Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.7' }, # outletSensorDecimalDigits
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.25' }, # outletSensorEnabledThresholds
LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.21' }, # outletSensorLowerCriticalThreshold
LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.22' }, # outletSensorLowerWarningThreshold
UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.23' }, # outletSensorUpperCriticalThreshold
UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.24' }, # outletSensorUpperWarningThreshold
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.5.4.1.25' }, # outletSensorEnabledThresholds
State => { oid => '.1.3.6.1.4.1.13742.6.5.4.3.1.3', map => \%map_state }, # measurementsOutletSensorState
Value => { oid => '.1.3.6.1.4.1.13742.6.5.4.3.1.4' }, # measurementsOutletSensorValue
Value => { oid => '.1.3.6.1.4.1.13742.6.5.4.3.1.4' } # measurementsOutletSensorValue
},
ocprot_label => {
Label => { oid => '.1.3.6.1.4.1.13742.6.3.4.3.1.2' }, # overCurrentProtectorLabel
Label => { oid => '.1.3.6.1.4.1.13742.6.3.4.3.1.2' } # overCurrentProtectorLabel
},
ocprot => {
Unit => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.6', map => \%map_units }, # overCurrentProtectorSensorUnits
Decimal => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.7' }, # overCurrentProtectorSensorDecimalDigits
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.25' }, # overCurrentProtectorSensorEnabledThresholds
LowerCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.21' }, # overCurrentProtectorSensorLowerCriticalThreshold
LowerWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.22' }, # overCurrentProtectorSensorLowerWarningThreshold
UpperCriticalThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.23' }, # overCurrentProtectorSensorUpperCriticalThreshold
UpperWarningThreshold => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.24' }, # overCurrentProtectorSensorUpperWarningThreshold
EnabledThresholds => { oid => '.1.3.6.1.4.1.13742.6.3.4.4.1.25' }, # overCurrentProtectorSensorEnabledThresholds
State => { oid => '.1.3.6.1.4.1.13742.6.5.3.3.1.3', map => \%map_state }, # measurementsOverCurrentProtectorSensorState
Value => { oid => '.1.3.6.1.4.1.13742.6.5.3.3.1.4' }, # measurementsOverCurrentProtectorSensorValue
},
Value => { oid => '.1.3.6.1.4.1.13742.6.5.3.3.1.4' } # measurementsOverCurrentProtectorSensorValue
}
};
%raritan_type = (
@ -130,7 +144,7 @@ $mapping = {
inletPhaseSyncAngle => 38, inletPhaseSync => 39, operatingState => 40,
activeInlet => 41, illuminance => 42, doorContact => 43,
tamperDetection => 44, motionDetection => 45, i1smpsStatus => 46,
i2smpsStatus => 47, switchStatus => 48,
i2smpsStatus => 47, switchStatus => 48
);
%map_type = (
@ -187,55 +201,55 @@ $thresholds = {
['belowLowerCritical', 'CRITICAL'],
['belowLowerWarning', 'WARNING'],
['aboveUpperWarning', 'WARNING'],
['aboveUpperCritical', 'CRITICAL'],
['aboveUpperCritical', 'CRITICAL']
],
onoff => [
['unavailable', 'UNKNOWN'],
['on', 'OK'],
['off', 'OK'],
['off', 'OK']
],
contact => [
['unavailable', 'UNKNOWN'],
['open', 'OK'],
['closed', 'OK'],
['closed', 'OK']
],
alarm => [
['unavailable', 'UNKNOWN'],
['normal', 'OK'],
['alarmed', 'CRITICAL'],
['selfTest', 'OK'],
['fail', 'CRITICAL'],
['fail', 'CRITICAL']
],
fault => [
['unavailable', 'UNKNOWN'],
['ok', 'OK'],
['fault', 'CRITICAL'],
['fault', 'CRITICAL']
],
powerQuality => [
['unavailable', 'UNKNOWN'],
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['critical', 'CRITICAL']
],
inletPhaseSync => [
['unavailable', 'UNKNOWN'],
['inSync', 'OK'],
['outOfSync', 'CRITICAL'],
['outOfSync', 'CRITICAL']
],
operatingState => [
['unavailable', 'UNKNOWN'],
['normal', 'OK'],
['standby', 'OK'],
['off', 'CRITICAL'],
['off', 'CRITICAL']
],
activeInlet => [
['unavailable', 'UNKNOWN'],
['one', 'OK'],
['two', 'OK'],
['none', 'WARNING'],
['none', 'WARNING']
],
motionDetection => [
['unavailable', 'UNKNOWN'],
['unavailable', 'UNKNOWN']
],
switchStatus => [
['unavailable', 'UNKNOWN'],
@ -243,8 +257,8 @@ $thresholds = {
['i1OpenFault', 'WARNING'],
['i1ShortFault', 'WARNING'],
['i2OpenFault', 'WARNING'],
['i2ShortFault', 'WARNING'],
],
['i2ShortFault', 'WARNING']
]
};
1;

View File

@ -42,22 +42,38 @@ sub load {
sub check {
my ($self, %options) = @_;
foreach my $component (sort keys %raritan_type) {
my $long_msg = 0;
next if ($component !~ /$options{component}/);
$self->{components}->{$component} = {name => $component, total => 0, skip => 0};
$self->{components}->{$component} = { name => $component, total => 0, skip => 0 };
next if ($self->check_filter(section => $component));
my $instance_type = $raritan_type{$component};
my $value_type = $map_type{$instance_type};
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}})) {
next if ($oid !~ /^$mapping->{$options{type}}->{State}->{oid}\.(\d+)\.(\d+)\.$instance_type$/);
my $instance = $1 . '.' . $2 . '.' . $instance_type;
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$options{type}}, results => $self->{results}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping->{$options{type} . '_label'}, results => $self->{results}, instance => $1 . '.' . $2);
$instance = defined($result2->{Label}) && $result2->{Label} ne '' ? $result2->{Label} : $1 . '.' . $2;
my ($pduId, $fullSensorId, $result);
if ($options{type} eq 'external') {
next if ($oid !~ /^$mapping->{ $options{type} }->{State}->{oid}\./);
$oid =~ /^$mapping->{ $options{type} }->{State}->{oid}\.(\d+)\.(\d+)$/;
$pduId = $1;
$fullSensorId = $1 . '.' . $2;
next if ($self->{externalSensorType}->{$fullSensorId} != $instance_type);
$result = $self->{snmp}->map_instance(mapping => $mapping->{$options{type}}, results => $self->{results}, instance => $fullSensorId);
} else {
next if ($oid !~ /^$mapping->{ $options{type} }->{State}->{oid}\.(\d+)\.(\d+)\.$instance_type$/);
$pduId = $1;
$fullSensorId = $1 . '.' . $2;
my $fullInstanceId = $1 . '.' . $2 . '.' . $instance_type;
$result = $self->{snmp}->map_instance(mapping => $mapping->{$options{type}}, results => $self->{results}, instance => $fullInstanceId);
}
my $pduName = $self->{pduNames}->{$pduId};
my $result2 = $self->{snmp}->map_instance(mapping => $mapping->{$options{type} . '_label'}, results => $self->{results}, instance => $fullSensorId);
my $instance = defined($result2->{Label}) && $result2->{Label} ne '' ? $result2->{Label} : $fullSensorId;
next if ($self->check_filter(section => $component, instance => $instance));
@ -74,9 +90,15 @@ sub check {
}
$self->{output}->output_add(
long_msg => sprintf(
"'%s' %s state is '%s' [instance: %s, value: %s, unit: %s, label: %s]",
$instance, $component, $result->{State},
$instance, $value, $result->{Unit}->{unit}, $result2->{Label}
"'%s' %s state is '%s' [instance: %s, value: %s, unit: %s, label: %s, pdu: %s]",
$instance,
$component,
$result->{State},
$instance,
$value,
$result->{Unit}->{unit},
$result2->{Label},
$pduName
)
);
my $exit = $self->get_severity(
@ -93,55 +115,56 @@ sub check {
);
}
if ($value =~ /[0-9]/) {
next if ($value =~ /^0$/ && $result->{Unit}->{unit} eq '');
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $component, instance => $instance, value => $value);
if ($checked == 0) {
$result->{EnabledThresholds} = oct("0b". unpack('b*', $result->{EnabledThresholds}));
my $warn_th;
$warn_th = ($result->{LowerWarningThreshold} * 10 ** -int($result->{Decimal})) . ':' if (($result->{EnabledThresholds} & (1 << 1)));
if (($result->{EnabledThresholds} & (1 << 2))) {
if (defined($warn_th)) {
$warn_th .= ($result->{UpperWarningThreshold} * 10 ** -int($result->{Decimal}));
} else {
$warn_th = '~:' . ($result->{UpperWarningThreshold} * 10 ** -int($result->{Decimal}));
}
}
my $crit_th;
$crit_th = ($result->{LowerCriticalThreshold} * 10 ** -int($result->{Decimal})) . ':' if (($result->{EnabledThresholds} & (1 << 0)));
if (($result->{EnabledThresholds} & (1 << 3))) {
if (defined($crit_th)) {
$crit_th .= ($result->{UpperCriticalThreshold} * 10 ** -int($result->{Decimal}));
} else {
$crit_th = '~:' . ($result->{UpperCriticalThreshold} * 10 ** -int($result->{Decimal}));
}
}
$self->{perfdata}->threshold_validate(label => 'warning-' . $component . '-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-' . $component . '-instance-' . $instance, value => $crit_th);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $component . '-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $component . '-instance-' . $instance);
}
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf(
"'%s' %s value is %s %s",
$instance, $component, $value, $result->{Unit}->{unit}
)
);
}
next if ($value !~ /[0-9]/);
next if ($value =~ /^0$/ && $result->{Unit}->{unit} eq '');
my $nunit = (defined($result->{Unit}->{nunit}) ? $result->{Unit}->{nunit} : lc($result->{Unit}->{unit}));
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $component, instance => $instance, value => $value);
if ($checked == 0) {
$result->{EnabledThresholds} = oct('0b'. unpack('b*', $result->{EnabledThresholds}));
my $warn_th;
$warn_th = ($result->{LowerWarningThreshold} * 10 ** -int($result->{Decimal})) . ':' if (($result->{EnabledThresholds} & (1 << 1)));
if (($result->{EnabledThresholds} & (1 << 2))) {
if (defined($warn_th)) {
$warn_th .= ($result->{UpperWarningThreshold} * 10 ** -int($result->{Decimal}));
} else {
$warn_th = '~:' . ($result->{UpperWarningThreshold} * 10 ** -int($result->{Decimal}));
}
}
my $crit_th;
$crit_th = ($result->{LowerCriticalThreshold} * 10 ** -int($result->{Decimal})) . ':' if (($result->{EnabledThresholds} & (1 << 0)));
if (($result->{EnabledThresholds} & (1 << 3))) {
if (defined($crit_th)) {
$crit_th .= ($result->{UpperCriticalThreshold} * 10 ** -int($result->{Decimal}));
} else {
$crit_th = '~:' . ($result->{UpperCriticalThreshold} * 10 ** -int($result->{Decimal}));
}
}
$self->{perfdata}->threshold_validate(label => 'warning-' . $component . '-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-' . $component . '-instance-' . $instance, value => $crit_th);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $component . '-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $component . '-instance-' . $instance);
}
$self->{output}->perfdata_add(
label => $component, unit => $result->{Unit}->{unit},
nlabel => 'hardware.sensor.' . $options{type} . '.' . lc($component) . '.' . $nunit,
instances => $instance,
value => $value,
warning => $warn,
critical => $crit
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf(
"'%s' %s value is %s %s",
$instance, $component, $value, $result->{Unit}->{unit}
)
);
}
my $nunit = (defined($result->{Unit}->{nunit}) ? $result->{Unit}->{nunit} : lc($result->{Unit}->{unit}));
$self->{output}->perfdata_add(
nlabel => 'hardware.sensor.' . $options{type} . '.' . lc($component) . '.' . $nunit,
unit => $result->{Unit}->{unit},
instances => [$pduName, $instance],
value => $value,
warning => $warn,
critical => $crit
);
}
}
}

View File

@ -0,0 +1,147 @@
#
# Copyright 2023 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 hardware::pdu::raritan::snmp::mode::externalsensors;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type);
sub set_system {
my ($self, %options) = @_;
$self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = $thresholds;
$self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components';
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
my $oid_pduName = '.1.3.6.1.4.1.13742.6.3.2.2.1.13';
my $snmp_result = $self->{snmp}->get_table(oid => $oid_pduName, return_type => 1);
$self->{pduNames} = {};
foreach (keys %$snmp_result) {
/\.(\d+)$/;
$self->{pduNames}->{$1} = $snmp_result->{$_};
}
my $oid_externalSensorType = '.1.3.6.1.4.1.13742.6.3.6.3.1.2';
$snmp_result = $self->{snmp}->get_table(oid => $oid_externalSensorType, return_type => 1);
$self->{externalSensorType} = {};
foreach (keys %$snmp_result) {
/\.(\d+\.\d+)$/;
$self->{externalSensorType}->{$1} = $snmp_result->{$_};
}
}
sub check_numeric_section_option {
my ($self, %options) = @_;
if (!defined($raritan_type{$options{section}})) {
$self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'.");
$self->{output}->option_exit();
}
}
sub load_components {
my ($self, %options) = @_;
my $mod_name = $self->{components_path} . "::sensor";
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'."
);
my $func = $mod_name->can('load');
$func->($self, type => 'external');
$self->{loaded} = 1;
}
sub exec_components {
my ($self, %options) = @_;
my $mod_name = $self->{components_path} . "::sensor";
my $func = $mod_name->can('check');
$func->($self, component => $self->{option_results}->{component}, type => 'external');
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
1;
__END__
=head1 MODE
Check external sensors.
=over 8
=item B<--component>
Which component to check (Default: '.*').
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=airPressure --filter=rmsVoltage)
Can also exclude specific instance: --filter=rmsVoltage,I1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='powerQuality,CRITICAL,^(?!(normal)$)'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,instance,threshold)
Example: --warning='powerQuality,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,instance,threshold)
Example: --critical='powerQuality,.*,40'
=back
=cut

View File

@ -43,6 +43,14 @@ sub snmp_execute {
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
my $oid_pduName = '.1.3.6.1.4.1.13742.6.3.2.2.1.13';
my $snmp_result = $self->{snmp}->get_table(oid => $oid_pduName, return_type => 1);
$self->{pduNames} = {};
foreach (keys %$snmp_result) {
/\.(\d+)$/;
$self->{pduNames}->{$1} = $snmp_result->{$_};
}
}
sub check_numeric_section_option {
@ -58,8 +66,10 @@ sub load_components {
my ($self, %options) = @_;
my $mod_name = $self->{components_path} . "::sensor";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'."
);
my $func = $mod_name->can('load');
$func->($self, type => 'inlet');
@ -76,12 +86,10 @@ sub exec_components {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {});
return $self;
}
@ -128,4 +136,4 @@ Example: --critical='powerQuality,.*,40'
=back
=cut
=cut

View File

@ -43,6 +43,14 @@ sub snmp_execute {
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
my $oid_pduName = '.1.3.6.1.4.1.13742.6.3.2.2.1.13';
my $snmp_result = $self->{snmp}->get_table(oid => $oid_pduName, return_type => 1);
$self->{pduNames} = {};
foreach (keys %$snmp_result) {
/\.(\d+)$/;
$self->{pduNames}->{$1} = $snmp_result->{$_};
}
}
sub check_numeric_section_option {
@ -58,8 +66,10 @@ sub load_components {
my ($self, %options) = @_;
my $mod_name = $self->{components_path} . "::sensor";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'."
);
my $func = $mod_name->can('load');
$func->($self, type => 'ocprot');
@ -76,11 +86,10 @@ sub exec_components {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
$options{options}->add_options(arguments => {});
return $self;
}

View File

@ -43,6 +43,14 @@ sub snmp_execute {
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
my $oid_pduName = '.1.3.6.1.4.1.13742.6.3.2.2.1.13';
my $snmp_result = $self->{snmp}->get_table(oid => $oid_pduName, return_type => 1);
$self->{pduNames} = {};
foreach (keys %$snmp_result) {
/\.(\d+)$/;
$self->{pduNames}->{$1} = $snmp_result->{$_};
}
}
sub check_numeric_section_option {
@ -58,8 +66,10 @@ sub load_components {
my ($self, %options) = @_;
my $mod_name = $self->{components_path} . "::sensor";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'."
);
my $func = $mod_name->can('load');
$func->($self, type => 'outlet');
@ -76,11 +86,10 @@ sub exec_components {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
$options{options}->add_options(arguments => {});
return $self;
}

View File

@ -29,12 +29,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
$self->{modes} = {
'external-sensors' => 'hardware::pdu::raritan::snmp::mode::externalsensors',
'inlet-sensors' => 'hardware::pdu::raritan::snmp::mode::inletsensors',
'outlet-sensors' => 'hardware::pdu::raritan::snmp::mode::outletsensors',
'ocprot-sensors' => 'hardware::pdu::raritan::snmp::mode::ocprotsensors',
);
'ocprot-sensors' => 'hardware::pdu::raritan::snmp::mode::ocprotsensors'
};
return $self;
}