From 13d7ca825e1144ca02bc5c8edbdd326d0facd5bd Mon Sep 17 00:00:00 2001 From: itoussies <65223458+itoussies@users.noreply.github.com> Date: Tue, 19 Jan 2021 11:34:38 +0100 Subject: [PATCH] enh(plugin)apps-protocol-radius metricsv2 (#2526) --- .../apps/protocols/radius/mode/login.pm | 20 ++++++++++--------- .../apps/protocols/radius/plugin.pm | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/centreon-plugins/apps/protocols/radius/mode/login.pm b/centreon-plugins/apps/protocols/radius/mode/login.pm index 8d0e3264f..f93c8e474 100644 --- a/centreon-plugins/apps/protocols/radius/mode/login.pm +++ b/centreon-plugins/apps/protocols/radius/mode/login.pm @@ -26,7 +26,7 @@ use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); use Authen::Radius; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_status_output { my ($self, %options) = @_; @@ -53,23 +53,26 @@ sub set_counters { ]; $self->{maps_counters}->{radius} = [ - { label => 'status', threshold => 0, set => { + { + label => 'status', + type => 2, + critical_default => '%{status} ne "accepted"', + set => { key_values => [ { name => 'status' }, { name => 'error_msg' } ], 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, + closure_custom_threshold_check => \&catalog_status_threshold_ng, } }, - { label => 'time', set => { + { label => 'time', nlabel => 'radius.response.time.seconds', set => { key_values => [ { name => 'elapsed' } ], output_template => 'Response time : %.3f second(s)', perfdatas => [ - { label => 'time', value => 'elapsed', template => '%.3f', - min => 0, unit => 's' }, - ], + { label => 'time' template => '%.3f', min => 0, unit => 's' } + ] } - }, + } ]; } @@ -119,7 +122,6 @@ sub check_options { if (defined($self->{option_results}->{port}) && $self->{option_results}->{port} =~ /^\d+$/) { $self->{option_results}->{hostname} .= ':' . $self->{option_results}->{port}; } - $self->change_macros(macros => ['warning_status', 'critical_status']); } sub radius_simple_connection { diff --git a/centreon-plugins/apps/protocols/radius/plugin.pm b/centreon-plugins/apps/protocols/radius/plugin.pm index a55e7e787..63e3a7ffb 100644 --- a/centreon-plugins/apps/protocols/radius/plugin.pm +++ b/centreon-plugins/apps/protocols/radius/plugin.pm @@ -30,9 +30,9 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'login' => 'apps::protocols::radius::mode::login', - ); + $self->{modes}} = { + 'login' => 'apps::protocols::radius::mode::login' + }; return $self; }