Debian Codegraph @

src/network/ruckus/smartzone/snmp/mode/system.pm

raw
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::ruckus::smartzone::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 system_long_output {
30 my ($self, %options) = @_;
31
32 return 'checking system ';
33 }
34
35 sub set_counters {
36 my ($self, %options) = @_;
37
38 $self->{maps_counters_type} = [
39 { name => 'system', type => 3, cb_long_output => 'system_long_output',
40 indent_long_output => ' ',
41 group => [
42 { name => 'connection', type => 0, skipped_code => { -10 => 1 } },
43 { name => 'traffic', type => 0, skipped_code => { -10 => 1 } }
44 ]
45 }
46 ];
47
48 $self->{maps_counters}->{connection} = [
49 { label => 'connection-accesspoints', nlabel => 'system.connection.accesspoints.count', set => {
50 key_values => [ { name => 'ap' } ],
51 output_template => 'access points connections: %d',
52 perfdatas => [
53 { template => '%d', min => 0 }
54 ]
55 }
56 },
57 { label => 'connection-client-devices-authorized', nlabel => 'system.connection.client.devices.authorized.count', set => {
58 key_values => [ { name => 'authorized_clients' } ],
59 output_template => 'client devices authorized connections: %d',
60 perfdatas => [
61 { template => '%d', min => 0 }
62 ]
63 }
64 }
65 ];
66
67 $self->{maps_counters}->{traffic} = [
68 { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => {
69 key_values => [ { name => 'traffic_in', per_second => 1 } ],
70 output_template => 'traffic in: %s%s/s',
71 output_change_bytes => 2,
72 perfdatas => [
73 { template => '%s', min => 0, unit => 'b/s' }
74 ]
75 }
76 },
77 { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => {
78 key_values => [ { name => 'traffic_out', per_second => 1 } ],
79 output_template => 'traffic out: %s%s/s',
80 output_change_bytes => 2,
81 perfdatas => [
82 { template => '%s', min => 0, unit => 'b/s' }
83 ]
84 }
85 }
86 ];
87 }
88
89 sub new {
90 my ($class, %options) = @_;
91 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
92 bless $self, $class;
93
94 $options{options}->add_options(arguments => {
95 });
96
97 return $self;
98 }
99
100 my $mapping = {
101 ap => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.1' }, # ruckusSZSystemStatsNumAP
102 authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.2' }, # ruckusSZSystemStatsNumSta
103 traffic_in => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.6' }, # ruckusSZSystemStatsWLANTotalRxBytes
104 traffic_out => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.9' } # ruckusSZSystemStatsWLANTotalTxBytes
105 };
106
107 sub manage_selection {
108 my ($self, %options) = @_;
109
110 my $snmp_result = $options{snmp}->get_leef(
111 oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
112 nothing_quit => 1
113 );
114 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
115
116 $self->{system}->{global} = {
117 connection => {
118 ap => $result->{ap},
119 authorized_clients => $result->{authorized_clients}
120 },
121 traffic => {
122 traffic_in => $result->{traffic_in} * 8,
123 traffic_out => $result->{traffic_out} * 8
124 }
125 };
126
127 $self->{cache_name} = 'ruckus_smartzone_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
128 (defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' .
129 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
130 }
131
132 1;
133
134 __END__
135
136 =head1 MODE
137
138 Check system.
139
140 =over 8
141
142 =item B<--warning-*> B<--critical-*>
143
144 Thresholds.
145 Can be: 'traffic-in', 'traffic-out', 'connection-accesspoints',
146 'connection-client-devices-authorized'.
147
148 =back
149
150 =cut