From 409611b73aa1fe88f968b010f317fa75fba18b8d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 30 Jun 2015 11:12:24 +0200 Subject: [PATCH] + Enhance java tomcat --- centreon-plugins/centreon/common/jvm/mode/cpuload.pm | 4 ++-- centreon-plugins/centreon/common/jvm/mode/loadaverage.pm | 8 +++++++- .../centreon/common/jvm/mode/memorydetailed.pm | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/centreon/common/jvm/mode/cpuload.pm b/centreon-plugins/centreon/common/jvm/mode/cpuload.pm index 933e7d2fa..adcda9708 100644 --- a/centreon-plugins/centreon/common/jvm/mode/cpuload.pm +++ b/centreon-plugins/centreon/common/jvm/mode/cpuload.pm @@ -101,13 +101,13 @@ sub run { $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100)); $self->{output}->perfdata_add(label => 'SystemCpuLoad', unit => '%', - value => $result->{"java.lang:type=OperatingSystem"}->{SystemCpuLoad} * 100, + value => sprintf("%.2f", $result->{"java.lang:type=OperatingSystem"}->{SystemCpuLoad} * 100), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-system'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-system'), min => 0, max => 100); $self->{output}->perfdata_add(label => 'ProcessCpuLoad', unit => '%', - value => $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100, + value => sprintf("%.2f", $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-process'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-process'), min => 0, max => 100); diff --git a/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm b/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm index c6a745df1..80eed0c8a 100644 --- a/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm +++ b/centreon-plugins/centreon/common/jvm/mode/loadaverage.pm @@ -79,6 +79,13 @@ sub run { my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1); my $load = $result->{"java.lang:type=OperatingSystem"}->{SystemLoadAverage}; + if ($load == -1) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "System load average is not set"); + $self->{output}->display(); + $self->{output}->exit(); + } + my $exit = $self->{perfdata}->threshold_check(value => $load, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); @@ -93,7 +100,6 @@ sub run { $self->{output}->display(); $self->{output}->exit(); - } 1; diff --git a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm index bad1d41b1..bfef71f93 100644 --- a/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm +++ b/centreon-plugins/centreon/common/jvm/mode/memorydetailed.pm @@ -49,9 +49,11 @@ my %mapping_memory = ( 'PS Survivor Space' => 'survivor', 'CMS Perm Gen' => 'permanent', 'PS Perm Gen' => 'permanent', + 'Perm Gen' => 'permanent', 'Code Cache' => 'code', 'CMS Old Gen' => 'tenured', 'PS Old Gen' => 'tenured', + 'Tenured Gen' => 'tenured', ); @@ -109,7 +111,7 @@ sub run { my $memtype = $1; my $prct = $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{used} / $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{max} * 100; - $self->{output}->perfdata_add(label => $mapping_memory{$memtype}, + $self->{output}->perfdata_add(label => $mapping_memory{$memtype}, unit => 'B', value => $result->{"java.lang:name=" . $memtype . ",type=MemoryPool"}->{Usage}->{used}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $mapping_memory{$memtype}, total => $result->{"java.lang:name=" . $memtype . ",type=MemoryPool"}->{Usage}->{used}, cast_int => 1), warning => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $mapping_memory{$memtype}, total => $result->{"java.lang:name=" . $memtype . ",type=MemoryPool"}->{Usage}->{used}, cast_int => 1), @@ -122,7 +124,7 @@ sub run { $self->{output}->output_add(long_msg => sprintf("%s usage %.2f%%", $memtype, $prct)); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("%s usage %.2f%% ", $memtype, $prct})); + short_msg => sprintf("%s usage %.2f%% ", $memtype, $prct)); } }