diff --git a/apps/backup/tsm/local/mode/actlog.pm b/apps/backup/tsm/local/mode/actlog.pm index 99a69e746..6d8e920ef 100644 --- a/apps/backup/tsm/local/mode/actlog.pm +++ b/apps/backup/tsm/local/mode/actlog.pm @@ -26,7 +26,7 @@ use strict; use warnings; use centreon::plugins::misc; use centreon::plugins::statefile; -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) = @_; @@ -56,30 +56,31 @@ sub set_counters { ]; $self->{maps_counters}->{alarm} = [ - { label => 'status', threshold => 0, set => { + { label => 'status', + type => 2, + warning_default => '%{severity} =~ /warning/', + critical_default => '%{severity} =~ /error|severe/', + set => { key_values => [ { name => 'message' }, { name => 'severity' }, { name => 'since' }, { name => 'generation_time' } ], 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 } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-time:s" => { name => 'filter_time', default => '1' }, - "warning-status:s" => { name => 'warning_status', default => '%{severity} =~ /warning/' }, - "critical-status:s" => { name => 'critical_status', default => '%{severity} =~ /error|severe/' }, - "memory" => { name => 'memory' }, - "timezone:s" => { name => 'timezone' }, - }); + $options{options}->add_options(arguments => { + "filter-time:s" => { name => 'filter_time', default => '1' }, + "memory" => { name => 'memory' }, + "timezone:s" => { name => 'timezone' } + }); centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', error_msg => "Cannot load module 'DateTime'."); diff --git a/apps/backup/tsm/local/mode/drives.pm b/apps/backup/tsm/local/mode/drives.pm index 155e7165b..9c39be1a0 100644 --- a/apps/backup/tsm/local/mode/drives.pm +++ b/apps/backup/tsm/local/mode/drives.pm @@ -29,74 +29,74 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' } ]; $self->{maps_counters}->{global} = [ - { label => 'online', set => { + { label => 'online', nlabel => 'drives.online.count', set => { key_values => [ { name => 'online' } ], output_template => 'online : %s', perfdatas => [ - { label => 'online', value => 'online', template => '%s', min => 0 }, - ], + { label => 'online', template => '%s', min => 0 } + ] } }, - { label => 'offline', set => { + { label => 'offline', nlabel => 'drives.offline.count', set => { key_values => [ { name => 'offline' } ], output_template => 'offline : %s', perfdatas => [ - { label => 'offline', value => 'offline', template => '%s', min => 0 }, - ], + { label => 'offline', template => '%s', min => 0 } + ] } }, - { label => 'unavailable', set => { + { label => 'unavailable', nlabel => 'drives.unavailable.count', set => { key_values => [ { name => 'unavailable' } ], output_template => 'unavailable : %s', perfdatas => [ - { label => 'unavailable', value => 'unavailable', template => '%s', min => 0 }, - ], + { label => 'unavailable', template => '%s', min => 0 } + ] } }, - { label => 'empty', set => { + { label => 'empty', nlabel => 'drives.empty.count', set => { key_values => [ { name => 'empty' } ], output_template => 'empty : %s', perfdatas => [ - { label => 'empty', value => 'empty', template => '%s', min => 0 }, - ], + { label => 'empty', template => '%s', min => 0 } + ] } }, - { label => 'loaded', set => { + { label => 'loaded', nlabel => 'drives.loaded.count', set => { key_values => [ { name => 'loaded' } ], output_template => 'loaded : %s', perfdatas => [ - { label => 'loaded', value => 'loaded', template => '%s', min => 0 }, - ], + { label => 'loaded', template => '%s', min => 0 } + ] } }, - { label => 'unloaded', set => { + { label => 'unloaded', nlabel => 'drives.unloaded.count', set => { key_values => [ { name => 'unloaded' } ], output_template => 'unloaded : %s', perfdatas => [ - { label => 'unloaded', value => 'unloaded', template => '%s', min => 0 }, - ], + { label => 'unloaded', template => '%s', min => 0 } + ] } }, - { label => 'reserved', set => { + { label => 'reserved', nlabel => 'drives.reserved.count', set => { key_values => [ { name => 'reserved' } ], output_template => 'reserved : %s', perfdatas => [ - { label => 'reserved', value => 'reserved', template => '%s', min => 0 }, - ], + { label => 'reserved', template => '%s', min => 0 } + ] } }, - { label => 'unknown', set => { + { label => 'unknown', nlabel => 'drives.unknown.count', set => { key_values => [ { name => 'unknown' } ], output_template => 'unknown : %s', perfdatas => [ - { label => 'unknown', value => 'unknown', template => '%s', min => 0 }, - ], + { label => 'unknown', template => '%s', min => 0 } + ] } - }, + } ]; } @@ -108,7 +108,7 @@ sub prefix_global_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => diff --git a/apps/backup/tsm/local/mode/nodes.pm b/apps/backup/tsm/local/mode/nodes.pm index c718dadc4..158066642 100644 --- a/apps/backup/tsm/local/mode/nodes.pm +++ b/apps/backup/tsm/local/mode/nodes.pm @@ -29,40 +29,40 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0 }, + { name => 'global', type => 0 } ]; $self->{maps_counters}->{global} = [ - { label => 'associated', set => { + { label => 'associated', nlabel => 'nodes.associated.count', set => { key_values => [ { name => 'associated' } ], - output_template => 'Total Associated Nodes : %s', + output_template => 'total associated nodes : %s', perfdatas => [ - { label => 'associated', value => 'associated', template => '%s', min => 0 }, - ], + { label => 'associated', template => '%s', min => 0 } + ] } }, - { label => 'non-associated', set => { + { label => 'non-associated', nlabel => 'nodes.nonassociated.count', set => { key_values => [ { name => 'non_associated' } ], - output_template => 'Total Non Associated Nodes : %s', + output_template => 'total non associated nodes : %s', perfdatas => [ - { label => 'non_associated', value => 'non_associated', template => '%s', min => 0 }, - ], + { label => 'non_associated', template => '%s', min => 0 } + ] } }, - { label => 'locked', set => { + { label => 'locked', nlabel => 'nodes.locked.count', set => { key_values => [ { name => 'locked' } ], - output_template => 'Total Locked Nodes : %s', + output_template => 'total locked nodes : %s', perfdatas => [ - { label => 'locked', value => 'locked', template => '%s', min => 0 }, - ], + { label => 'locked', template => '%s', min => 0 } + ] } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => diff --git a/apps/backup/tsm/local/mode/sessions.pm b/apps/backup/tsm/local/mode/sessions.pm index 3d07f934d..7b93cc984 100644 --- a/apps/backup/tsm/local/mode/sessions.pm +++ b/apps/backup/tsm/local/mode/sessions.pm @@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::misc; -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,30 +53,30 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'sessions', type => 1, cb_prefix_output => 'prefix_sessions_output', message_multiple => 'All sessions are ok' }, + { name => 'sessions', type => 1, cb_prefix_output => 'prefix_sessions_output', message_multiple => 'All sessions are ok' } ]; $self->{maps_counters}->{global} = [ - { label => 'total', set => { + { label => 'total', nlabel => 'sessions.count', set => { key_values => [ { name => 'total' } ], - output_template => 'Total Sessions : %s', + output_template => 'total sessions : %s', perfdatas => [ - { label => 'total', value => 'total', template => '%s', min => 0 }, - ], + { label => 'total', template => '%s', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{sessions} = [ - { label => 'status', threshold => 0, set => { + { label => 'status', type => 2, set => { key_values => [ { name => 'session_id' }, { name => 'client_name' }, { name => 'session_type' }, { name => 'state' }, { name => 'since' }, { name => 'generation_time' } ], 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, } - }, + } ]; } @@ -88,18 +88,15 @@ sub prefix_sessions_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-clientname:s" => { name => 'filter_clientname' }, - "filter-sessiontype:s" => { name => 'filter_sessiontype' }, - "filter-state:s" => { name => 'filter_state' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - "timezone:s" => { name => 'timezone' }, - }); + $options{options}->add_options(arguments => { + "filter-clientname:s" => { name => 'filter_clientname' }, + "filter-sessiontype:s" => { name => 'filter_sessiontype' }, + "filter-state:s" => { name => 'filter_state' }, + "timezone:s" => { name => 'timezone' }, + }); centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', error_msg => "Cannot load module 'DateTime'."); diff --git a/apps/backup/tsm/local/mode/volumes.pm b/apps/backup/tsm/local/mode/volumes.pm index 0a70bcf32..629dad3b5 100644 --- a/apps/backup/tsm/local/mode/volumes.pm +++ b/apps/backup/tsm/local/mode/volumes.pm @@ -30,78 +30,78 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'volumes', type => 1, cb_prefix_output => 'prefix_volumes_output', message_multiple => 'All volumes are ok' }, + { name => 'volumes', type => 1, cb_prefix_output => 'prefix_volumes_output', message_multiple => 'All volumes are ok' } ]; $self->{maps_counters}->{global} = [ - { label => 'total', set => { + { label => 'total', nlabel => 'volumes.count', set => { key_values => [ { name => 'total' } ], - output_template => 'Volumes Total : %s', + output_template => 'volumes total : %s', perfdatas => [ - { label => 'total', value => 'total', template => '%s', min => 0 }, - ], + { label => 'total', template => '%s', min => 0 } + ] } }, - { label => 'online', set => { + { label => 'online', nlabel => 'volumes.online.count', set => { key_values => [ { name => 'online' } ], - output_template => 'Online : %s', + output_template => 'online : %s', perfdatas => [ - { label => 'online', value => 'online', template => '%s', min => 0 }, - ], + { label => 'online', template => '%s', min => 0 } + ] } }, - { label => 'offline', set => { + { label => 'offline', nlabel => 'volumes.offline.count', set => { key_values => [ { name => 'offline' } ], - output_template => 'Offline : %s', + output_template => 'offline : %s', perfdatas => [ - { label => 'offline', value => 'offline', template => '%s', min => 0 }, - ], + { label => 'offline', template => '%s', min => 0 } + ] } }, - { label => 'empty', set => { + { label => 'empty', nlabel => 'volumes.empty.count', set => { key_values => [ { name => 'empty' } ], - output_template => 'Empty : %s', + output_template => 'empty : %s', perfdatas => [ - { label => 'empty', value => 'empty', template => '%s', min => 0 }, - ], + { label => 'empty', template => '%s', min => 0 } + ] } }, - { label => 'pending', set => { + { label => 'pending', nlabel => 'volumes.pending.count', set => { key_values => [ { name => 'pending' } ], - output_template => 'Pending : %s', + output_template => 'pending : %s', perfdatas => [ - { label => 'pending', value => 'pending', template => '%s', min => 0 }, - ], + { label => 'pending', template => '%s', min => 0 } + ] } }, - { label => 'filling', set => { + { label => 'filling', nlabel => 'volumes.filling.count', set => { key_values => [ { name => 'filling' } ], - output_template => 'Filling : %s', + output_template => 'filling : %s', perfdatas => [ - { label => 'filling', value => 'filling', template => '%s', min => 0 }, - ], + { label => 'filling', template => '%s', min => 0 } + ] } }, - { label => 'full', set => { + { label => 'full', nlabel => 'volumes.full.count', set => { key_values => [ { name => 'full' } ], - output_template => 'Full : %s', + output_template => 'full : %s', perfdatas => [ - { label => 'full', value => 'full', template => '%s', min => 0 }, - ], + { label => 'full', template => '%s', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{volumes} = [ - { label => 'used', set => { + { label => 'used', nlabel => 'volume.space.usage.percentage', set => { key_values => [ { name => 'prct_utilized' }, { name => 'display' } ], output_template => 'Usage : %s %%', perfdatas => [ - { label => 'used', value => 'prct_utilized', template => '%s', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'used', template => '%s', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -113,14 +113,13 @@ sub prefix_volumes_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-volume:s" => { name => 'filter_volume' }, - "filter-stgpool:s" => { name => 'filter_stgpool' }, - }); + $options{options}->add_options(arguments => { + "filter-volume:s" => { name => 'filter_volume' }, + "filter-stgpool:s" => { name => 'filter_stgpool' } + }); return $self; } diff --git a/apps/backup/tsm/local/plugin.pm b/apps/backup/tsm/local/plugin.pm index 6eb0eccb9..1a9226194 100644 --- a/apps/backup/tsm/local/plugin.pm +++ b/apps/backup/tsm/local/plugin.pm @@ -30,13 +30,13 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + $self->{modes} = { 'actlog' => 'apps::backup::tsm::local::mode::actlog', 'drives' => 'apps::backup::tsm::local::mode::drives', 'nodes' => 'apps::backup::tsm::local::mode::nodes', 'sessions' => 'apps::backup::tsm::local::mode::sessions', 'volumes' => 'apps::backup::tsm::local::mode::volumes', - ); + }; $self->{custom_modes}{api} = 'apps::backup::tsm::local::custom::api'; return $self;