| 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::firmware; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); |
| 28 |
|
| 29 |
sub custom_status_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
return sprintf( |
| 33 |
"'%s': software is '%s', firmware is '%s'", |
| 34 |
$self->{result_values}->{model}, |
| 35 |
$self->{result_values}->{software_version}, |
| 36 |
$self->{result_values}->{firmware_version} |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
sub set_counters { |
| 41 |
my ($self, %options) = @_; |
| 42 |
|
| 43 |
$self->{maps_counters_type} = [ |
| 44 |
{ name => 'global', type => 0 } |
| 45 |
]; |
| 46 |
|
| 47 |
$self->{maps_counters}->{global} = [ |
| 48 |
{ label => 'status', type => 2, warning_default => '%{firmware_version} ne %{software_version}', set => { |
| 49 |
key_values => [ |
| 50 |
{ name => 'model' }, { name => 'software_version' }, |
| 51 |
{ name => 'firmware_version' }, { name => 'firmware_version_update' } |
| 52 |
], |
| 53 |
closure_custom_output => $self->can('custom_status_output'), |
| 54 |
closure_custom_perfdata => sub { return 0; }, |
| 55 |
closure_custom_threshold_check => \&catalog_status_threshold_ng |
| 56 |
} |
| 57 |
} |
| 58 |
]; |
| 59 |
} |
| 60 |
|
| 61 |
sub new { |
| 62 |
my ($class, %options) = @_; |
| 63 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 64 |
bless $self, $class; |
| 65 |
|
| 66 |
$options{options}->add_options(arguments => { |
| 67 |
}); |
| 68 |
|
| 69 |
return $self; |
| 70 |
} |
| 71 |
|
| 72 |
my $mapping = { |
| 73 |
model => { oid => '.1.3.6.1.2.1.1.1' }, # sysDescr |
| 74 |
software_version => { oid => '.1.3.6.1.4.1.14988.1.1.4.4' }, # mtxrLicVersion |
| 75 |
firmware_version => { oid => '.1.3.6.1.4.1.14988.1.1.7.4' }, # mtxrFirmwareVersion |
| 76 |
firmware_version_update => { oid => '.1.3.6.1.4.1.14988.1.1.7.7' } # mtxrFirmwareUpgradeVersion |
| 77 |
}; |
| 78 |
|
| 79 |
sub manage_selection { |
| 80 |
my ($self, %options) = @_; |
| 81 |
|
| 82 |
my $snmp_result = $options{snmp}->get_leef( |
| 83 |
oids => [ map($_->{oid} . '.0', values(%$mapping)) ], |
| 84 |
nothing_quit => 1 |
| 85 |
); |
| 86 |
$self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); |
| 87 |
$self->{global}->{firmware_version} = 'n/a' if (!defined($self->{global}->{firmware_version})); |
| 88 |
$self->{global}->{firmware_version_update} = 'n/a' if (!defined($self->{global}->{firmware_version_update})); |
| 89 |
} |
| 90 |
|
| 91 |
1; |
| 92 |
|
| 93 |
__END__ |
| 94 |
|
| 95 |
=head1 MODE |
| 96 |
|
| 97 |
Check firmware status. |
| 98 |
|
| 99 |
=over 8 |
| 100 |
|
| 101 |
=item B<--warning-status> |
| 102 |
|
| 103 |
Define the conditions to match for the status to be WARNING (default : '%{firmware_version} ne %{software_version}'). |
| 104 |
You can use the following variables: %{model}, %{software_version}, %{firmware_version}, %{firmware_version_update} |
| 105 |
|
| 106 |
=item B<--critical-status> |
| 107 |
|
| 108 |
Define the conditions to match for the status to be CRITICAL. |
| 109 |
You can use the following variables: %{model}, %{software_version}, %{firmware_version}, %{firmware_version_update} |
| 110 |
|
| 111 |
=back |
| 112 |
|
| 113 |
=cut |