+ Enhance java tomcat

This commit is contained in:
garnier-quentin 2015-06-30 11:12:24 +02:00
parent faf6578d2b
commit 1a03fec584
3 changed files with 13 additions and 5 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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));
}
}