| 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 network::mikrotik::snmp::mode::components::current; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); |
| 26 |
|
| 27 |
my $mapping = { |
| 28 |
mtxrHlCurrent => { oid => '.1.3.6.1.4.1.14988.1.1.3.13' } |
| 29 |
}; |
| 30 |
|
| 31 |
sub load {} |
| 32 |
|
| 33 |
sub check_current { |
| 34 |
my ($self, %options) = @_; |
| 35 |
|
| 36 |
$self->{output}->output_add( |
| 37 |
long_msg => sprintf( |
| 38 |
"current '%s' is %s A", |
| 39 |
$options{name}, |
| 40 |
$options{value} |
| 41 |
) |
| 42 |
); |
| 43 |
|
| 44 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $options{name}, value => $options{value}); |
| 45 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 46 |
$self->{output}->output_add( |
| 47 |
severity => $exit, |
| 48 |
short_msg => sprintf("Current '%s' is %s A", $options{name}, $options{value}) |
| 49 |
); |
| 50 |
} |
| 51 |
$self->{output}->perfdata_add( |
| 52 |
nlabel => 'hardware.current.ampere', |
| 53 |
unit => 'A', |
| 54 |
instances => $options{name}, |
| 55 |
value => $options{value}, |
| 56 |
warning => $warn, |
| 57 |
critical => $crit |
| 58 |
); |
| 59 |
$self->{components}->{current}->{total}++; |
| 60 |
} |
| 61 |
|
| 62 |
sub check { |
| 63 |
my ($self) = @_; |
| 64 |
|
| 65 |
$self->{output}->output_add(long_msg => "Checking current"); |
| 66 |
$self->{components}->{current} = { name => 'current', total => 0, skip => 0 }; |
| 67 |
return if ($self->check_filter(section => 'current')); |
| 68 |
|
| 69 |
foreach (keys %{$self->{results}}) { |
| 70 |
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); |
| 71 |
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dA'); |
| 72 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); |
| 73 |
next if ($self->check_filter(section => 'current', instance => $result->{name})); |
| 74 |
check_current( |
| 75 |
$self, |
| 76 |
value => $result->{value} / 10, |
| 77 |
name => $result->{name} |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); |
| 82 |
if (defined($result->{mtxrHlCurrent}) && ! $self->check_filter(section => 'current', instance => 'system')) { |
| 83 |
check_current( |
| 84 |
$self, |
| 85 |
value => $result->{mtxrHlCurrent} / 1000, |
| 86 |
name => 'system' |
| 87 |
); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
1; |