commit
b0e10b2274
|
@ -0,0 +1,72 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2014 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package apps::tomcat::jmx::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
|
||||
'memory' => 'centreon::common::jvm::mode::memory',
|
||||
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
|
||||
'load-average' => 'centreon::common::jvm::mode::loadaverage',
|
||||
'thread-count' => 'centreon::common::jvm::mode::threadcount',
|
||||
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
|
||||
'class-count' => 'centreon::common::jvm::mode::classcount',
|
||||
'test' => 'centreon::common::jvm::mode::test',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
TOMCAT JMX plugin. Need Jolokia agent.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,159 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon BOMM <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::classcount;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-loaded:s" => { name => 'warning_loaded', default => '5000' },
|
||||
"critical-loaded:s" => { name => 'critical_loaded', default => '5000' },
|
||||
"warning-total:s" => { name => 'warning_total', default => '5500' },
|
||||
"critical-total:s" => { name => 'critical_total', default => '5500' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-loaded', value => $self->{option_results}->{warning_loaded})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-loaded threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-loaded', value => $self->{option_results}->{critical_loaded})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-loaded threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-total', value => $self->{option_results}->{warning_total})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-total threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-total', value => $self->{option_results}->{critical_total})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-total threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=ClassLoading", attributes => [ { name => 'UnloadedClassCount' }, { name => 'LoadedClassCount' }, { name => 'TotalLoadedClassCount' } ] },
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $result->{"java.lang:type=ClassLoading"}->{TotalLoadedClassCount},
|
||||
threshold => [ { label => 'critical-total', exit_litteral => 'critical' }, { label => 'warning-total', 'exit_litteral' => 'warning'} ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $result->{"java.lang:type=ClassLoading"}->{LoadedClassCount},
|
||||
threshold => [ { label => 'critical-loaded', exit_litteral => 'critical' }, { label => 'warning-loaded', 'exit_litteral' => 'warning'} ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Loaded Class Count : %i, Total Loaded Class : %i, Unloaded Class Count : %i",
|
||||
$result->{"java.lang:type=ClassLoading"}->{LoadedClassCount}, $result->{"java.lang:type=ClassLoading"}->{TotalLoadedClassCount},
|
||||
$result->{"java.lang:type=ClassLoading"}->{UnloadedClassCount}));
|
||||
|
||||
$self->{output}->perfdata_add(label => 'TotalLoadedClassCount',
|
||||
value => $result->{"java.lang:type=ClassLoading"}->{TotalLoadedClassCount},
|
||||
warning => $self->{option_results}->{warning_total},
|
||||
critical => $self->{option_results}->{critical_total},
|
||||
min => 0);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'LoadedClassCount',
|
||||
value => $result->{"java.lang:type=ClassLoading"}->{LoadedClassCount},
|
||||
warning => $self->{option_results}->{warning_loaded},
|
||||
critical => $self->{option_results}->{critical_loaded},
|
||||
min => 0);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'UnloadedClassCount',
|
||||
value => $result->{"java.lang:type=ClassLoading"}->{UnloadedClassCount},
|
||||
min => 0);
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Java Class Loading Mbean (Mbean java.lang:type=ClassLoading).
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=classcount --warning-loaded 60 --critical-loaded 75 --warning-total 65 --critical-total 75
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-loaded>
|
||||
|
||||
Current number of loaded class triggering a warning
|
||||
|
||||
=item B<--critical-loaded>
|
||||
|
||||
Current number of loaded class triggering a critical
|
||||
|
||||
=item B<--warning-total>
|
||||
|
||||
Total number of loaded class triggering a warning
|
||||
|
||||
=item B<--critical-total>
|
||||
|
||||
Total number total of loaded class triggering a critical
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::cpuload;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-system:s" => { name => 'warning_system', default => '80' },
|
||||
"critical-system:s" => { name => 'critical_system', default => '90' },
|
||||
"warning-process:s" => { name => 'warning_process', default => '80' },
|
||||
"critical-process:s" => { name => 'critical_process', default => '90' }
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-system', value => $self->{option_results}->{warning_system})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-system threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-system', value => $self->{option_results}->{critical_system})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-system threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-process', value => $self->{option_results}->{warning_process})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-process threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-process', value => $self->{option_results}->{critical_process})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-process threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=OperatingSystem", attributes => [ { name => 'SystemCpuLoad' }, { name => 'ProcessCpuLoad' } ] }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $result->{"java.lang:type=OperatingSystem"}->{SystemCpuLoad} * 100,
|
||||
threshold => [ { label => 'critical-system', exit_litteral => 'critical' }, { label => 'warning-system', 'exit_litteral' => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100,
|
||||
threshold => [ { label => 'critical-process', exit_litteral => 'critical' }, { label => 'warning-process', 'exit_litteral' => 'warning'} ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("SystemCpuLoad: %.2f%% - ProcessCpuLoad: %.2f%%",
|
||||
$result->{"java.lang:type=OperatingSystem"}->{SystemCpuLoad} * 100, $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100));
|
||||
|
||||
$self->{output}->perfdata_add(label => 'SystemCpuLoad',
|
||||
value => $result->{"java.lang:type=OperatingSystem"}->{SystemCpuLoad} * 100,
|
||||
warning => $self->{option_results}->{warning_system},
|
||||
critical => $self->{option_results}->{critical_system},
|
||||
min => 0, max => 100);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'ProcessCpuLoad',
|
||||
value => $result->{"java.lang:type=OperatingSystem"}->{ProcessCpuLoad} * 100,
|
||||
warning => $self->{option_results}->{warning_process},
|
||||
critical => $self->{option_results}->{critical_process},
|
||||
min => 0, max => 100);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check JVM SystemCpuLoad and ProcessCpuLoad (From 0 to 1 where 1 means 100% of CPU ressources are in use, here we * by 100 for convenience).
|
||||
WARN : Probably not work for java -version < 7.
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia --mode=cpu-load --warning-system 50 --critical-system 75 --warning-process 60 --critical-process 80
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-system>
|
||||
|
||||
Threshold warning of System cpuload
|
||||
|
||||
=item B<--critical-system>
|
||||
|
||||
Threshold critical of System cpuload
|
||||
|
||||
=item B<--warning-process>
|
||||
|
||||
Threshold warning of Process cpuload
|
||||
|
||||
=item B<--critical-process>
|
||||
|
||||
Threshold critical of Process cpuload
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::fdusage;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', default => '80' },
|
||||
"critical:s" => { name => 'critical', default => '90' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=OperatingSystem", attributes => [ { name => 'MaxFileDescriptorCount' }, { name => 'OpenFileDescriptorCount' } ] }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $prct_fd = $result->{"java.lang:type=OperatingSystem"}->{OpenFileDescriptorCount} / $result->{"java.lang:type=OperatingSystem"}->{MaxFileDescriptorCount} * 100;
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $prct_fd,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', 'exit_litteral' => 'warning' } ]);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'fd',
|
||||
value => $result->{"java.lang:type=OperatingSystem"}->{OpenFileDescriptorCount},
|
||||
warning => $self->{option_results}->{warning} / 100 * $result->{"java.lang:type=OperatingSystem"}->{MaxFileDescriptorCount},
|
||||
critical => $self->{option_results}->{critical} / 100 * $result->{"java.lang:type=OperatingSystem"}->{MaxFileDescriptorCount},
|
||||
min => 0, max => $result->{"java.lang:type=OperatingSystem"}->{MaxFileDescriptorCount});
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("File descriptor percentage usage: %2.f%%", $prct_fd));
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check number/percentage of file descriptors
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=fd-usage --warning 60 --critical 75
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning percentage concerning fd capacity
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical percentage concerning fd capacity
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::loadaverage;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', default => '2' },
|
||||
"critical:s" => { name => 'critical', default => '3' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=OperatingSystem", attributes => [ { name => 'SystemLoadAverage' } ] }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $load = $result->{"java.lang:type=OperatingSystem"}->{SystemLoadAverage};
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $load,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', 'exit_litteral' => 'warning' } ]);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'load',
|
||||
value => $result->{"java.lang:type=OperatingSystem"}->{SystemLoadAverage},
|
||||
warning => $self->{option_results}->{warning},
|
||||
critical => $self->{option_results}->{critical},
|
||||
min => 0);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("System load average: %.2f%%", $load));
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system load average
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=load-average --warning 2 --critical 3
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Warning threshold for loadaverage
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical threshold for loadaverage
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-heap:s" => { name => 'warning_heap', default => '80' },
|
||||
"critical-heap:s" => { name => 'critical_heap', default => '90' },
|
||||
"warning-nonheap:s" => { name => 'warning_nonheap', default => '80' },
|
||||
"critical-nonheap:s" => { name => 'critical_nonheap', default => '90' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-heap', value => $self->{option_results}->{warning_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-heap', value => $self->{option_results}->{critical_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-nonheap', value => $self->{option_results}->{warning_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-nonheap', value => $self->{option_results}->{critical_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=Memory" }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $prct_heap = $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max} * 100;
|
||||
my $prct_nonheap = $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max} * 100;
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $prct_heap,
|
||||
threshold => [ { label => 'critical-heap', exit_litteral => 'critical' }, { label => 'warning-heap', 'exit_litteral' => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $prct_nonheap,
|
||||
threshold => [ { label => 'critical-nonheap', exit_litteral => 'critical' }, { label => 'warning-nonheap', 'exit_litteral' => 'warning'} ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("HeapMemory Usage: %.2f%% - NonHeapMemoryUsage : %.2f%%",
|
||||
$prct_heap, $prct_nonheap));
|
||||
|
||||
$self->{output}->perfdata_add(label => 'HeapMemoryUsage', unit => 'B',
|
||||
value => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used},
|
||||
warning => $self->{option_results}->{warning_heap} / 100 * $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used},
|
||||
critical => $self->{option_results}->{critical_heap} / 100 * $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used},
|
||||
min => 0, max => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max});
|
||||
|
||||
$self->{output}->perfdata_add(label => 'NonHeapMemoryUsage', unit => 'B',
|
||||
value => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used},
|
||||
warning => $self->{option_results}->{warning_nonheap} / 100 * $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used},
|
||||
critical => $self->{option_results}->{critical_nonheap} / 100 * $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used},
|
||||
min => 0, max => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max});
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Java Heap and NonHeap Memory usage (Mbean java.lang:type=Memory).
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=memory --warning-heap 60 --critical-heap 75 --warning-nonheap 65 --critical-nonheap 75
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-heap>
|
||||
|
||||
Threshold warning of Heap memory usage
|
||||
|
||||
=item B<--critical-heap>
|
||||
|
||||
Threshold critical of Heap memory usage
|
||||
|
||||
=item B<--warning-nonheap>
|
||||
|
||||
Threshold warning of NonHeap memory usage
|
||||
|
||||
=item B<--critical-nonheap>
|
||||
|
||||
Threshold critical of NonHeap memory usage
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::memorydetailed;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %mapping_memory = (
|
||||
'Eden Space' => 'eden',
|
||||
'Par Eden Space' => 'eden',
|
||||
'PS Eden Space' => 'eden',
|
||||
'Survivor Space' => 'survivor',
|
||||
'Par Survivor Space' => 'survivor',
|
||||
'PS Survivor Space' => 'survivor',
|
||||
'CMS Perm Gen' => 'permanent',
|
||||
'PS Perm Gen' => 'permanent',
|
||||
'Code Cache' => 'code',
|
||||
'CMS Old Gen' => 'tenured',
|
||||
'PS Old Gen' => 'tenured',
|
||||
);
|
||||
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-eden:s" => { name => 'warning_eden', default => '80' },
|
||||
"critical-eden:s" => { name => 'critical_eden', default => '90' },
|
||||
"warning-survivor:s" => { name => 'warning_survivor', default => '80' },
|
||||
"critical-survivor:s" => { name => 'critical_survivor', default => '90' },
|
||||
"warning-tenured:s" => { name => 'warning_tenured', default => '80' },
|
||||
"critical-tenured:s" => { name => 'critical_tenured', default => '90' },
|
||||
"warning-permanent:s" => { name => 'warning_permanent', default => '80' },
|
||||
"critical-permanent:s" => { name => 'critical_permanent', default => '90' },
|
||||
"warning-code:s" => { name => 'warning_code', default => '80' },
|
||||
"critical-code:s" => { name => 'critical_code', default => '90' }
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $label ('warning_eden', 'critical_eden', 'warning_survivor', 'critical_survivor', 'warning_tenured', 'critical_tenured', 'warning_permanent', 'critical_permanent', 'warning_code', 'critical_code') {
|
||||
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
|
||||
my ($label_opt) = $label;
|
||||
$label_opt =~ tr/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
my %prct;
|
||||
my $exit;
|
||||
my @exits;
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=MemoryPool,name=*", attributes => [ { name => 'Usage' } ] }
|
||||
];
|
||||
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All memories within bounds');
|
||||
|
||||
|
||||
foreach my $key (keys %$result) {
|
||||
|
||||
$key =~ /name=(.*?),type/;
|
||||
my $memtype = $1;
|
||||
|
||||
$prct{$memtype} = $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},
|
||||
value => $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{used},
|
||||
warning => $self->{option_results}->{'warning_'.$mapping_memory{$memtype}} / 100 * $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{used},
|
||||
critical => $self->{option_results}->{'critical_'.$mapping_memory{$memtype}} / 100 * $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{used},
|
||||
min => 0, max => $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{max});
|
||||
|
||||
$exit = $self->{perfdata}->threshold_check(value => $prct{$memtype},
|
||||
threshold => [ { label => 'critical_'.$mapping_memory{$memtype}, exit_litteral => 'critical' },
|
||||
{ label => 'warning_'.$mapping_memory{$memtype}, 'exit_litteral' => 'warning'} ]);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("%s usage is %.2f%%", $memtype, $prct{$memtype}));
|
||||
push @exits, $exit;
|
||||
if ($exit ne 'ok') {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("%s usage:%.2f%% ", $memtype, $prct{$memtype}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check JVM Memory Pools :
|
||||
|
||||
Eden Space (heap) (-eden) : The pool from which memory is initially allocated for most objects.
|
||||
Survivor Space (heap) (-survivor) : The pool containing objects that have survived the garbage collection of the Eden space.
|
||||
Tenured Generation (heap) (-tenured) : The pool containing objects that have existed for some time in the survivor space.
|
||||
Permanent Generation (non-heap) (-permanent) : The pool containing all the reflective data of the virtual machine itself, such as class and method objects.
|
||||
Code Cache (non-heap) (-code) : The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::tomcat::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:00/jolokia-war --mode=memory-detailed --warning-eden 60 --critical-eden 75 --warning-survivor 65 --critical-survivor 75
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-eden>
|
||||
|
||||
Threshold warning of Heap 'Eden Space' memory usage
|
||||
|
||||
=item B<--critical-eden>
|
||||
|
||||
Threshold critical of Heap 'Survivor Space' memory usage
|
||||
|
||||
=item B<--warning-tenured>
|
||||
|
||||
Threshold warning of Heap 'Tenured Generation' memory usage
|
||||
|
||||
=item B<--critical-tenured>
|
||||
|
||||
Threshold critical of Heap 'Tenured Generation' memory usage
|
||||
|
||||
=item B<--warning-survivor>
|
||||
|
||||
Threshold warning of Heap 'Survivor Space' memory usage
|
||||
|
||||
=item B<--critical-survivor>
|
||||
|
||||
Threshold critical of Heap 'Survivor Space' memory usage
|
||||
|
||||
=item B<--warning-permanent>
|
||||
|
||||
Threshold warning of NonHeap 'Permanent Generation' memory usage
|
||||
|
||||
=item B<--critical-permanent>
|
||||
|
||||
Threshold critical of NonHeap 'Permanent Generation' memory usage
|
||||
|
||||
=item B<--warning-code>
|
||||
|
||||
Threshold warning of NonHeap 'Code Cache' memory usage
|
||||
|
||||
=item B<--critical-code>
|
||||
|
||||
Threshold critical of NonHeap 'Code Cache' memory usage
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,123 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
# Simon Bomm <sbomm@centreon.com>
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::jvm::mode::threadcount;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', default => '80' },
|
||||
"critical:s" => { name => 'critical', default => '90' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=Threading", attributes => [ { name => 'ThreadCount' } ] },
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result->{"java.lang:type=Threading"}->{ThreadCount},
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', 'exit_litteral' => 'warning' } ]);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'ThreadCount', unit => 'thread',
|
||||
value => $result->{"java.lang:type=Threading"}->{ThreadCount},
|
||||
warning => $self->{option_results}->{warning},
|
||||
critical => $self->{option_results}->{critical},
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Thread Count : %i", $result->{"java.lang:type=Threading"}->{ThreadCount}));
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Java Heap and NonHeap Memory usage (Mbean java.lang:type=Memory).
|
||||
|
||||
Example:
|
||||
perl centreon_plugins.pl --plugin=apps::weblogic::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=thread-count --warning 10 --critical 15
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue