| 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::devices::camera::avigilon::snmp::mode::memory; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub custom_memory_output { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); |
| 32 |
|
| 33 |
return sprintf( |
| 34 |
'total system memory available: %s', |
| 35 |
$total_value . " " . $total_unit |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
sub set_counters { |
| 40 |
my ($self, %options) = @_; |
| 41 |
|
| 42 |
$self->{maps_counters_type} = [ |
| 43 |
{ name => 'memory', type => 0 } |
| 44 |
]; |
| 45 |
|
| 46 |
$self->{maps_counters}->{memory} = [ |
| 47 |
{ label => 'available', nlabel => 'memory.available', set => { |
| 48 |
key_values => [{ name => 'total' }], |
| 49 |
closure_custom_output => $self->can('custom_memory_output'), |
| 50 |
perfdatas => [ |
| 51 |
{ value => 'total', template => '%d', min => 0, |
| 52 |
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' } |
| 53 |
], |
| 54 |
} |
| 55 |
} |
| 56 |
]; |
| 57 |
} |
| 58 |
|
| 59 |
sub new { |
| 60 |
my ($class, %options) = @_; |
| 61 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 62 |
bless $self, $class; |
| 63 |
|
| 64 |
$options{options}->add_options(arguments => { |
| 65 |
}); |
| 66 |
|
| 67 |
return $self; |
| 68 |
} |
| 69 |
|
| 70 |
sub manage_selection { |
| 71 |
my ($self, %options) = @_; |
| 72 |
|
| 73 |
my $oid_total = '.1.3.6.1.4.1.46202.1.1.1.6.0'; #memAvailable |
| 74 |
my $snmp_result = $options{snmp}->get_leef( |
| 75 |
oids => [$oid_total], |
| 76 |
nothing_quit => 1 |
| 77 |
); |
| 78 |
|
| 79 |
$self->{memory} = { |
| 80 |
total => $snmp_result->{$oid_total} |
| 81 |
}; |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
1; |
| 86 |
|
| 87 |
__END__ |
| 88 |
|
| 89 |
=head1 MODE |
| 90 |
|
| 91 |
Check system memory available. |
| 92 |
|
| 93 |
=over 8 |
| 94 |
|
| 95 |
=item B<--warning-available*> |
| 96 |
|
| 97 |
Warning threshold for total memory available (B). |
| 98 |
|
| 99 |
=item B<--critical-available*> |
| 100 |
|
| 101 |
Critical threshold for total memory available (B). |
| 102 |
|
| 103 |
=back |
| 104 |
|
| 105 |
=cut |