From d7603030c24766935ed07e6ebe1082e16d6fdb4a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 Nov 2019 10:33:02 +0100 Subject: [PATCH] fix issue with aruba no ap connected --- network/aruba/instant/snmp/mode/apusage.pm | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/network/aruba/instant/snmp/mode/apusage.pm b/network/aruba/instant/snmp/mode/apusage.pm index e8a647e50..74703ddcd 100644 --- a/network/aruba/instant/snmp/mode/apusage.pm +++ b/network/aruba/instant/snmp/mode/apusage.pm @@ -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