| 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::watchguard::snmp::mode::system; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use Digest::MD5 qw(md5_hex); |
| 28 |
|
| 29 |
sub set_counters { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{maps_counters_type} = [ |
| 33 |
{ name => 'global', type => 0, message_separator => ' - ' } |
| 34 |
]; |
| 35 |
|
| 36 |
$self->{maps_counters}->{global} = [ |
| 37 |
{ label => 'connections', nlabel => 'system.connections.current.count', set => { |
| 38 |
key_values => [ { name => 'connections' } ], |
| 39 |
output_template => 'Current connections: %s', |
| 40 |
perfdatas => [ |
| 41 |
{ label => 'current_connections', template => '%s', min => 0 } |
| 42 |
] |
| 43 |
} |
| 44 |
}, |
| 45 |
{ label => 'in-traffic', nlabel => 'system.traffic.in.bitspersecond', set => { |
| 46 |
key_values => [ { name => 'in_traffic', per_second => 1 } ], |
| 47 |
output_template => 'Traffic in: %s %s/s', |
| 48 |
output_change_bytes => 2, |
| 49 |
perfdatas => [ |
| 50 |
{ label => 'traffic_in', template => '%s', min => 0, unit => 'b/s' } |
| 51 |
] |
| 52 |
} |
| 53 |
}, |
| 54 |
{ label => 'out-traffic', nlabel => 'system.traffic.out.bitspersecond', set => { |
| 55 |
key_values => [ { name => 'out_traffic', per_second => 1 } ], |
| 56 |
output_template => 'Traffic out: %s %s/s', |
| 57 |
output_change_bytes => 2, |
| 58 |
perfdatas => [ |
| 59 |
{ label => 'traffic_out', template => '%s', min => 0, unit => 'b/s' } |
| 60 |
] |
| 61 |
} |
| 62 |
} |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
sub new { |
| 67 |
my ($class, %options) = @_; |
| 68 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); |
| 69 |
bless $self, $class; |
| 70 |
|
| 71 |
$options{options}->add_options(arguments => { |
| 72 |
}); |
| 73 |
|
| 74 |
return $self; |
| 75 |
} |
| 76 |
|
| 77 |
sub manage_selection { |
| 78 |
my ($self, %options) = @_; |
| 79 |
|
| 80 |
if ($options{snmp}->is_snmpv1()) { |
| 81 |
$self->{output}->add_option_msg(short_msg => 'Need to use SNMP v2c or v3.'); |
| 82 |
$self->{output}->option_exit(); |
| 83 |
} |
| 84 |
|
| 85 |
my $oid_wgSystemTotalSendBytes = '.1.3.6.1.4.1.3097.6.3.8.0'; |
| 86 |
my $oid_wgSystemTotalRecvBytes = '.1.3.6.1.4.1.3097.6.3.9.0'; |
| 87 |
my $oid_wgSystemCurrActiveConns = '.1.3.6.1.4.1.3097.6.3.80.0'; |
| 88 |
my $snmp_result = $options{snmp}->get_leef( |
| 89 |
oids => [ |
| 90 |
$oid_wgSystemTotalSendBytes, $oid_wgSystemTotalRecvBytes, $oid_wgSystemCurrActiveConns |
| 91 |
], |
| 92 |
nothing_quit => 1 |
| 93 |
); |
| 94 |
|
| 95 |
$self->{global} = { |
| 96 |
out_traffic => $snmp_result->{$oid_wgSystemTotalSendBytes} * 8, |
| 97 |
in_traffic => $snmp_result->{$oid_wgSystemTotalRecvBytes} * 8, |
| 98 |
connections => $snmp_result->{$oid_wgSystemCurrActiveConns} |
| 99 |
}; |
| 100 |
|
| 101 |
$self->{cache_name} = 'watchguard_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . |
| 102 |
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); |
| 103 |
} |
| 104 |
|
| 105 |
1; |
| 106 |
|
| 107 |
__END__ |
| 108 |
|
| 109 |
=head1 MODE |
| 110 |
|
| 111 |
Check system statistics. |
| 112 |
|
| 113 |
=over 8 |
| 114 |
|
| 115 |
=item B<--filter-counters> |
| 116 |
|
| 117 |
Only display some counters (regexp can be used). |
| 118 |
Example: --filter-counters='^connections$' |
| 119 |
|
| 120 |
=item B<--warning-*> B<--critical-*> |
| 121 |
|
| 122 |
Thresholds. |
| 123 |
Can be: 'in-traffic', 'out-traffic', 'connections'. |
| 124 |
|
| 125 |
=back |
| 126 |
|
| 127 |
=cut |