This commit is contained in:
garnier-quentin 2019-12-26 10:43:52 +01:00
parent b3c128a071
commit fd90ccb74c
7 changed files with 752 additions and 16 deletions

View File

@ -147,7 +147,7 @@ sub new {
$thlabel = $self->get_threshold_prefix(name => $key) . $label;
}
$thlabel =~ s/\./-/g;
if (!defined($_->{threshold}) || $_->{threshold} != 0) {
$options{options}->add_options(arguments => {
'warning-' . $thlabel . ':s' => { name => 'warning-' . $thlabel },

View File

@ -109,13 +109,12 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"unknown-status:s" => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /batteryLow/i' },
"critical-status:s" => { name => 'critical_status', default => '%{replace} =~ /yes/i' },
});
$options{options}->add_options(arguments => {
'unknown-status:s' => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /batteryLow/i' },
'critical-status:s' => { name => 'critical_status', default => '%{replace} =~ /yes/i' },
});
return $self;
}
@ -191,7 +190,7 @@ Example: --filter-counters='^status|load$'
=item B<--unknown-status>
Set warning threshold for status (Default: '%{status} =~ /unknown/i').
Set unknown threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{status}, %{replace}
=item B<--warning-status>
@ -204,14 +203,9 @@ Can used special variables like: %{status}, %{replace}
Set critical threshold for status (Default: '%{replace} =~ /yes/i').
Can used special variables like: %{status}, %{replace}
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: 'load', 'voltage', 'current', 'temperature', 'time'.
=item B<--critical-*>
Threshold critical.
Thresholds.
Can be: 'load', 'voltage', 'current', 'temperature', 'time'.
=back

View File

