From fd201527aa41f118d9f379fbb90383a5d6935ffc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 9 Feb 2021 13:51:23 +0100 Subject: [PATCH] fix typo and some nlabel --- apps/protocols/snmp/mode/responsetime.pm | 28 ++++++++++++------------ apps/protocols/ssh/mode/login.pm | 16 +++----------- apps/protocols/ssh/plugin.pm | 2 +- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/apps/protocols/snmp/mode/responsetime.pm b/apps/protocols/snmp/mode/responsetime.pm index 199453559..0168799ef 100644 --- a/apps/protocols/snmp/mode/responsetime.pm +++ b/apps/protocols/snmp/mode/responsetime.pm @@ -29,18 +29,18 @@ use Time::HiRes qw(gettimeofday tv_interval); sub prefix_output { my ($self, %options) = @_; - return "SNMP Agent "; + return 'SNMP Agent '; } sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0, cb_prefix_output => 'prefix_output' }, + { name => 'global', type => 0, cb_prefix_output => 'prefix_output' } ]; $self->{maps_counters}->{global} = [ - { label => 'rta', nlabel => 'response.time.average', set => { + { label => 'rta', nlabel => 'roundtrip.time.average.milliseconds', set => { key_values => [ { name => 'rta' } ], output_template => 'rta %.3fms', perfdatas => [ @@ -48,14 +48,14 @@ sub set_counters { ] } }, - { label => 'rtmax', nlabel => 'response.time.max', display_ok => 0, set => { + { label => 'rtmax', nlabel => 'roundtrip.time.maximum.milliseconds', display_ok => 0, set => { key_values => [ { name => 'rtmax' } ], perfdatas => [ { label => 'rtmax', template => '%.3f', min => 0, unit => 'ms' } ] } }, - { label => 'rtmin', nlabel => 'response.time.max', display_ok => 0, set => { + { label => 'rtmin', nlabel => 'roundtrip.time.minimum.milliseconds', display_ok => 0, set => { key_values => [ { name => 'rtmin' } ], perfdatas => [ { label => 'rtmin', template => '%.3f', min => 0, unit => 'ms' } @@ -77,12 +77,12 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { - "timeout:s" => { name => 'timeout' }, - "packets:s" => { name => 'packets' } + 'timeout:s' => { name => 'timeout' }, + 'packets:s' => { name => 'packets' } }); - + return $self; } @@ -98,7 +98,7 @@ sub check_options { if (defined($self->{option_results}->{packets}) && $self->{option_results}->{packets} =~ /(\d+)/) { $self->{option_packets} = $1; } - + $options{snmp}->set_snmp_connect_params(Timeout => $self->{option_timeout} * (10**6)); $options{snmp}->set_snmp_connect_params(Retries => 0); $options{snmp}->set_snmp_params(subsetleef => 1); @@ -106,8 +106,8 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - - my $sysDescr = ".1.3.6.1.2.1.1.1.0"; + + my $sysDescr = '.1.3.6.1.2.1.1.1.0'; my $total_time_elapsed = 0; my $max_time_elapsed = 0; my $min_time_elapsed = 0; @@ -116,7 +116,7 @@ sub manage_selection { my $timing0 = [gettimeofday]; my $return = $options{snmp}->get_leef(oids => [$sysDescr], nothing_quit => 0, dont_quit => 1); my $timeelapsed = tv_interval($timing0, [gettimeofday]); - + if (!defined($return)) { $total_packet_lost++; } else { @@ -130,7 +130,7 @@ sub manage_selection { rta => ($self->{option_packets} > $total_packet_lost) ? $total_time_elapsed * 1000 / ($self->{option_packets} - $total_packet_lost) : 0, rtmax => $max_time_elapsed * 1000, rtmin => $min_time_elapsed * 1000, - pl => int($total_packet_lost * 100 / $self->{option_packets}), + pl => int($total_packet_lost * 100 / $self->{option_packets}) }; } diff --git a/apps/protocols/ssh/mode/login.pm b/apps/protocols/ssh/mode/login.pm index b6b8459d7..abe21a160 100644 --- a/apps/protocols/ssh/mode/login.pm +++ b/apps/protocols/ssh/mode/login.pm @@ -30,16 +30,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ sub custom_status_output { my ($self, %options) = @_; - my $msg = sprintf("%s", $self->{result_values}->{message}); - return $msg; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{message} = $options{new_datas}->{$self->{instance} . '_message'}; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - return 0; + return sprintf('%s', $self->{result_values}->{message}); } sub set_counters { @@ -51,11 +42,10 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', - type => 2 + type => 2, critical_default => '%{message} !~ /authentification succeeded/i', set => { key_values => [ { name => 'status' }, { name => 'message' } ], - 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 @@ -76,7 +66,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { }); diff --git a/apps/protocols/ssh/plugin.pm b/apps/protocols/ssh/plugin.pm index 1beb5feaa..6bed42d90 100644 --- a/apps/protocols/ssh/plugin.pm +++ b/apps/protocols/ssh/plugin.pm @@ -34,7 +34,7 @@ sub new { 'login' => 'apps::protocols::ssh::mode::login' }; - $self->{custom_modes}{api} = 'centreon::common::protocols::ssh::custom::api'; + $self->{custom_modes}->{api} = 'centreon::common::protocols::ssh::custom::api'; return $self; }