diff --git a/apps/protocols/ospf/snmp/mode/neighbor.pm b/apps/protocols/ospf/snmp/mode/neighbor.pm index bae3f1a45..1bc539c76 100644 --- a/apps/protocols/ospf/snmp/mode/neighbor.pm +++ b/apps/protocols/ospf/snmp/mode/neighbor.pm @@ -30,24 +30,13 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ sub custom_status_output { my ($self, %options) = @_; - my $msg = 'state : ' . $self->{result_values}->{NbrState}; - return $msg; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{NbrState} = $options{new_datas}->{$self->{instance} . '_NbrState'}; - $self->{result_values}->{NbrIpAddr} = $options{new_datas}->{$self->{instance} . '_NbrIpAddr'}; - $self->{result_values}->{NbrRtrId} = $options{new_datas}->{$self->{instance} . '_NbrRtrId'}; - return 0; + return 'state : ' . $self->{result_values}->{NbrState}; } sub custom_change_output { my ($self, %options) = @_; - my $msg = 'Neighbors current : ' . $self->{result_values}->{Total} . ' (last : ' . $self->{result_values}->{TotalLast} . ')'; - return $msg; + return 'Neighbors current : ' . $self->{result_values}->{Total} . ' (last : ' . $self->{result_values}->{TotalLast} . ')'; } sub custom_change_calc { @@ -81,15 +70,16 @@ sub set_counters { ] } }, - { label => 'total-change', threshold => 0, set => { + { label => 'total-change', type => 2, set => { key_values => [ { name => 'total', diff => 1 } ], closure_custom_calc => $self->can('custom_change_calc'), closure_custom_output => $self->can('custom_change_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold_ng, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; + $self->{maps_counters}->{nb} = [ { label => 'status', @@ -97,12 +87,11 @@ sub set_counters { critical_default => '%{NbrState} =~ /down/i', set => { key_values => [ { name => 'NbrIpAddr' }, { name => 'NbrRtrId' }, { name => 'NbrState' } ], - 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_ng, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -125,12 +114,12 @@ my %map_state = ( 5 => 'exchangeStart', 6 => 'exchange', 7 => 'loading', - 8 => 'full', + 8 => 'full' ); my $mapping = { NbrIpAddr => { oid => '.1.3.6.1.2.1.14.10.1.1' }, NbrRtrId => { oid => '.1.3.6.1.2.1.14.10.1.3' }, - NbrState => { oid => '.1.3.6.1.2.1.14.10.1.6', map => \%map_state }, + NbrState => { oid => '.1.3.6.1.2.1.14.10.1.6', map => \%map_state } }; my $oid_ospfNbrEntry = '.1.3.6.1.2.1.14.10.1'; @@ -140,8 +129,10 @@ sub manage_selection { $self->{nb} = {}; $self->{global} = { total => 0 }; - my $snmp_result = $options{snmp}->get_table(oid => $oid_ospfNbrEntry, - nothing_quit => 1); + my $snmp_result = $options{snmp}->get_table( + oid => $oid_ospfNbrEntry, + nothing_quit => 1 + ); foreach my $oid (keys %{$snmp_result}) { next if ($oid !~ /^$mapping->{NbrState}->{oid}\.(.*)$/); @@ -151,13 +142,13 @@ sub manage_selection { $self->{global}->{total}++; $self->{nb}->{$instance} = { %$result }; } - + if (scalar(keys %{$self->{nb}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No neighbors found."); $self->{output}->option_exit(); } - - $self->{cache_name} = "ospf_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + + $self->{cache_name} = 'ospf_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); }