wip enhance airespace cisco wlc

This commit is contained in:
garnier-quentin 2020-07-06 11:01:54 +02:00
parent 0cf498cd39
commit 7bbf9c3997
4 changed files with 334 additions and 328 deletions

View File

@ -28,90 +28,87 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_output {
my ($self, %options) = @_;
my $msg;
if ($self->{result_values}->{admstatus} eq 'disabled') {
$msg = ' is disabled';
} else {
$msg = 'Status : ' . $self->{result_values}->{opstatus};
}
my $msg = $self->{result_values}->{admstatus} eq 'disabled' ? 'is disabled' : 'status: ' . $self->{result_values}->{opstatus};
return $msg;
}
sub custom_status_calc {
sub skip_global {
my ($self, %options) = @_;
$self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'};
$self->{result_values}->{admstatus} = $options{new_datas}->{$self->{instance} . '_admstatus'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
scalar(keys %{$self->{ap}}) == 1 ? return(1) : return(0);
}
sub prefix_ap_output {
my ($self, %options) = @_;
return "Access point '" . $options{instance_value}->{display} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return 'Access point ';
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_init => 'skip_global', },
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All AP status are ok' }
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', cb_init => 'skip_global', },
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access points are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
{ label => 'total', nlabel => 'accesspoints.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total ap : %s',
output_template => 'total: %s',
perfdatas => [
{ label => 'total', value => 'total', template => '%s',
min => 0 },
],
{ label => 'total', template => '%s', min => 0 }
]
}
},
{ label => 'total-associated', set => {
{ label => 'total-associated', nlabel => 'accesspoints.associated.count', set => {
key_values => [ { name => 'associated' } ],
output_template => 'Total ap associated : %s',
output_template => 'associated: %s',
perfdatas => [
{ label => 'total_associated', value => 'associated', template => '%s',
min => 0 },
],
{ label => 'total_associated', template => '%s', min => 0 }
]
}
},
{ label => 'total-disassociating', set => {
{ label => 'total-disassociating', nlabel => 'accesspoints.disassociating.count', set => {
key_values => [ { name => 'disassociating' } ],
output_template => 'Total ap disassociating : %s',
output_template => 'disassociating: %s',
perfdatas => [
{ label => 'total_disassociating', value => 'disassociating', template => '%s',
min => 0 },
],
{ label => 'total_disassociating', template => '%s', min => 0 }
]
}
},
{ label => 'total-enabled', set => {
{ label => 'total-enabled', nlabel => 'accesspoints.enabled.count', set => {
key_values => [ { name => 'enable' } ],
output_template => 'Total ap enabled : %s',
output_template => 'enabled: %s',
perfdatas => [
{ label => 'total_enabled', value => 'enable', template => '%s',
min => 0 },
],
{ label => 'total_enabled', template => '%s', min => 0 }
]
}
},
{ label => 'total-disabled', set => {
{ label => 'total-disabled', nlabel => 'accesspoints.disabled.count', set => {
key_values => [ { name => 'disable' } ],
output_template => 'Total ap disabled : %s',
output_template => 'disabled: %s',
perfdatas => [
{ label => 'total_disabled', value => 'disable', template => '%s',
min => 0 },
],
{ label => 'total_disabled', template => '%s', min => 0 }
]
}
},
}
];
$self->{maps_counters}->{ap} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'opstatus' }, { name => 'admstatus' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold
}
},
}
];
}
@ -119,14 +116,14 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{admstatus} eq "enable" and %{opstatus} !~ /associated|downloading/' },
});
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-group:s' => { name => 'filter_group' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{admstatus} eq "enable" and %{opstatus} !~ /associated|downloading/' }
});
return $self;
}
@ -137,35 +134,22 @@ sub check_options {
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub skip_global {
my ($self, %options) = @_;
scalar(keys %{$self->{ap}}) == 1 ? return(1) : return(0);
}
sub prefix_ap_output {
my ($self, %options) = @_;
return "AP '" . $options{instance_value}->{display} . "' ";
}
my %map_admin_status = (
my $map_admin_status = {
1 => 'enable',
2 => 'disable',
);
my %map_operation_status = (
2 => 'disable'
};
my $map_operation_status = {
1 => 'associated',
2 => 'disassociating',
3 => 'downloading',
);
3 => 'downloading'
};
my $mapping = {
bsnAPName => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.3' },
bsnAPName => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.3' },
bsnAPGroupVlanName => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.30' }
};
my $mapping2 = {
bsnAPOperationStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.6', map => \%map_operation_status },
};
my $mapping3 = {
bsnAPAdminStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => \%map_admin_status },
bsnAPOperationStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.6', map => $map_operation_status },
bsnAPAdminStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => $map_admin_status }
};
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
@ -174,36 +158,63 @@ sub manage_selection {
$self->{ap} = {};
$self->{global} = { total => 0, associated => 0, disassociating => 0, downloading => 0, enable => 0, disable => 0 };
$self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{bsnAPName}->{oid} },
{ oid => $mapping2->{bsnAPOperationStatus}->{oid} },
{ oid => $mapping3->{bsnAPAdminStatus}->{oid} },
],
nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " .
(defined($self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}) ? $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'} : 'unknown'));
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnAPName}->{oid} }}) {
$oid =~ /^$mapping->{bsnAPName}->{oid}\.(.*)$/;
my $request = [ { oid => $oid_agentInventoryMachineModel }, { oid => $mapping->{bsnAPName}->{oid} } ];
push @$request, { oid => $mapping->{bsnAPGroupVlanName}->{oid} }
if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '');
my $snmp_result = $options{snmp}->get_multiple_table(
oids => $request,
return_type => 1,
nothing_quit => 1
);
$self->{output}->output_add(
long_msg => 'Model: ' .
(defined($snmp_result->{$oid_agentInventoryMachineModel . '.0'}) ? $snmp_result->{$oid_agentInventoryMachineModel . '.0'} : 'unknown')
);
foreach (keys %$snmp_result) {
next if (! /^$mapping->{bsnAPName}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{bsnAPName}->{oid} }, instance => $instance);
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{ $mapping2->{bsnAPOperationStatus}->{oid} }, instance => $instance);
my $result3 = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnAPAdminStatus}->{oid} }, instance => $instance);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{bsnAPName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{bsnAPName} . "': no matching filter.", debug => 1);
$self->{output}->output_add(long_msg => "skipping '" . $result->{bsnAPName} . "'.", debug => 1);
next;
}
$self->{global}->{total}++;
$self->{global}->{$result2->{bsnAPOperationStatus}}++;
$self->{global}->{$result3->{bsnAPAdminStatus}}++;
$self->{ap}->{$instance} = { display => $result->{bsnAPName},
opstatus => $result2->{bsnAPOperationStatus}, admstatus => $result3->{bsnAPAdminStatus}};
if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '' &&
$result->{bsnAPGroupVlanName} !~ /$self->{option_results}->{filter_group}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{bsnAPName} . "'.", debug => 1);
next;
}
$self->{ap}->{$instance} = {
display => $result->{bsnAPName}
};
}
if (scalar(keys %{$self->{ap}}) <= 0) {
$self->{output}->output_add(long_msg => 'no AP associated (can be: slave wireless controller or your filter)');
return ;
}
$options{snmp}->load(
oids => [ map($_->{oid}, values(%$mapping2)) ],
instances => [ keys %{$self->{ap}} ],
instance_regexp => '^(.*)$'
);
$snmp_result = $options{snmp}->get_leef();
foreach (keys %{$self->{ap}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
$self->{global}->{total}++;
$self->{global}->{$result->{bsnAPOperationStatus}}++;
$self->{global}->{$result->{bsnAPAdminStatus}}++;
$self->{ap}->{$_}->{opstatus} = $result->{bsnAPOperationStatus};
$self->{ap}->{$_}->{admstatus} = $result->{bsnAPAdminStatus};
}
}
@ -224,7 +235,11 @@ Example: --filter-counters='^total-disassociating|total-associated$'
=item B<--filter-name>
Filter AP name (can be a regexp).
Filter access point name (can be a regexp).
=item B<--filter-group>
Filter access point group (can be a regexp).
=item B<--warning-status>
@ -236,15 +251,7 @@ Can used special variables like: %{admstatus}, %{opstatus}, %{display}
Set critical threshold for status (Default: '%{admstatus} eq "enable" and %{opstatus} !~ /associated|downloading/').
Can used special variables like: %{admstatus}, %{opstatus}, %{display}
=item B<--warning-*>
Threshold warning.
Can be: 'total', 'total-associated', 'total-disassociating', 'total-enabled', 'total-disabled'.
=item B<--critical-*>
Threshold critical.
Can be: 'total', 'total-associated', 'total-disassociating', 'total-enabled', 'total-disabled'.
=item B<--warning-*> B<--critical-*>
=back

