From e0f26e73a08ea37adc3c7e7be80bbc2a33eb8a50 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Jan 2020 11:03:32 +0100 Subject: [PATCH] fix aruba + indent --- centreon/common/aruba/snmp/mode/apstatus.pm | 60 +++++++++------------ centreon/plugins/output.pm | 16 +++--- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/centreon/common/aruba/snmp/mode/apstatus.pm b/centreon/common/aruba/snmp/mode/apstatus.pm index 7aa3beb41..05d1cdb75 100644 --- a/centreon/common/aruba/snmp/mode/apstatus.pm +++ b/centreon/common/aruba/snmp/mode/apstatus.pm @@ -33,7 +33,8 @@ sub custom_status_output { $self->{result_values}->{status}, $self->{result_values}->{ip}, $self->{result_values}->{group}, - $self->{result_values}->{location}); + $self->{result_values}->{location} + ); return $msg; } @@ -50,7 +51,7 @@ sub custom_status_calc { 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_output', @@ -67,7 +68,7 @@ sub set_counters { } }, ]; - + $self->{maps_counters}->{ap} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'wlanAPName' }, { name => 'wlanAPIpAddress' }, { name => 'wlanAPGroupName' }, @@ -126,11 +127,11 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-ip:s" => { name => 'filter_ip' }, - "filter-name:s" => { name => 'filter_name' }, - "filter-group:s" => { name => 'filter_group' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' }, + 'filter-ip:s' => { name => 'filter_ip' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-group:s' => { name => 'filter_group' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /up/i' }, }); return $self; @@ -143,23 +144,21 @@ sub check_options { $self->change_macros(macros => ['warning_status', 'critical_status']); } -my %map_status = ( - 1 => 'up', 2 => 'down' -); +my $map_status = { 1 => 'up', 2 => 'down' }; my $oid_wlsxWlanAPTable = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1'; my $mapping_info = { wlanAPIpAddress => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.2' }, - wlanAPName => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3' }, - wlanAPGroupName=> { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.4' }, + wlanAPName => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3' }, + wlanAPGroupName => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.4' }, }; my $mapping_stat = { - wlanAPUpTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.12' }, - wlanAPLocation => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.14' }, - wlanAPStatus => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.20', map => \%map_status }, - wlanAPNumBootstraps => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.21' }, - wlanAPNumReboots => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.22' }, + wlanAPUpTime => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.12' }, + wlanAPLocation => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.14' }, + wlanAPStatus => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.19', map => $map_status }, + wlanAPNumBootstraps => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.20' }, + wlanAPNumReboots => { oid => '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.21' }, }; sub manage_selection { @@ -167,7 +166,7 @@ sub manage_selection { $self->{global}->{connected} = 0; $self->{ap} = {}; - + my $snmp_info = $options{snmp}->get_table( oid => $oid_wlsxWlanAPTable, start => $mapping_info->{wlanAPIpAddress}->{oid}, @@ -203,12 +202,12 @@ sub manage_selection { $self->{ap}->{$instance} = { %{$result} }; } - + if (scalar(keys %{$self->{ap}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No AP found."); $self->{output}->option_exit(); } - + $options{snmp}->load( oids => [ $mapping_stat->{wlanAPUpTime}->{oid}, @@ -222,17 +221,17 @@ sub manage_selection { ); my $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); - + foreach my $oid (keys %{$snmp_result}) { next if ($oid !~ /^$mapping_stat->{wlanAPUpTime}->{oid}\.(.*)/); my $instance = $1; - + my $result = $options{snmp}->map_instance( mapping => $mapping_stat, results => $snmp_result, instance => $instance ); - + $self->{ap}->{$instance} = { %{$self->{ap}->{$instance}}, %{$result}, wlanAPUpTime => $result->{wlanAPUpTime} / 100 }; $self->{global}->{connected}++; } @@ -248,22 +247,15 @@ Check AP status (WLSX-WLAN-MIB). =over 8 -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. +Thresholds. Can be: 'connected-current' (global), 'uptime', 'controller-bootstrap', 'reboot', 'status' (per AP). + 'status' can use special variables like: %{name}, %{status}, %{ip}, %{group}, %{location} (Default: '') -=item B<--critical-*> - -Threshold critical. -Can be: 'connected-current' (global), 'uptime', -'controller-bootstrap', 'reboot', 'status' (per AP). -'status' can use special variables like: %{name}, -%{status}, %{ip}, %{group}, %{location} (Default: '%{status} !~ /up/i') - =item B<--filter-*> Filter by 'ip', 'name', 'group' (regexp can be used). diff --git a/centreon/plugins/output.pm b/centreon/plugins/output.pm index 3c292cd03..f1595dc21 100644 --- a/centreon/plugins/output.pm +++ b/centreon/plugins/output.pm @@ -511,17 +511,21 @@ sub display { if (defined($self->{option_results}->{output_xml})) { $self->create_xml_document(); if ($self->{is_output_xml}) { - $self->output_xml(exit_litteral => $self->get_litteral_status(), - nolabel => $nolabel, - force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output); + $self->output_xml( + exit_litteral => $self->get_litteral_status(), + nolabel => $nolabel, + force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output + ); return ; } } elsif (defined($self->{option_results}->{output_json})) { $self->create_json_document(); if ($self->{is_output_json}) { - $self->output_json(exit_litteral => $self->get_litteral_status(), - nolabel => $nolabel, - force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output); + $self->output_json( + exit_litteral => $self->get_litteral_status(), + nolabel => $nolabel, + force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output + ); return ; } } elsif (defined($self->{option_results}->{output_openmetrics})) {