fix issue with aruba no ap connected

This commit is contained in:
garnier-quentin 2019-11-07 10:33:02 +01:00
parent b156213a81
commit d7603030c2
1 changed files with 18 additions and 11 deletions

View File

@ -49,10 +49,22 @@ sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output',
message_multiple => 'All access points are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{global} = [
{ label => 'total-ap', nlabel => 'accesspoints.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'total access points: %s',
perfdatas => [
{ value => 'total_absolute', template => '%s', min => 0 },
],
}
},
];
$self->{maps_counters}->{ap} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'display' } ],
@ -159,14 +171,13 @@ sub manage_selection {
my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_aiAccessPointEntry, start => $mapping->{aiAPName}->{oid},
end => $mapping->{aiAPStatus}->{oid} },
{ oid => $oid_aiAccessPointEntry, start => $mapping->{aiAPName}->{oid}, end => $mapping->{aiAPStatus}->{oid} },
{ oid => $oid_aiClientAPIPAddress },
],
nothing_quit => 1
);
my $link_ap = {};
$self->{global} = { total => 0 };
$self->{ap} = {};
foreach my $oid (keys %{$snmp_result->{$oid_aiAccessPointEntry}}) {
next if ($oid !~ /^$mapping->{aiAPName}->{oid}\.(.*)$/);
@ -179,6 +190,7 @@ sub manage_selection {
next;
}
$self->{global}->{total}++;
$self->{ap}->{$result->{aiAPName}} = {
display => $result->{aiAPName},
status => $result->{aiAPStatus},
@ -193,7 +205,7 @@ sub manage_selection {
$link_ap->{$result->{aiAPIPAddress}} = $self->{ap}->{$result->{aiAPName}};
}
if (scalar(keys %{$snmp_result->{$oid_aiAccessPointEntry}}) == 0) {
if (scalar(keys %{$snmp_result->{$oid_aiAccessPointEntry}}) == 0 && scalar(keys %{$snmp_result->{$oid_aiClientAPIPAddress}}) > 0) {
$self->{ap}->{default} = {
display => 'default',
clients => 0,
@ -208,11 +220,6 @@ sub manage_selection {
$self->{ap}->{default}->{clients}++;
}
}
if (scalar(keys %{$self->{ap}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No access point found.");
$self->{output}->option_exit();
}
}
1;
@ -247,7 +254,7 @@ Can used special variables like: %{status}, %{display}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'cpu', 'clients',
Can be: 'total-ap', 'cpu', 'clients',
'mem-usage' (B), 'mem-usage-free' (B), 'mem-usage-prct' (%).
=back