| 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::kvm::adder::aim::snmp::mode::serverusage; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_counters { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{maps_counters_type} = [ |
| 32 |
{ name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }, |
| 33 |
]; |
| 34 |
|
| 35 |
$self->{maps_counters}->{global} = [ |
| 36 |
{ label => 'cpu-load', set => { |
| 37 |
key_values => [ { name => 'cpu_load' } ], |
| 38 |
output_template => 'CPU Load : %s', |
| 39 |
perfdatas => [ |
| 40 |
{ label => 'cpu_load', value => 'cpu_load', template => '%s', min => 0 }, |
| 41 |
], |
| 42 |
} |
| 43 |
}, |
| 44 |
{ label => 'memory', set => { |
| 45 |
key_values => [ { name => 'memory_used' } ], |
| 46 |
output_template => 'Memory Used : %s %%', |
| 47 |
perfdatas => [ |
| 48 |
{ label => 'memory_used', value => 'memory_used', template => '%s', |
| 49 |
unit => '%', min => 0, max => 100 }, |
| 50 |
], |
| 51 |
} |
| 52 |
}, |
| 53 |
{ label => 'disk', set => { |
| 54 |
key_values => [ { name => 'disk_used' } ], |
| 55 |
output_template => 'Disk Used : %s %%', |
| 56 |
perfdatas => [ |
| 57 |
{ label => 'disk_used', value => 'disk_used', template => '%s', |
| 58 |
unit => '%', min => 0, max => 100 }, |
| 59 |
], |
| 60 |
} |
| 61 |
}, |
| 62 |
{ label => 'num-active-con', set => { |
| 63 |
key_values => [ { name => 'num_active_con' } ], |
| 64 |
output_template => 'Current Connected Rx : %s', |
| 65 |
perfdatas => [ |
| 66 |
{ label => 'num_active_con', value => 'num_active_con', template => '%s', min => 0}, |
| 67 |
], |
| 68 |
} |
| 69 |
}, |
| 70 |
{ label => 'num-rx', set => { |
| 71 |
key_values => [ { name => 'num_rx' } ], |
| 72 |
output_template => 'Number Rx : %s', |
| 73 |
perfdatas => [ |
| 74 |
{ label => 'num_rx', value => 'num_rx', template => '%s', min => 0 }, |
| 75 |
], |
| 76 |
} |
| 77 |
}, |
| 78 |
{ label => 'num-tx', set => { |
| 79 |
key_values => [ { name => 'num_tx' } ], |
| 80 |
output_template => 'Numbre Tx : %s', |
| 81 |
perfdatas => [ |
| 82 |
{ label => 'num_tx', value => 'num_tx', template => '%s', min => 0 }, |
| 83 |
], |
| 84 |
} |
| 85 |
}, |
| 86 |
]; |
| 87 |
} |
| 88 |
|
| 89 |
sub new { |
| 90 |
my ($class, %options) = @_; |
| 91 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 92 |
bless $self, $class; |
| 93 |
|
| 94 |
$options{options}->add_options(arguments => |
| 95 |
{ |
| 96 |
}); |
| 97 |
|
| 98 |
return $self; |
| 99 |
} |
| 100 |
|
| 101 |
sub manage_selection { |
| 102 |
my ($self, %options) = @_; |
| 103 |
|
| 104 |
my $oid_numRx = '.1.3.6.1.4.1.25119.1.2.1.0'; |
| 105 |
my $oid_numTx = '.1.3.6.1.4.1.25119.1.2.2.0'; |
| 106 |
my $oid_numActiveConnexions = '.1.3.6.1.4.1.25119.1.2.3.0'; |
| 107 |
my $oid_serverCPULoad = '.1.3.6.1.4.1.25119.1.3.1.0'; |
| 108 |
my $oid_serverMemoryUsage = '.1.3.6.1.4.1.25119.1.3.2.0'; |
| 109 |
my $oid_serverDiskSpace = '.1.3.6.1.4.1.25119.1.3.4.0'; |
| 110 |
my $result = $options{snmp}->get_leef(oids => [ |
| 111 |
$oid_numRx, $oid_numTx, $oid_numActiveConnexions, |
| 112 |
$oid_serverCPULoad, $oid_serverMemoryUsage, $oid_serverDiskSpace |
| 113 |
], |
| 114 |
nothing_quit => 1); |
| 115 |
$result->{$oid_serverMemoryUsage} =~ s/%//g; |
| 116 |
$result->{$oid_serverDiskSpace} =~ s/%//g; |
| 117 |
|
| 118 |
$self->{global} = { |
| 119 |
num_rx => $result->{$oid_numRx}, num_tx => $result->{$oid_numTx}, |
| 120 |
num_active_con => $result->{$oid_numActiveConnexions}, |
| 121 |
cpu_load => $result->{$oid_serverCPULoad}, |
| 122 |
memory_used => $result->{$oid_serverMemoryUsage}, |
| 123 |
disk_used => $result->{$oid_serverDiskSpace}, |
| 124 |
}; |
| 125 |
} |
| 126 |
|
| 127 |
1; |
| 128 |
|
| 129 |
__END__ |
| 130 |
|
| 131 |
=head1 MODE |
| 132 |
|
| 133 |
Check server usage. |
| 134 |
|
| 135 |
=over 8 |
| 136 |
|
| 137 |
=item B<--filter-counters> |
| 138 |
|
| 139 |
Only display some counters (regexp can be used). |
| 140 |
Example: --filter-counters='^cpu-load$' |
| 141 |
|
| 142 |
=item B<--warning-*> |
| 143 |
|
| 144 |
Warning threshold. |
| 145 |
Can be: 'cpu-load', 'memory', 'disk', 'num-rx', |
| 146 |
'num-tx', 'num-active-con'. |
| 147 |
|
| 148 |
=item B<--critical-*> |
| 149 |
|
| 150 |
Critical threshold. |
| 151 |
Can be: 'cpu-load', 'memory', 'disk', 'num-rx', |
| 152 |
'num-tx', 'num-active-con'. |
| 153 |
|
| 154 |
=back |
| 155 |
|
| 156 |
=cut |