| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::ups::mge::snmp::mode::outputsource; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my $oid_upsmgOutput = '.1.3.6.1.4.1.705.1.7'; |
| 29 |
my $oid_upsmgOutputOnBatteryEntry = '.1.3.6.1.4.1.705.1.7.3'; |
| 30 |
|
| 31 |
my %map_output_status = ( |
| 32 |
'.1.3.6.1.4.1.705.1.7.3.0' => 'OutputOnBattery', |
| 33 |
'.1.3.6.1.4.1.705.1.7.4.0' => 'OutputOnByPass', |
| 34 |
'.1.3.6.1.4.1.705.1.7.5.0' => 'OutputUnavailableByPass', |
| 35 |
'.1.3.6.1.4.1.705.1.7.6.0' => 'OutputNoByPass', |
| 36 |
'.1.3.6.1.4.1.705.1.7.7.0' => 'OutputUtilityOff', |
| 37 |
'.1.3.6.1.4.1.705.1.7.8.0' => 'OutputOnBoost', |
| 38 |
'.1.3.6.1.4.1.705.1.7.9.0' => 'OutputInverterOff', |
| 39 |
'.1.3.6.1.4.1.705.1.7.10.0' => 'OutputOverLoad', |
| 40 |
'.1.3.6.1.4.1.705.1.7.11.0' => 'OutputOverTemp', |
| 41 |
'.1.3.6.1.4.1.705.1.7.12.0' => 'OutputOnBuck', |
| 42 |
); |
| 43 |
|
| 44 |
sub new { |
| 45 |
my ($class, %options) = @_; |
| 46 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 47 |
bless $self, $class; |
| 48 |
|
| 49 |
$options{options}->add_options(arguments => |
| 50 |
{ |
| 51 |
"filter-status:s" => { name => 'filter_status', default => '^OutputInverterOff'}, |
| 52 |
}); |
| 53 |
|
| 54 |
return $self; |
| 55 |
} |
| 56 |
|
| 57 |
sub check_options { |
| 58 |
my ($self, %options) = @_; |
| 59 |
$self->SUPER::init(%options); |
| 60 |
} |
| 61 |
|
| 62 |
sub run { |
| 63 |
my ($self, %options) = @_; |
| 64 |
$self->{snmp} = $options{snmp}; |
| 65 |
|
| 66 |
my $result = $self->{snmp}->get_table(oid => $oid_upsmgOutput, start => $oid_upsmgOutputOnBatteryEntry, nothing_quit => 1); |
| 67 |
$self->{output}->output_add(severity => 'OK', |
| 68 |
short_msg => sprintf("Output status is ok")); |
| 69 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %map_output_status)) { |
| 70 |
next if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' && $map_output_status{$oid} =~ /$self->{option_results}->{filter_status}/); |
| 71 |
if (defined($result->{$oid}) && $result->{$oid} == 1) { |
| 72 |
$self->{output}->output_add(severity => 'CRITICAL', |
| 73 |
short_msg => sprintf("Output status is '%s'", $map_output_status{$oid})); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
$self->{output}->display(); |
| 78 |
$self->{output}->exit(); |
| 79 |
} |
| 80 |
|
| 81 |
1; |
| 82 |
|
| 83 |
__END__ |
| 84 |
|
| 85 |
=head1 MODE |
| 86 |
|
| 87 |
Check output source status. |
| 88 |
|
| 89 |
=over 8 |
| 90 |
|
| 91 |
=item B<--filter-status> |
| 92 |
|
| 93 |
Filter on status. (can be a regexp) |
| 94 |
Default: ^OutputInverterOff |
| 95 |
|
| 96 |
=back |
| 97 |
|
| 98 |
=cut |