@ -0,0 +1,177 @@
#
# Copyright 2019 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::ups::hp::snmp::mode::batterystatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("battery status is '%s'", $self->{result_values}->{status});
return $msg;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{global} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' } ],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'charge-remaining', , nlabel => 'battery.charge.remaining.percent', set => {
key_values => [ { name => 'upsBatCapacity' } ],
output_template => 'remaining capacity: %s %%',
perfdatas => [
{ value => 'upsBatCapacity_absolute', template => '%s', min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'charge-remaining-minutes', nlabel => 'battery.charge.remaining.minutes', display_ok => 0, set => {
key_values => [ { name => 'upsBatTimeRemaining' } ],
output_template => 'remaining time: %s minutes',
perfdatas => [
{ value => 'upsBatTimeRemaining_absolute', template => '%s', min => 0, unit => 'm' },
],
}
},
{ label => 'current', nlabel => 'battery.current.ampere', display_ok => 0, set => {
key_values => [ { name => 'upsBatCurrent', no_value => 0 } ],
output_template => 'current: %s A',
perfdatas => [
{ value => 'upsBatCurrent_absolute', template => '%s', unit => 'A' },
],
}
},
{ label => 'voltage', nlabel => 'battery.voltage.volt', display_ok => 0, set => {
key_values => [ { name => 'upsBatVoltage', no_value => 0 } ],
output_template => 'voltage: %s V',
perfdatas => [
{ value => 'upsBatVoltage_absolute', template => '%s', unit => 'V' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'unknown-status:s' => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /batteryDischarging/i' },
'critical-status:s' => { name => 'critical_status', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
}
my $map_battery_status = {
1 => 'batteryCharging', 2 => 'batteryDischarging',
3 => 'batteryFloating', 4 => 'batteryResting',
5 => 'unknown',
};
my $mapping = {
upsBatTimeRemaining => { oid => '.1.3.6.1.4.1.232.165.3.2.1' }, # in seconds
upsBatVoltage => { oid => '.1.3.6.1.4.1.232.165.3.2.2' }, # in dV
upsBatCurrent => { oid => '.1.3.6.1.4.1.232.165.3.2.3' }, # in dA
upsBatCapacity => { oid => '.1.3.6.1.4.1.232.165.3.2.4' },
upsBatteryAbmStatus => { oid => '.1.3.6.1.4.1.232.165.3.2.5', map => $map_battery_status },
};
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
$result->{upsBatCurrent} = defined($result->{upsBatCurrent}) ? $result->{upsBatCurrent} * 0.1 : 0;
$result->{upsBatVoltage} = defined($result->{upsBatVoltage}) ? $result->{upsBatVoltage} * 0.1 : 0;
$result->{upsBatTimeRemaining} = defined($result->{upsBatTimeRemaining}) ? int($result->{upsBatTimeRemaining} / 60) : undef;
$result->{status} = $result->{upsBatteryAbmStatus};
$self->{global} = $result;
}
1;
__END__
=head1 MODE
Check battery status.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='status|current'
=item B<--unknown-status>
Set unknown threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{status}.
=item B<--warning-status>
Set warning threshold for status (Default: '%{status} =~ /batteryDischarging/i').
Can used special variables like: %{status}.
=item B<--critical-status>
Set critical threshold for status (Default: '').
Can used special variables like: %{status}.
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: Can be: 'charge-remaining' (%), 'charge-remaining-minutes',
'current' (A), 'voltage' (V).
=back
=cut

View File

@ -0,0 +1,127 @@
#
# Copyright 2019 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::ups::hp::snmp::mode::environment;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{global} = [
{ label => 'temperature', nlabel => 'environment.ambient.temperature.celsius', set => {
key_values => [ { name => 'temperature' } ],
output_template => 'ambient temperature: %.2f C',
perfdatas => [
{ value => 'temperature_absolute', template => '%.2f',
min => 0, unit => 'C' },
],
}
},
{ label => 'humidity', nlabel => 'environment.humidity.percentage', set => {
key_values => [ { name => 'humidity' } ],
output_template => 'humidity: %.2f %%',
perfdatas => [
{ value => 'humidity_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oids = {
upsEnvAmbientTemp => '.1.3.6.1.4.1.232.165.3.6.1.0',
upsEnvAmbientLowerLimit => '.1.3.6.1.4.1.232.165.3.6.2.0',
upsEnvAmbientUpperLimit => '.1.3.6.1.4.1.232.165.3.6.3.0',
upsEnvAmbientHumidity => '.1.3.6.1.4.1.232.165.3.6.4.0',
upsEnvRemoteTemp => '.1.3.6.1.4.1.232.165.3.6.5.0',
upsEnvRemoteHumidity => '.1.3.6.1.4.1.232.165.3.6.6.0',
upsEnvRemoteTempLowerLimit => '.1.3.6.1.4.1.232.165.3.6.9.0',
upsEnvRemoteTempUpperLimit => '.1.3.6.1.4.1.232.165.3.6.10.0',
upsEnvRemoteHumidityLowerLimit => '.1.3.6.1.4.1.232.165.3.6.11.0',
upsEnvRemoteHumidityUpperLimit => '.1.3.6.1.4.1.232.165.3.6.12.0',
};
my $snmp_result = $options{snmp}->get_leef(
oids => [ values %$oids ],
nothing_quit => 1
);
$self->{global} = {};
$self->{global}->{temperature} = defined($snmp_result->{$oids->{upsEnvAmbientTemp}}) && $snmp_result->{$oids->{upsEnvAmbientTemp}} ne '' && $snmp_result->{$oids->{upsEnvAmbientTemp}} != 0 ?
$snmp_result->{$oids->{upsEnvAmbientTemp}} :
(defined($snmp_result->{$oids->{upsEnvRemoteTemp}}) && $snmp_result->{$oids->{upsEnvRemoteTemp}} ne '' && $snmp_result->{$oids->{upsEnvRemoteTemp}} != 0 ?
$snmp_result->{$oids->{upsEnvRemoteTemp}} : undef);
$self->{global}->{humidity} = defined($snmp_result->{$oids->{upsEnvAmbientHumidity}}) && $snmp_result->{$oids->{upsEnvAmbientHumidity}} ne '' && $snmp_result->{$oids->{upsEnvAmbientHumidity}} != 0 ?
$snmp_result->{$oids->{upsEnvAmbientHumidity}} :
(defined($snmp_result->{$oids->{upsEnvRemoteHumidity}}) && $snmp_result->{$oids->{upsEnvRemoteHumidity}} ne '' && $snmp_result->{$oids->{upsEnvRemoteHumidity}} != 0 ?
$snmp_result->{$oids->{upsEnvRemoteHumidity}} : undef);
if (!defined($self->{option_results}->{'critical-environment-ambient-temperature-celsius'}) || $self->{option_results}->{'critical-environment-ambient-temperature-celsius'} eq '') {
my $crit_val = '';
$crit_val = $snmp_result->{$oids->{upsEnvAmbientLowerLimit}} . ':'
if (defined($snmp_result->{$oids->{upsEnvAmbientLowerLimit}}) &&
$snmp_result->{$oids->{upsEnvAmbientLowerLimit}} ne '' && $snmp_result->{$oids->{upsEnvAmbientLowerLimit}} != 0);
$crit_val .= $snmp_result->{$oids->{upsEnvAmbientUpperLimit}}
if (defined($snmp_result->{$oids->{upsEnvAmbientUpperLimit}}) &&
$snmp_result->{$oids->{upsEnvAmbientUpperLimit}} ne '' && $snmp_result->{$oids->{upsEnvAmbientUpperLimit}} != 0);
$self->{perfdata}->threshold_validate(label => 'critical-environment-ambient-temperature-celsius', value => $crit_val);
}
}
1;
__END__
=head1 MODE
Check environment.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'temperature', 'humidity'.
=back
=cut

View File

@ -0,0 +1,173 @@
#
# Copyright 2019 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::ups::hp::snmp::mode::inputlines;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
{ name => 'iline', type => 1, cb_prefix_output => 'prefix_iline_output', message_multiple => 'All input lines are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{global} = [
{ label => 'frequence', nlabel => 'lines.input.frequence.hertz', set => {
key_values => [ { name => 'upsInputFrequency', no_value => 0 } ],
output_template => 'frequence: %.2f Hz',
perfdatas => [
{ value => 'upsInputFrequency_absolute', template => '%.2f',
unit => 'Hz' },
],
}
},
];
$self->{maps_counters}->{iline} = [
{ label => 'current', nlabel => 'line.input.current.ampere', set => {
key_values => [ { name => 'upsInputCurrent', no_value => 0 } ],
output_template => 'current: %.2f A',
perfdatas => [
{ value => 'upsInputCurrent_absolute', template => '%.2f',
min => 0, unit => 'A', label_extra_instance => 1 },
],
}
},
{ label => 'voltage', nlabel => 'line.input.voltage.volt', set => {
key_values => [ { name => 'upsInputVoltage', no_value => 0 } ],
output_template => 'voltage: %s V',
perfdatas => [
{ value => 'upsInputVoltage_absolute', template => '%s',
unit => 'V', label_extra_instance => 1 },
],
}
},
{ label => 'power', nlabel => 'line.input.power.watt', set => {
key_values => [ { name => 'upsInputWatts', no_value => 0 } ],
output_template => 'power: %s W',
perfdatas => [
{ value => 'upsInputWatts_absolute', template => '%s',
unit => 'W', label_extra_instance => 1 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
sub prefix_iline_output {
my ($self, %options) = @_;
return "Input Line '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
upsInputVoltage => { oid => '.1.3.6.1.4.1.232.165.3.3.4.1.2' }, # in V
upsInputCurrent => { oid => '.1.3.6.1.4.1.232.165.3.3.4.1.3' }, # in A
upsInputWatts => { oid => '.1.3.6.1.4.1.232.165.3.3.4.1.4' }, # in W
};
my $mapping2 = {
upsInputFrequency => { oid => '.1.3.6.1.4.1.232.165.3.3.1' }, # in dHZ
};
my $mapping3 = {
upsConfigLowOutputVoltageLimit => { oid => '.1.3.6.1.4.1.232.165.3.9.6' },
upsConfigHighOutputVoltageLimit => { oid => '.1.3.6.1.4.1.232.165.3.9.7' },
};
my $oid_upsInputEntry = '.1.3.6.1.4.1.232.165.3.3.4.1';
my $oid_upsConfig = '.1.3.6.1.4.1.232.165.3.9';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $mapping2->{upsInputFrequency}->{oid} },
{ oid => $oid_upsInputEntry },
{ oid => $oid_upsConfig, start => $mapping3->{upsConfigLowOutputVoltageLimit}->{oid}, end => $mapping3->{upsConfigHighOutputVoltageLimit}->{oid} },
],
return_type => 1,
nothing_quit => 1
);
$self->{iline} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$oid_upsInputEntry\.\d+\.(.*)$/);
my $instance = $1;
next if (defined($self->{iline}->{$instance}));
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$result->{upsInputCurrent} = 0 if (defined($result->{upsInputCurrent}) && $result->{upsInputCurrent} eq '');
$self->{iline}->{$instance} = { display => $instance, %$result };
}
if (scalar(keys %{$self->{iline}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No input lines found.");
$self->{output}->option_exit();
}
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => '0');
$result->{upsInputFrequency} = defined($result->{upsInputFrequency}) ? ($result->{upsInputFrequency} * 0.1) : 0;
$self->{global} = { %$result };
$result = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result, instance => '0');
if ((!defined($self->{option_results}->{'warning-instance-line-input-voltage-volt'}) || $self->{option_results}->{'warning-instance-line-input-voltage-volt'} eq '') &&
(!defined($self->{option_results}->{'critical-instance-line-input-voltage-volt'}) || $self->{option_results}->{'critical-instance-line-input-voltage-volt'} eq '')
) {
my $th = '';
$th .= $result->{upsConfigHighOutputVoltageLimit} if (defined($result->{upsConfigHighOutputVoltageLimit}) && $result->{upsConfigHighOutputVoltageLimit} =~ /\d+/);
$th = $result->{upsConfigLowOutputVoltageLimit} . ':' . $th if (defined($result->{upsConfigLowOutputVoltageLimit}) && $result->{upsConfigLowOutputVoltageLimit} =~ /\d+/);
$self->{perfdata}->threshold_validate(label => 'critical-instance-line-input-voltage-volt', value => $th) if ($th ne '');
}
}
1;
__END__
=head1 MODE
Check input lines metrics.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'frequence', 'voltage', 'current', 'power'.
=back
=cut

View File

@ -0,0 +1,213 @@
#
# Copyright 2019 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::ups::hp::snmp::mode::outputlines;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
sub custom_source_output {
my ($self, %options) = @_;
return sprintf("output source is '%s'", $self->{result_values}->{source});
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
{ name => 'oline', type => 1, cb_prefix_output => 'prefix_oline_output', message_multiple => 'All output lines are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{global} = [
{ label => 'source', threshold => 0, set => {
key_values => [ { name => 'source' } ],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_source_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'load', nlabel => 'lines.output.load.percentage', set => {
key_values => [ { name => 'upsOutputLoad', no_value => -1 } ],
output_template => 'load: %.2f %%',
perfdatas => [
{ value => 'upsOutputLoad_absolute', template => '%.2f', min => 0, max => 100 },
],
}
},
{ label => 'frequence', nlabel => 'lines.output.frequence.hertz', set => {
key_values => [ { name => 'upsOutputFrequency', no_value => 0 } ],
output_template => 'frequence: %.2f Hz',
perfdatas => [
{ value => 'upsOutputFrequency_absolute', template => '%.2f', unit => 'Hz' },
],
}
},
];
$self->{maps_counters}->{oline} = [
{ label => 'current', nlabel => 'line.output.current.ampere', set => {
key_values => [ { name => 'upsOutputCurrent', no_value => 0 } ],
output_template => 'current: %.2f A',
perfdatas => [
{ value => 'upsOutputCurrent_absolute', template => '%.2f',
min => 0, unit => 'A', label_extra_instance => 1 },
],
}
},
{ label => 'voltage', nlabel => 'line.output.voltage.volt', set => {
key_values => [ { name => 'upsOutputVoltage', no_value => 0 } ],
output_template => 'Voltage: %s V',
perfdatas => [
{ value => 'upsOutputVoltage_absolute', template => '%s',
unit => 'V', label_extra_instance => 1 },
],
}
},
{ label => 'power', nlabel => 'line.output.power.watt', set => {
key_values => [ { name => 'upsOutputWatts', no_value => 0 } ],
output_template => 'power: %s W',
perfdatas => [
{ value => 'upsOutputWatts_absolute', template => '%s',
unit => 'W', label_extra_instance => 1 },
],
}
},
];
}
sub prefix_oline_output {
my ($self, %options) = @_;
return "Output line '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'unknown-source:s' => { name => 'unknown_source', default => '' },
'warning-source:s' => { name => 'warning_source', default => '' },
'critical-source:s' => { name => 'critical_source', default => '%{source} !~ /normal/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_source', 'critical_source', 'unknown_source']);
}
my $map_source = {
1 => 'other', 2 => 'none', 3 => 'normal',
4 => 'bypass', 5 => 'battery', 6 => 'booster',
7 => 'reducer', 8 => 'parallelCapacity',
9 => 'parallelRedundant', 10 => 'highEfficiencyMode',
};
my $mapping = {
upsOutputVoltage => { oid => '.1.3.6.1.4.1.232.165.3.4.4.1.2' }, # in V
upsOutputCurrent => { oid => '.1.3.6.1.4.1.232.165.3.4.4.1.3' }, # in A
upsOutputWatts => { oid => '.1.3.6.1.4.1.232.165.3.4.4.1.4' }, # in W
};
my $mapping2 = {
upsOutputLoad => { oid => '.1.3.6.1.4.1.232.165.3.4.1' }, # in %
upsOutputFrequency => { oid => '.1.3.6.1.4.1.232.165.3.4.2' }, # in dHZ
upsOutputSource => { oid => '.1.3.6.1.4.1.232.165.3.4.5', map => $map_source },
};
my $oid_upsOutput = '.1.3.6.1.4.1.232.165.3.4';
my $oid_upsOutputEntry = '.1.3.6.1.4.1.232.165.3.4.4.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{oline} = {};
my $snmp_result = $options{snmp}->get_table(
oid => $oid_upsOutput,
nothing_quit => 1
);
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$oid_upsOutputEntry\.\d+\.(.*)$/);
my $instance = $1;
next if (defined($self->{oline}->{$instance}));
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{oline}->{$instance} = { display => $instance, %$result };
}
if (scalar(keys %{$self->{oline}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No output lines found.");
$self->{output}->option_exit();
}
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => '0');
$result->{upsOutputFrequency} = defined($result->{upsOutputFrequency}) ? ($result->{upsOutputFrequency} * 0.1) : 0;
$result->{upsOutputLoad} = defined($result->{upsOutputLoad}) ? $result->{upsOutputLoad} : -1;
$result->{source} = $result->{upsOutputSource};
$self->{global} = $result;
}
1;
__END__
=head1 MODE
Check output lines metrics.
=over 8
=item B<--unknown-source>
Set unknown threshold for status (Default: '').
Can used special variables like: %{status}.
=item B<--warning-source>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}.
=item B<--critical-source>
Set critical threshold for status (Default: '%{source} !~ /normal/i').
Can used special variables like: %{status}.
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'load', 'voltage', 'current', 'power'.
=back
=cut

View File

@ -0,0 +1,52 @@
#
# Copyright 2019 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::ups::hp::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'battery-status' => 'hardware::ups::hp::snmp::mode::batterystatus',
'environment' => 'hardware::ups::hp::snmp::mode::environment',
'input-lines' => 'hardware::ups::hp::snmp::mode::inputlines',
'uptime' => 'snmp_standard::mode::uptime',
'output-lines' => 'hardware::ups::hp::snmp::mode::outputlines',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check HP UPS in SNMP.
=cut