fix issue with aruba no ap connected

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

View File

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