| 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::cambium::epmp::snmp::mode::license; |
| 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 set_counters { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{maps_counters_type} = [ |
| 33 |
{ name => 'global', type => 0 } |
| 34 |
]; |
| 35 |
|
| 36 |
$self->{maps_counters}->{global} = [ |
| 37 |
{ label => 'status', |
| 38 |
type => 2, |
| 39 |
unknown_default => '%{status} =~ /unknown/i', |
| 40 |
warning_default => '%{status} =~ /validation fail|not provided/i', |
| 41 |
critical_default => '%{status} =~ /not valid/i', |
| 42 |
set => { |
| 43 |
key_values => [ { name => 'status' } ], |
| 44 |
closure_custom_output => $self->can('custom_status_output'), |
| 45 |
closure_custom_perfdata => sub { return 0; }, |
| 46 |
closure_custom_threshold_check => \&catalog_status_threshold_ng |
| 47 |
} |
| 48 |
} |
| 49 |
]; |
| 50 |
} |
| 51 |
|
| 52 |
sub custom_status_output { |
| 53 |
my ($self, %options) = @_; |
| 54 |
|
| 55 |
return 'License status: ' . $self->{result_values}->{status}; |
| 56 |
} |
| 57 |
|
| 58 |
sub new { |
| 59 |
my ($class, %options) = @_; |
| 60 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 61 |
bless $self, $class; |
| 62 |
|
| 63 |
$options{options}->add_options(arguments => { |
| 64 |
}); |
| 65 |
|
| 66 |
return $self; |
| 67 |
} |
| 68 |
|
| 69 |
sub check_options { |
| 70 |
my ($self, %options) = @_; |
| 71 |
$self->SUPER::check_options(%options); |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
my $map_status = { |
| 76 |
0 => 'Unknown', |
| 77 |
1 => 'License Valid', |
| 78 |
2 => 'Validation procedure was not provided', |
| 79 |
3 => 'Validation Fail', |
| 80 |
4 => 'License not valid for current device' |
| 81 |
}; |
| 82 |
|
| 83 |
sub manage_selection { |
| 84 |
my ($self, %options) = @_; |
| 85 |
|
| 86 |
my $oid_cambLicenseStatus = '.1.3.6.1.4.1.17713.21.1.8.5.0'; |
| 87 |
|
| 88 |
my $snmp_result = $options{snmp}->get_leef( |
| 89 |
oids => [ $oid_cambLicenseStatus ], |
| 90 |
nothing_quit => 1 |
| 91 |
); |
| 92 |
|
| 93 |
$self->{global} = { |
| 94 |
status => $map_status->{ $snmp_result->{$oid_cambLicenseStatus} } |
| 95 |
}; |
| 96 |
} |
| 97 |
|
| 98 |
1; |
| 99 |
|
| 100 |
__END__ |
| 101 |
|
| 102 |
=head1 MODE |
| 103 |
|
| 104 |
Check Cambium license status. |
| 105 |
|
| 106 |
=over 8 |
| 107 |
|
| 108 |
=item B<--unknown-status> |
| 109 |
|
| 110 |
Define the conditions to match for the status to be UNKNOWN (default: '%{status} =~ /unknown/i'). |
| 111 |
You can use the following variables: %{status} |
| 112 |
|
| 113 |
=item B<--warning-status> |
| 114 |
|
| 115 |
Define the conditions to match for the status to be WARNING (default: '%{status} =~ /validation fail|not provided/i'). |
| 116 |
You can use the following variables: %{status} |
| 117 |
|
| 118 |
=item B<--critical-status> |
| 119 |
|
| 120 |
Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /not valid/i'). |
| 121 |
You can use the following variables: %{status} |
| 122 |
|
| 123 |
=back |
| 124 |
|
| 125 |
=cut |