| 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 centreon::common::violin::snmp::mode::components::psu; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my $oid_chassisSystemPowerPSUA = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.17'; |
| 29 |
my $oid_chassisSystemPowerPSUB = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.18'; |
| 30 |
|
| 31 |
sub load { |
| 32 |
my ($self) = @_; |
| 33 |
|
| 34 |
push @{$self->{request}}, { oid => $oid_chassisSystemPowerPSUA }, { oid => $oid_chassisSystemPowerPSUB }; |
| 35 |
} |
| 36 |
|
| 37 |
sub psu { |
| 38 |
my ($self, %options) = @_; |
| 39 |
my $oid = $options{oid}; |
| 40 |
|
| 41 |
$options{oid} =~ /^$options{oid_short}\.(.*)$/; |
| 42 |
my ($dummy, $array_name) = $self->convert_index(value => $1); |
| 43 |
my $instance = $array_name . '-' . $options{extra_instance}; |
| 44 |
|
| 45 |
my $psu_state = $options{value}; |
| 46 |
|
| 47 |
return if ($self->check_filter(section => 'psu', instance => $instance)); |
| 48 |
return if ($psu_state =~ /Absent/i && |
| 49 |
$self->absent_problem(section => 'psu', instance => $instance)); |
| 50 |
|
| 51 |
$self->{components}->{psu}->{total}++; |
| 52 |
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.", |
| 53 |
$instance, $psu_state)); |
| 54 |
my $exit = $self->get_severity(section => 'psu', value => $psu_state); |
| 55 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 56 |
$self->{output}->output_add(severity => $exit, |
| 57 |
short_msg => sprintf("Power Supply '%s' status is %s", $instance, $psu_state)); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
sub check { |
| 62 |
my ($self) = @_; |
| 63 |
|
| 64 |
$self->{output}->output_add(long_msg => "Checking power supplies"); |
| 65 |
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; |
| 66 |
return if ($self->check_filter(section => 'psu')); |
| 67 |
|
| 68 |
foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemPowerPSUA}}) { |
| 69 |
psu($self, oid => $oid, oid_short => $oid_chassisSystemPowerPSUA, value => $self->{results}->{$oid_chassisSystemPowerPSUA}->{$oid}, |
| 70 |
extra_instance => 'A'); |
| 71 |
} |
| 72 |
foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemPowerPSUB}}) { |
| 73 |
psu($self, oid => $oid, oid_short => $oid_chassisSystemPowerPSUB, value => $self->{results}->{$oid_chassisSystemPowerPSUB}->{$oid}, |
| 74 |
extra_instance => 'B'); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
1; |