View File

@ -25,130 +25,10 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
sub prefix_global_output {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' },
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' },
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total Users : %s',
perfdatas => [
{ label => 'total', value => 'total', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-idle', set => {
key_values => [ { name => 'total_idle' } ],
output_template => 'Total Idle Users : %s',
perfdatas => [
{ label => 'total_idle', value => 'total_idle', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-aaapending', set => {
key_values => [ { name => 'total_aaapending' } ],
output_template => 'Total AaaPending Users : %s',
perfdatas => [
{ label => 'total_aaapending', value => 'total_aaapending', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-authenticated', set => {
key_values => [ { name => 'total_authenticated' } ],
output_template => 'Total Authenticated Users : %s',
perfdatas => [
{ label => 'total_authenticated', value => 'total_authenticated', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-associated', set => {
key_values => [ { name => 'total_associated' } ],
output_template => 'Total Associated Users : %s',
perfdatas => [
{ label => 'total_associated', value => 'total_associated', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-powersave', set => {
key_values => [ { name => 'total_powersave' } ],
output_template => 'Total Powersave Users : %s',
perfdatas => [
{ label => 'total_powersave', value => 'total_powersave', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-disassociated', set => {
key_values => [ { name => 'total_disassociated' } ],
output_template => 'Total Disassociated Users : %s',
perfdatas => [
{ label => 'total_disassociated', value => 'total_disassociated', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-tobedeleted', set => {
key_values => [ { name => 'total_tobedeleted' } ],
output_template => 'Total ToBeDeleted Users : %s',
perfdatas => [
{ label => 'total_tobedeleted', value => 'total_tobedeleted', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-probing', set => {
key_values => [ { name => 'total_probing' } ],
output_template => 'Total Probing Users : %s',
perfdatas => [
{ label => 'total_probing', value => 'total_probing', template => '%s',
unit => 'users', min => 0 },
],
}
},
{ label => 'total-blacklisted', set => {
key_values => [ { name => 'total_blacklisted' } ],
output_template => 'Total Blacklisted Users : %s',
perfdatas => [
{ label => 'total_blacklisted', value => 'total_blacklisted', template => '%s',
unit => 'users', min => 0 },
],
}
},
];
$self->{maps_counters}->{ssid} = [
{ label => 'ssid', set => {
key_values => [ { name => 'total' }, { name => 'display' } ],
output_template => 'users : %s',
perfdatas => [
{ label => 'ssid', value => 'total', template => '%s',
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' },
],
}
},
];
$self->{maps_counters}->{ap} = [
{ label => 'ap', set => {
key_values => [ { name => 'total' }, { name => 'display' } ],
output_template => 'users : %s',
perfdatas => [
{ label => 'ap', value => 'total', template => '%s',
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' },
],
}
},
];
return 'Users ';
}
sub prefix_ssid_output {
@ -160,23 +40,139 @@ sub prefix_ssid_output {
sub prefix_ap_output {
my ($self, %options) = @_;
return "AP '" . $options{instance_value}->{display} . "' ";
return "Access point '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 },
{ name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' },
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by access point are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', nlabel => 'users.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'total: %s',
perfdatas => [
{ label => 'total', template => '%s', unit => 'users', min => 0 },
]
}
},
{ label => 'total-idle', nlabel => 'users.idle.count', set => {
key_values => [ { name => 'total_idle' } ],
output_template => 'idle: %s',
perfdatas => [
{ label => 'total_idle', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-aaapending', nlabel => 'users.aaapending.count', set => {
key_values => [ { name => 'total_aaapending' } ],
output_template => 'aaaPending: %s',
perfdatas => [
{ label => 'total_aaapending', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-authenticated', nlabel => 'users.authenticated.count', set => {
key_values => [ { name => 'total_authenticated' } ],
output_template => 'authenticated: %s',
perfdatas => [
{ label => 'total_authenticated', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-associated', nlabel => 'users.associated.count', set => {
key_values => [ { name => 'total_associated' } ],
output_template => 'associated: %s',
perfdatas => [
{ label => 'total_associated', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-disassociated', nlabel => 'users.disassociated.count', set => {
key_values => [ { name => 'total_disassociated' } ],
output_template => 'disassociated: %s',
perfdatas => [
{ label => 'total_disassociated', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-powersave', nlabel => 'users.powersave.count', set => {
key_values => [ { name => 'total_powersave' } ],
output_template => 'powersave: %s',
perfdatas => [
{ label => 'total_powersave', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-tobedeleted', nlabel => 'users.tobedeleted.count', set => {
key_values => [ { name => 'total_tobedeleted' } ],
output_template => 'to be deleted: %s',
perfdatas => [
{ label => 'total_tobedeleted', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-probing', nlabel => 'users.probing.count', set => {
key_values => [ { name => 'total_probing' } ],
output_template => 'probing: %s',
perfdatas => [
{ label => 'total_probing', template => '%s', unit => 'users', min => 0 }
]
}
},
{ label => 'total-blacklisted', nlabel => 'users.blacklisted.count', set => {
key_values => [ { name => 'total_blacklisted' } ],
output_template => 'blacklisted: %s',
perfdatas => [
{ label => 'total_blacklisted', template => '%s', unit => 'users', min => 0 }
]
}
}
];
$self->{maps_counters}->{ssid} = [
{ label => 'ssid', nlabel => 'ssid.users.total.count', set => {
key_values => [ { name => 'total' }, { name => 'display' } ],
output_template => 'users: %s',
perfdatas => [
{ label => 'ssid', template => '%s', unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' },
]
}
}
];
$self->{maps_counters}->{ap} = [
{ label => 'ap', nlabel => 'accesspoint.users.total.count', set => {
key_values => [ { name => 'total' }, { name => 'display' } ],
output_template => 'users: %s',
perfdatas => [
{ label => 'ap', template => '%s', unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-ssid:s' => { name => 'filter_ssid' },
'filter-ap:s' => { name => 'filter_ap' },
'filter-ssid:s' => { name => 'filter_ssid' },
'filter-ap:s' => { name => 'filter_ap' },
'filter-group:s' => { name => 'filter_group' }
});
return $self;
}
my %map_station_status = (
my $map_station_status = {
0 => 'idle',
1 => 'aaapending',
2 => 'authenticated',
@ -185,87 +181,94 @@ my %map_station_status = (
5 => 'disassociated',
6 => 'tobedeleted',
7 => 'probing',
8 => 'blacklisted',
);
8 => 'blacklisted'
};
my $mapping = {
bsnMobileStationStatus => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.9', map => \%map_station_status },
ssid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' }, # bsnMobileStationSsid
status => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.9', map => $map_station_status } # bsnMobileStationStatus
};
my $mapping2 = {
bsnMobileStationSsid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' },
};
my $mapping3 = {
bsnDot11EssNumberOfMobileStations => { oid => '.1.3.6.1.4.1.14179.2.1.1.1.38' },
ap_name => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.3' }, # bsnAPName
group_name => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.30' } # bsnAPGroupVlanName
};
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
my $oid_bsnDot11EssSsid = '.1.3.6.1.4.1.14179.2.1.1.1.2';
my $oid_bsnAPName = '.1.3.6.1.4.1.14179.2.2.1.1.3';
my $oid_bsnAPIfLoadNumOfClients = '.1.3.6.1.4.1.14179.2.2.13.1.4';
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = { total => 0, total_idle => 0, total_aaapending => 0, total_authenticated => 0,
total_associated => 0, total_powersave => 0, total_disassociated => 0,
total_tobedeleted => 0, total_probing => 0, total_blacklisted => 0};
$self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{bsnMobileStationStatus}->{oid} },
{ oid => $mapping2->{bsnMobileStationSsid}->{oid} },
{ oid => $oid_bsnDot11EssSsid },
{ oid => $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} },
{ oid => $oid_bsnAPName },
{ oid => $oid_bsnAPIfLoadNumOfClients },
],
nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " .
(defined($self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}) ? $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'} : 'unknown'));
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }}) {
$oid =~ /^$mapping->{bsnMobileStationStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }, instance => $instance);
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{ $mapping2->{bsnMobileStationSsid}->{oid} }, instance => $instance);
if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' &&
$result2->{bsnMobileStationSsid} !~ /$self->{option_results}->{filter_ssid}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $result2->{bsnMobileStationSsid} . "': no matching filter.", debug => 1);
next;
}
$self->{global}->{total}++;
$self->{global}->{'total_' . $result->{bsnMobileStationStatus}}++;
}
# check by ssid
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{status}->{oid} },
{ oid => $mapping->{ssid}->{oid} },
{ oid => $oid_bsnDot11EssSsid }
],
return_type => 1,
nothing_quit => 1
);
$self->{output}->output_add(
long_msg => "Model: " .
(defined($self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}) ? $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'} : 'unknown')
);
$self->{global} = {
total => 0, total_idle => 0, total_aaapending => 0, total_authenticated => 0,
total_associated => 0, total_powersave => 0, total_disassociated => 0,
total_tobedeleted => 0, total_probing => 0, total_blacklisted => 0
};
$self->{ssid} = {};
foreach my $oid (keys %{$self->{results}->{ $oid_bsnDot11EssSsid }}) {
$oid =~ /^$oid_bsnDot11EssSsid\.(.*)$/;
my $instance = $1;
my $ssid_name = $self->{results}->{ $oid_bsnDot11EssSsid }->{$oid};
my $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} }, instance => $instance);
if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' &&
$ssid_name !~ /$self->{option_results}->{filter_ssid}/) {
$self->{output}->output_add(long_msg => "skipping ssid '" . $ssid_name . "': no matching filter.", debug => 1);
foreach my $oid (keys %$snmp_result) {
if ($oid =~ /^$oid_bsnDot11EssSsid/ && !defined($self->{ssid}->{ $snmp_result->{$oid} })) {
$self->{ssid}->{ $snmp_result->{$oid} } = { display => $snmp_result->{$oid}, total => 0 };
next;
}
$self->{ssid}->{$ssid_name} = { display => $ssid_name, total => 0 } if (!defined($self->{ssid}->{$ssid_name}));
$self->{ssid}->{$ssid_name}->{total} += $result->{bsnDot11EssNumberOfMobileStations};
}
# check by ap
$self->{ap} = {};
foreach my $oid (keys %{$self->{results}->{ $oid_bsnAPName }}) {
$oid =~ /^$oid_bsnAPName\.(.*)/;
next if ($oid !~ /^$mapping->{ssid}->{oid}\.(.*)$/);
my $instance = $1;
my $ap_name = $self->{results}->{$oid_bsnAPName}->{$oid};
if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' &&
$ap_name !~ /$self->{option_results}->{filter_ap}/) {
$self->{output}->output_add(long_msg => "skipping ap '" . $ap_name . "': no matching filter.", debug => 1);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' &&
$result->{ssid} !~ /$self->{option_results}->{filter_ssid}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{ssid} . "': no matching filter.", debug => 1);
next;
}
foreach my $oid2 (keys %{$self->{results}->{ $oid_bsnAPIfLoadNumOfClients }}) {
$self->{ssid}->{ $result->{ssid} } = { display => $result->{ssid}, total => 0 } if (!defined($self->{ssid}->{ $result->{ssid} }));
$self->{ssid}->{ $result->{ssid} }->{total}++;
$self->{global}->{total}++;
$self->{global}->{'total_' . $result->{status}}++;
}
my $request = [ { oid => $mapping2->{ap_name}->{oid} }, { oid => $oid_bsnAPIfLoadNumOfClients } ];
push @$request, { oid => $mapping2->{group_name}->{oid} }
if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '');
$snmp_result = $options{snmp}->get_multiple_table(
oids => $request,
return_type => 1
);
# check by ap
$self->{ap} = {};
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping2->{ap_name}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' &&
$result->{ap_name} !~ /$self->{option_results}->{filter_ap}/) {
$self->{output}->output_add(long_msg => "skipping access point '" . $result->{ap_name} . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_group}) && $self->{option_results}->{filter_group} ne '' &&
$result->{group_name} !~ /$self->{option_results}->{filter_group}/) {
$self->{output}->output_add(long_msg => "skipping access point '" . $result->{ap_name} . "': no matching filter.", debug => 1);
next;
}
foreach my $oid2 (keys %$snmp_result) {
next if ($oid2 !~ /^$oid_bsnAPIfLoadNumOfClients\.$instance\./);
$self->{ap}->{$instance} = { display => $ap_name, total => 0 } if (!defined($self->{ap}->{$instance}));
$self->{ap}->{$instance}->{total} += $self->{results}->{$oid_bsnAPIfLoadNumOfClients}->{$oid2};
$self->{ap}->{$instance} = { display => $result->{ap_name}, total => 0 } if (!defined($self->{ap}->{$instance}));
$self->{ap}->{$instance}->{total} += $snmp_result->{$oid2};
}
}
}
@ -285,27 +288,24 @@ Check users connected (total, by SSID, by AP).
Only display some counters (regexp can be used).
Example: --filter-counters='^total|total-idle$'
=item B<--warning-*>
Threshold warning.
Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated',
'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted',
'total-probing', 'total-blacklisted', 'ssid', 'ap'.
=item B<--critical-*>
Threshold critical.
Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated',
'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted',
'total-probing', 'total-blacklisted', 'ssid', 'ap'.
=item B<--filter-ssid>
Filter by SSID (can be a regexp).
=item B<--filter-ap>
Filter by AP (can be a regexp).
Filter by access point name (can be a regexp).
=item B<--filter-group>
Filter by access point group (can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated',
'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted',
'total-probing', 'total-blacklisted', 'ssid', 'ap'.
=back

View File

@ -29,12 +29,11 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
$options{options}->add_options(arguments => {
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' }
});
return $self;
}

View File

@ -30,17 +30,17 @@ sub new {
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'ap-channel-interference' => 'centreon::common::airespace::snmp::mode::apchannelinterference',
'ap-channel-noise' => 'centreon::common::airespace::snmp::mode::apchannelnoise',
'ap-status' => 'centreon::common::airespace::snmp::mode::apstatus',
'ap-users' => 'centreon::common::airespace::snmp::mode::apusers',
'cpu' => 'centreon::common::airespace::snmp::mode::cpu',
'hardware' => 'centreon::common::airespace::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'centreon::common::airespace::snmp::mode::memory',
);
$self->{modes} = {
'ap-channel-interference' => 'centreon::common::airespace::snmp::mode::apchannelinterference',
'ap-channel-noise' => 'centreon::common::airespace::snmp::mode::apchannelnoise',
'ap-status' => 'centreon::common::airespace::snmp::mode::apstatus',
'ap-users' => 'centreon::common::airespace::snmp::mode::apusers',
'cpu' => 'centreon::common::airespace::snmp::mode::cpu',
'hardware' => 'centreon::common::airespace::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'centreon::common::airespace::snmp::mode::memory'
};
return $self;
}