diff --git a/centreon-plugins/apps/slack/restapi/mode/countchannels.pm b/centreon-plugins/apps/slack/restapi/mode/countchannels.pm index 9218a6f40..4e0cb2527 100644 --- a/centreon-plugins/apps/slack/restapi/mode/countchannels.pm +++ b/centreon-plugins/apps/slack/restapi/mode/countchannels.pm @@ -31,43 +31,12 @@ sub prefix_output { return "Channel '" . $options{instance_value}->{name} . "' "; } -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'global', type => 0 }, - { name => 'channels', type => 1, cb_prefix_output => 'prefix_output' }, - ]; - - $self->{maps_counters}->{global} = [ - { label => 'count', set => { - key_values => [ { name => 'count' } ], - output_template => 'Number of channels : %d', - perfdatas => [ - { label => 'count', value => 'count', template => '%d', - min => 0 }, - ], - } - }, - ]; - - $self->{maps_counters}->{channels} = [ - { label => 'members', set => { - key_values => [ { name => 'id' }, { name => 'name' }, { name => 'num_members' } ], - closure_custom_calc => $self->can('custom_info_calc'), - closure_custom_output => $self->can('custom_info_output'), - closure_custom_perfdata => $self->can('custom_info_perfdata'), - closure_custom_threshold_check => $self->can('custom_info_threshold'), - } - }, - ]; -} - sub custom_info_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( label => 'members', + nlabel => 'channels.members.count', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{name} : undef, value => $self->{result_values}->{num_members}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), @@ -102,6 +71,37 @@ sub custom_info_calc { return 0; } +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'channels', type => 1, cb_prefix_output => 'prefix_output' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'count', nlabel => 'channels.count', set => { + key_values => [ { name => 'count' } ], + output_template => 'Number of channels : %d', + perfdatas => [ + { label => 'count', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{channels} = [ + { label => 'members', set => { + key_values => [ { name => 'id' }, { name => 'name' }, { name => 'num_members' } ], + closure_custom_calc => $self->can('custom_info_calc'), + closure_custom_output => $self->can('custom_info_output'), + closure_custom_perfdata => $self->can('custom_info_perfdata'), + closure_custom_threshold_check => $self->can('custom_info_threshold') + } + } + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/apps/slack/restapi/mode/countmembers.pm b/centreon-plugins/apps/slack/restapi/mode/countmembers.pm index d8c20c598..e34f0a80e 100644 --- a/centreon-plugins/apps/slack/restapi/mode/countmembers.pm +++ b/centreon-plugins/apps/slack/restapi/mode/countmembers.pm @@ -36,19 +36,18 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'members', type => 1, cb_prefix_output => 'prefix_output' }, + { name => 'members', type => 1, cb_prefix_output => 'prefix_output' } ]; $self->{maps_counters}->{global} = [ - { label => 'count', set => { + { label => 'count', nlabel => 'members.count', set => { key_values => [ { name => 'count' } ], output_template => 'Number of members : %d', perfdatas => [ - { label => 'count', value => 'count', template => '%d', - min => 0 }, - ], + { label => 'count', template => '%d', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{members} = [ @@ -56,9 +55,9 @@ sub set_counters { key_values => [ { name => 'id' }, { name => 'real_name' }, { name => 'display_name' } ], closure_custom_calc => $self->can('custom_info_calc'), closure_custom_output => $self->can('custom_info_output'), - closure_custom_perfdata => sub { return 0; }, + closure_custom_perfdata => sub { return 0; } } - }, + } ]; } sub custom_info_output { diff --git a/centreon-plugins/apps/slack/restapi/plugin.pm b/centreon-plugins/apps/slack/restapi/plugin.pm index cd69db775..25ceb0bc9 100644 --- a/centreon-plugins/apps/slack/restapi/plugin.pm +++ b/centreon-plugins/apps/slack/restapi/plugin.pm @@ -30,10 +30,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + %{$self->{modes} => { 'count-channels' => 'apps::slack::restapi::mode::countchannels', - 'count-members' => 'apps::slack::restapi::mode::countmembers', - ); + 'count-members' => 'apps::slack::restapi::mode::countmembers' + }; $self->{custom_modes}{restapi} = 'apps::slack::restapi::custom::api'; return $self;