diff --git a/centreon-plugins/apps/java/hibernate/jmx/mode/stats.pm b/centreon-plugins/apps/java/hibernate/jmx/mode/stats.pm index fad0cd08f..52a67d7b3 100644 --- a/centreon-plugins/apps/java/hibernate/jmx/mode/stats.pm +++ b/centreon-plugins/apps/java/hibernate/jmx/mode/stats.pm @@ -148,7 +148,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = "hibernate_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "hibernate_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/java/solr/jmx/mode/cacheusage.pm b/centreon-plugins/apps/java/solr/jmx/mode/cacheusage.pm index 0f8a1fe05..acbb09e12 100644 --- a/centreon-plugins/apps/java/solr/jmx/mode/cacheusage.pm +++ b/centreon-plugins/apps/java/solr/jmx/mode/cacheusage.pm @@ -131,7 +131,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = "solr_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "solr_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/java/solr/jmx/mode/requesthandlerusage.pm b/centreon-plugins/apps/java/solr/jmx/mode/requesthandlerusage.pm index 30f0cd6be..9f6814e7f 100644 --- a/centreon-plugins/apps/java/solr/jmx/mode/requesthandlerusage.pm +++ b/centreon-plugins/apps/java/solr/jmx/mode/requesthandlerusage.pm @@ -128,7 +128,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = "solr_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "solr_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/java/zookeeper/jmx/mode/stats.pm b/centreon-plugins/apps/java/zookeeper/jmx/mode/stats.pm index 812dd2ee2..6b98b318e 100644 --- a/centreon-plugins/apps/java/zookeeper/jmx/mode/stats.pm +++ b/centreon-plugins/apps/java/zookeeper/jmx/mode/stats.pm @@ -141,7 +141,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = "zookeeper_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "zookeeper_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm index 45f1e3ffb..9e48b2c8f 100644 --- a/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm +++ b/centreon-plugins/apps/protocols/jmx/mode/numericvalue.pm @@ -142,7 +142,7 @@ sub check_value { if ($self->{attributes}->{type} =~ /^counter$/i) { if (!defined($self->{datas})) { $self->{datas} = {}; - $self->{statefile_cache}->read(statefile => "jmxstandard_" . $self->{mode} . '_' . md5_hex($self->{connector}->{url} . ' ' . $self->{option_results}->{mbean_pattern})); + $self->{statefile_cache}->read(statefile => "jmxstandard_" . $self->{mode} . '_' . md5_hex($self->{connector}->get_connection_info() . ' ' . $self->{option_results}->{mbean_pattern})); } my $old_timestamp = $self->{statefile_cache}->get(name => 'timestamp'); diff --git a/centreon-plugins/apps/tomcat/jmx/mode/connectorusage.pm b/centreon-plugins/apps/tomcat/jmx/mode/connectorusage.pm index 80aa205c8..4ab1dedbc 100644 --- a/centreon-plugins/apps/tomcat/jmx/mode/connectorusage.pm +++ b/centreon-plugins/apps/tomcat/jmx/mode/connectorusage.pm @@ -213,7 +213,7 @@ sub manage_selection { $self->{tomcatconnector}->{$connector} = { %{$self->{tomcatconnector}->{$connector}}, %{$result->{$key}} }; } - $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/tomcat/jmx/mode/datasourceusage.pm b/centreon-plugins/apps/tomcat/jmx/mode/datasourceusage.pm index 80e60cfb6..b1360f721 100644 --- a/centreon-plugins/apps/tomcat/jmx/mode/datasourceusage.pm +++ b/centreon-plugins/apps/tomcat/jmx/mode/datasourceusage.pm @@ -189,7 +189,7 @@ sub manage_selection { }; } - $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/apps/tomcat/jmx/mode/webappssessions.pm b/centreon-plugins/apps/tomcat/jmx/mode/webappssessions.pm index b1f36813a..165826a02 100644 --- a/centreon-plugins/apps/tomcat/jmx/mode/webappssessions.pm +++ b/centreon-plugins/apps/tomcat/jmx/mode/webappssessions.pm @@ -184,7 +184,7 @@ sub manage_selection { }; } - $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "tomcat_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/centreon-plugins/centreon/common/jvm/mode/classcount.pm b/centreon-plugins/centreon/common/jvm/mode/classcount.pm index 9558c4260..9282f35c5 100644 --- a/centreon-plugins/centreon/common/jvm/mode/classcount.pm +++ b/centreon-plugins/centreon/common/jvm/mode/classcount.pm @@ -20,168 +20,79 @@ package centreon::common::jvm::mode::classcount; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::values; -use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); -my $instance_mode; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, + ]; -my $maps_counters = { - class => { - '000_current' => { set => { key_values => [ { name => 'current' } ], - output_template => 'Current : %s', - perfdatas => [ - { label => 'current', value => 'current_absolute', template => '%s', min => 0 }, - ], - } - }, - '001_loaded' => { set => { key_values => [ { name => 'loaded', diff => 1 } ], - output_template => 'Loaded : %s', - perfdatas => [ - { label => 'loaded', value => 'loaded_absolute', template => '%s', min => 0 }, - ], - } - }, - '003_unloaded' => { set => { key_values => [ { name => 'unloaded', diff => 1 } ], - output_template => 'Unloaded : %s', - perfdatas => [ - { label => 'unloaded', value => 'unloaded_absolute', template => '%s', min => 0 }, - ], - } - }, + $self->{maps_counters}->{global} = [ + { label => 'current', set => { + key_values => [ { name => 'LoadedClassCount' } ], + output_template => 'Current : %s', + perfdatas => [ + { label => 'current', value => 'LoadedClassCount_absolute', template => '%s', min => 0 }, + ], + } }, -}; + { label => 'loaded', set => { + key_values => [ { name => 'TotalLoadedClassCount', diff => 1 } ], + output_template => 'Loaded : %s', + perfdatas => [ + { label => 'loaded', value => 'TotalLoadedClassCount_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'unloaded', set => { + key_values => [ { name => 'UnloadedClassCount', diff => 1 } ], + output_template => 'Unloaded : %s', + perfdatas => [ + { label => 'unloaded', value => 'UnloadedClassCount_absolute', template => '%s', min => 0 }, + ], + } + }, + ]; +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Class "; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { }); - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - - foreach my $key (('class')) { - foreach (keys %{$maps_counters->{$key}}) { - my ($id, $name) = split /_/; - if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { - $options{options}->add_options(arguments => { - 'warning-' . $name . ':s' => { name => 'warning-' . $name }, - 'critical-' . $name . ':s' => { name => 'critical-' . $name }, - }); - } - $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new( - statefile => $self->{statefile_value}, - output => $self->{output}, perfdata => $self->{perfdata}, - label => $name); - $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); - } - } return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach my $key (('class')) { - foreach (keys %{$maps_counters->{$key}}) { - $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); - } - } - - $self->{statefile_value}->check_options(%options); - $instance_mode = $self; - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } -} - -sub run { - my ($self, %options) = @_; - $self->{connector} = $options{custom}; - - $self->manage_selection(); - - $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "jvm_standard_" . $self->{mode} . '_' . md5_hex($self->{connector}->{url})); - $self->{new_datas}->{last_timestamp} = time(); - - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters->{class}}) { - my $obj = $maps_counters->{class}->{$_}->{obj}; - $obj->set(instance => 'global'); - - my ($value_check) = $obj->execute(values => $self->{global}, - new_datas => $self->{new_datas}); - - if ($value_check != 0) { - $long_msg .= $long_msg_append . $obj->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $obj->threshold_check(); - push @exits, $exit2; - - my $output = $obj->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $obj->perfdata(); - } - - my $exit = $self->{output}->get_most_critical(status => [ @exits ]); - if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->{output}->output_add(severity => $exit, - short_msg => "Class $short_msg" - ); - } else { - $self->{output}->output_add(short_msg => "Class $long_msg"); - } - - $self->{statefile_value}->write(data => $self->{new_datas}); - $self->{output}->display(); - $self->{output}->exit(); -} - sub manage_selection { my ($self, %options) = @_; my $mbean = 'java.lang:type=ClassLoading'; - $self->{request} = [ + my $request = [ { mbean => $mbean, attributes => [ { name => 'UnloadedClassCount' }, { name => 'LoadedClassCount' }, { name => 'TotalLoadedClassCount' } ] }, ]; - my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); + my $result = $options{custom}->get_attributes(request => $request, nothing_quit => 1); + + $self->{global} = { %{$result->{$mbean}} }; - $self->{global} = {}; - $self->{global}->{unloaded} = $result->{$mbean}->{UnloadedClassCount} if (defined($result->{$mbean}->{UnloadedClassCount})); - $self->{global}->{loaded} = $result->{$mbean}->{TotalLoadedClassCount} if (defined($result->{$mbean}->{TotalLoadedClassCount})); - $self->{global}->{current} = $result->{$mbean}->{LoadedClassCount} if (defined($result->{$mbean}->{LoadedClassCount})); + $self->{cache_name} = "jvm_standard_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } 1; @@ -194,6 +105,11 @@ Check Java Class Loading Mbean. =over 8 +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='current' + =item B<--warning-*> Threshold warning. @@ -206,4 +122,4 @@ Can be: 'unloaded', 'loaded', 'current'. =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/jvm/mode/gcusage.pm b/centreon-plugins/centreon/common/jvm/mode/gcusage.pm index 129f2f2f3..786add013 100644 --- a/centreon-plugins/centreon/common/jvm/mode/gcusage.pm +++ b/centreon-plugins/centreon/common/jvm/mode/gcusage.pm @@ -100,7 +100,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = "jvm_standard_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' . + $self->{cache_name} = "jvm_standard_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } @@ -136,4 +136,4 @@ Can be: 'count', 'time' (ms). =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm index c9817e8e4..62ed2883d 100644 --- a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm +++ b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm @@ -36,7 +36,9 @@ my %mapping_memory = ( 'PS Perm Gen' => 'permanent', 'Perm Gen' => 'permanent', 'Metaspace' => 'permanent', + 'JIT data cache' => 'permanent', 'Code Cache' => 'code', + 'JIT Code Cache' => 'code', 'CMS Old Gen' => 'tenured', 'PS Old Gen' => 'tenured', 'Tenured Gen' => 'tenured', diff --git a/centreon-plugins/centreon/common/jvm/mode/threads.pm b/centreon-plugins/centreon/common/jvm/mode/threads.pm index c5e913ffa..544f0d21e 100644 --- a/centreon-plugins/centreon/common/jvm/mode/threads.pm +++ b/centreon-plugins/centreon/common/jvm/mode/threads.pm @@ -20,168 +20,79 @@ package centreon::common::jvm::mode::threads; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::values; -use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); -my $instance_mode; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, + ]; -my $maps_counters = { - threads => { - '000_active' => { set => { key_values => [ { name => 'active' } ], - output_template => 'Active : %s', - perfdatas => [ - { label => 'active', value => 'active_absolute', template => '%s', min => 0 }, - ], - } - }, - '001_started' => { set => { key_values => [ { name => 'started', diff => 1 } ], - output_template => 'Started : %s', - perfdatas => [ - { label => 'started', value => 'started_absolute', template => '%s', min => 0 }, - ], - } - }, - '003_daemon' => { set => { key_values => [ { name => 'daemon' } ], - output_template => 'Daemon : %s', - perfdatas => [ - { label => 'daemon', value => 'daemon_absolute', template => '%s', min => 0 }, - ], - } - }, + $self->{maps_counters}->{global} = [ + { label => 'active', set => { + key_values => [ { name => 'ThreadCount' } ], + output_template => 'Active : %s', + perfdatas => [ + { label => 'active', value => 'ThreadCount_absolute', template => '%s', min => 0 }, + ], + } }, -}; + { label => 'started', set => { + key_values => [ { name => 'TotalStartedThreadCount', diff => 1 } ], + output_template => 'Started : %s', + perfdatas => [ + { label => 'started', value => 'TotalStartedThreadCount_absolute', template => '%s', min => 0 }, + ], + } + }, + { label => 'daemon', set => { + key_values => [ { name => 'DaemonThreadCount' } ], + output_template => 'Daemon : %s', + perfdatas => [ + { label => 'daemon', value => 'DaemonThreadCount_absolute', template => '%s', min => 0 }, + ], + } + }, + ]; +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Threads "; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; $self->{version} = '1.0'; $options{options}->add_options(arguments => { }); - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - - foreach my $key (('threads')) { - foreach (keys %{$maps_counters->{$key}}) { - my ($id, $name) = split /_/; - if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { - $options{options}->add_options(arguments => { - 'warning-' . $name . ':s' => { name => 'warning-' . $name }, - 'critical-' . $name . ':s' => { name => 'critical-' . $name }, - }); - } - $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new( - statefile => $self->{statefile_value}, - output => $self->{output}, perfdata => $self->{perfdata}, - label => $name); - $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); - } - } return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - foreach my $key (('threads')) { - foreach (keys %{$maps_counters->{$key}}) { - $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); - } - } - - $self->{statefile_value}->check_options(%options); - $instance_mode = $self; - - $self->{overload_th} = {}; - foreach my $val (@{$self->{option_results}->{threshold_overload}}) { - if ($val !~ /^(.*?),(.*?),(.*)$/) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); - $self->{output}->option_exit(); - } - my ($section, $status, $filter) = ($1, $2, $3); - if ($self->{output}->is_litteral_status(status => $status) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); - $self->{output}->option_exit(); - } - $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); - push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; - } -} - -sub run { - my ($self, %options) = @_; - $self->{connector} = $options{custom}; - - $self->manage_selection(); - - $self->{new_datas} = {}; - $self->{statefile_value}->read(statefile => "jvm_standard_" . $self->{mode} . '_' . md5_hex($self->{connector}->{url})); - $self->{new_datas}->{last_timestamp} = time(); - - my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); - my @exits; - foreach (sort keys %{$maps_counters->{threads}}) { - my $obj = $maps_counters->{threads}->{$_}->{obj}; - $obj->set(instance => 'global'); - - my ($value_check) = $obj->execute(values => $self->{global}, - new_datas => $self->{new_datas}); - - if ($value_check != 0) { - $long_msg .= $long_msg_append . $obj->output_error(); - $long_msg_append = ', '; - next; - } - my $exit2 = $obj->threshold_check(); - push @exits, $exit2; - - my $output = $obj->output(); - $long_msg .= $long_msg_append . $output; - $long_msg_append = ', '; - - if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { - $short_msg .= $short_msg_append . $output; - $short_msg_append = ', '; - } - - $obj->perfdata(); - } - - my $exit = $self->{output}->get_most_critical(status => [ @exits ]); - if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->{output}->output_add(severity => $exit, - short_msg => "Threads $short_msg" - ); - } else { - $self->{output}->output_add(short_msg => "Threads $long_msg"); - } - - $self->{statefile_value}->write(data => $self->{new_datas}); - $self->{output}->display(); - $self->{output}->exit(); -} - sub manage_selection { my ($self, %options) = @_; my $mbean = 'java.lang:type=Threading'; - $self->{request} = [ - { mbean => $mbean, attributes => [ { name => 'TotalStartedThreadCount' }, { name => 'ThreadCount' }, { name => 'DaemonThreadCount' } ] }, + my $request = [ + { mbean => $mbean, attributes => [ { name => 'TotalStartedThreadCount' }, { name => 'ThreadCount' }, { name => 'DaemonThreadCount' } ] }, ]; - my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); + my $result = $options{custom}->get_attributes(request => $request, nothing_quit => 1); + + $self->{global} = { %{$result->{$mbean}} }; - $self->{global} = {}; - $self->{global}->{started} = $result->{$mbean}->{TotalStartedThreadCount} if (defined($result->{$mbean}->{TotalStartedThreadCount})); - $self->{global}->{active} = $result->{$mbean}->{ThreadCount} if (defined($result->{$mbean}->{ThreadCount})); - $self->{global}->{daemon} = $result->{$mbean}->{DaemonThreadCount} if (defined($result->{$mbean}->{DaemonThreadCount})); + $self->{cache_name} = "jvm_standard_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } 1; @@ -206,4 +117,4 @@ Can be: 'active', 'started', 'daemon'. =back -=cut \ No newline at end of file +=cut diff --git a/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm b/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm index fb1f83915..2d1a96b9d 100644 --- a/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm +++ b/centreon-plugins/centreon/common/protocols/jmx/custom/jolokia.pm @@ -146,6 +146,14 @@ sub check_options { return 1; } +sub get_connection_info { + my ($self, %options) = @_; + + my $connection_info = $self->{url}; + $connection_info .= '_' . $self->{proxy_url} if (defined($self->{proxy_url})); + return $connection_info; +} + sub connect { my ($self, %options) = @_;