Debian Codegraph @

src/network/aerohive/snmp/mode/connectedusers.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::aerohive::snmp::mode::connectedusers;
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 },
33 { name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' },
34 ];
35 $self->{maps_counters}->{global} = [
36 { label => 'total', nlabel => 'users.current.count', set => {
37 key_values => [ { name => 'total' } ],
38 output_template => 'Total Users : %s',
39 perfdatas => [
40 { label => 'total', value => 'total', template => '%s',
41 unit => 'users', min => 0 },
42 ],
43 }
44 },
45 ];
46 $self->{maps_counters}->{ssid} = [
47 { label => 'ssid', nlabel => 'ssid.users.current.count', set => {
48 key_values => [ { name => 'total' }, { name => 'display' } ],
49 output_template => 'users : %s',
50 perfdatas => [
51 { label => 'ssid', value => 'total', template => '%s',
52 unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' },
53 ],
54 }
55 },
56 ];
57 }
58
59 sub prefix_ssid_output {
60 my ($self, %options) = @_;
61
62 return "SSID '" . $options{instance_value}->{display} . "' ";
63 }
64
65 sub new {
66 my ($class, %options) = @_;
67 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
68 bless $self, $class;
69
70 $options{options}->add_options(arguments =>
71 {
72 "filter-ssid:s" => { name => 'filter_ssid' },
73 });
74
75 return $self;
76 }
77
78 my $oid_ahSSIDNAME = '.1.3.6.1.4.1.26928.1.1.1.2.1.1.1.2';
79 my $oid_ahClientSSID = '.1.3.6.1.4.1.26928.1.1.1.2.1.2.1.10';
80
81 sub manage_selection {
82 my ($self, %options) = @_;
83
84 $self->{global} = { total => 0 };
85 $self->{ssid} = {};
86
87 $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_ahSSIDNAME },
88 { oid => $oid_ahClientSSID },
89 ],
90 nothing_quit => 1);
91
92 foreach my $oid (keys %{$self->{results}->{ $oid_ahSSIDNAME }}) {
93 my $ssid = $self->{results}->{ $oid_ahSSIDNAME }->{$oid};
94 if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' &&
95 $ssid !~ /$self->{option_results}->{filter_ssid}/) {
96 $self->{output}->output_add(long_msg => "skipping ssid " . $ssid . " : no matching filter.", debug => 1);
97 next;
98 }
99 $self->{ssid}->{$ssid} = { display => $ssid, total => 0 } if (!defined($self->{ssid}->{$ssid}));
100 }
101
102 foreach my $oid (keys %{$self->{results}->{ $oid_ahClientSSID }}) {
103 $self->{global}->{total}++;
104 my $ssid = $self->{results}->{ $oid_ahClientSSID }->{$oid};
105 $self->{ssid}->{$ssid}->{total}++ if (defined($self->{ssid}->{$ssid}));
106 }
107
108 }
109
110 1;
111
112 __END__
113
114 =head1 MODE
115
116 Check number of connected users (total and by SSID).
117
118 =over 8
119
120 =item B<--filter-counters>
121
122 Only display some counters (regexp can be used).
123 Example: --filter-counters='ssid$'
124
125 =item B<--warning-*>
126
127 Warning threshold.
128 Can be: 'total', 'ssid'
129
130 =item B<--critical-*>
131
132 Critical threshold.
133 Can be: 'total', 'ssid'
134
135 =item B<--filter-ssid>
136
137 Filter by SSID (can be a regexp).
138
139 =back
140
141 =cut