refactoring kingdee: wip #1784
This commit is contained in:
parent
a645afdfc1
commit
aea3bc21f1
|
@ -40,12 +40,12 @@ sub new {
|
|||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s@" => { name => 'hostname' },
|
||||
"proto:s@" => { name => 'proto' },
|
||||
"port:s@" => { name => 'port' },
|
||||
"username:s@" => { name => 'username' },
|
||||
"password:s@" => { name => 'password' },
|
||||
"timeout:s@" => { name => 'timeout' },
|
||||
'hostname:s@' => { name => 'hostname' },
|
||||
'proto:s@' => { name => 'proto' },
|
||||
'port:s@' => { name => 'port' },
|
||||
'username:s@' => { name => 'username' },
|
||||
'password:s@' => { name => 'password' },
|
||||
'timeout:s@' => { name => 'timeout' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
@ -55,7 +55,6 @@ sub new {
|
|||
$self->{http} = centreon::plugins::http->new(%options);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
|
@ -91,7 +90,7 @@ sub check_options {
|
|||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify hostname option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
@ -115,6 +114,18 @@ sub build_options_for_httplib {
|
|||
$self->{option_results}->{password} = $self->{password};
|
||||
}
|
||||
|
||||
sub get_hostname {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname};
|
||||
}
|
||||
|
||||
sub get_port {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{port};
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -21,81 +21,66 @@
|
|||
|
||||
package apps::kingdee::eas::mode::classloading;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'class-loaded', nlabel => 'java.class.loaded.count', set => {
|
||||
key_values => [ { name => 'loadedclass' } ],
|
||||
output_template => 'class loaded: %s',
|
||||
perfdatas => [
|
||||
{ value => 'loadedclass_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'class-unloaded', nlabel => 'java.class.unloaded.count', set => {
|
||||
key_values => [ { name => 'unloadedclass', diff => 1 } ],
|
||||
output_template => 'class unloaded: %s',
|
||||
perfdatas => [
|
||||
{ value => 'unloadedclass_absolute', 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, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkclassloading.jsp" },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkclassloading.jsp" },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
sub manage_selection {
|
||||
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->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /(LoadedClassCount|UnloadedClassCount)/i) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find classloading status."
|
||||
);
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot find classloading status.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my ($loadedclasscount, $unloadedclasscount) = (0, 0);
|
||||
|
||||
if ($webcontent =~ /LoadedClassCount=\s*(\d+)/mi) {
|
||||
$loadedclasscount = $1;
|
||||
}
|
||||
if ($webcontent =~ /UnloadedClassCount=\s*(\d+)/mi) {
|
||||
$unloadedclasscount = $1;
|
||||
}
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $loadedclasscount,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warning', 'exit_litteral' => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("ClassLoaded: %d", $loadedclasscount));
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("ClassUnloaded: %d", $unloadedclasscount));
|
||||
|
||||
$self->{output}->perfdata_add(label => "LoadedClassCount", unit => '',
|
||||
value => sprintf("%d", $loadedclasscount),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[UnloadedClassCount]", unit => '',
|
||||
value => sprintf("%d", $unloadedclasscount),
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
$self->{global} = { loadedclass => 0, unloadedclass => 0 };
|
||||
$self->{global}->{loadedclass} = $1 if ($webcontent =~ /LoadedClassCount=\s*(\d+)/mi);
|
||||
$self->{global}->{unloadedclass} = $1 if ($webcontent =~ /UnloadedClassCount=\s*(\d+)/mi);
|
||||
|
||||
$self->{cache_name} = 'kingdee_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -112,13 +97,10 @@ Check EAS application classLoading status.
|
|||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkclassloading.jsp')
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning Threshold for class loaded
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for class unloaded
|
||||
Thresholds.
|
||||
Can be: 'class-loaded', 'class-unloaded'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -21,125 +21,142 @@
|
|||
|
||||
package apps::kingdee::eas::mode::datasource;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'datasource', type => 1, cb_prefix_output => 'prefix_datasource_output', skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{datasource} = [
|
||||
{ label => 'pool-size-initial', nlabel => 'datasource.pool.size.initial.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'init_pool_size' } ],
|
||||
output_template => 'pool initial size: %s',
|
||||
perfdatas => [
|
||||
{ value => 'init_pool_size_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'pool-size-max', nlabel => 'datasource.pool.size.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'max_pool_size' } ],
|
||||
output_template => 'pool max size: %s',
|
||||
perfdatas => [
|
||||
{ value => 'max_pool_size_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'idle-timeout', nlabel => 'datasource.idle.timeout.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'idle_timeout' } ],
|
||||
output_template => 'idle timeout: %s',
|
||||
perfdatas => [
|
||||
{ value => 'idle_timeout_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'connections-active', nlabel => 'datasource.connections.active.count', set => {
|
||||
key_values => [ { name => 'active_conn_count' } ],
|
||||
output_template => 'connections active: %s',
|
||||
perfdatas => [
|
||||
{ value => 'active_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'connections-current', nlabel => 'datasource.connections.current.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'cur_conn_count' } ],
|
||||
output_template => 'connections current: %s',
|
||||
perfdatas => [
|
||||
{ value => 'cur_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'connections-max', nlabel => 'datasource.connections.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'max_conn_count' } ],
|
||||
output_template => 'connections max: %s',
|
||||
perfdatas => [
|
||||
{ value => 'max_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'connections-created', nlabel => 'datasource.connections.created.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'create_count', diff => 1 } ],
|
||||
output_template => 'connections created: %s',
|
||||
perfdatas => [
|
||||
{ value => 'create_count_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'connections-closed', nlabel => 'datasource.connections.closed.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'close_count', diff => 1 } ],
|
||||
output_template => 'connections closed: %s',
|
||||
perfdatas => [
|
||||
{ value => 'close_count_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_datasource_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Datasource '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkdatasources.jsp" },
|
||||
"datasource:s" => { name => 'datasource' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkdatasources.jsp" },
|
||||
'datasource:s' => { name => 'datasource' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{datasource}) || $self->{option_results}->{datasource} eq "") {
|
||||
$self->{output}->add_option_msg(short_msg => "Missing datasource name.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{option_results}->{url_path} .= "?ds=" . $self->{option_results}->{datasource};
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /^Name=/i) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find datasource \'" . $self->{option_results}->{datasource} . "\' status."
|
||||
);
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot find datasource '" . $self->{option_results}->{datasource} . "' status.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $init_pool_size = -1;
|
||||
my $max_pool_size = -1;
|
||||
my $idle_timeout = -1;
|
||||
my $cur_conn_count = -1;
|
||||
my $cur_avail_conn_count = -1;
|
||||
my $max_conn_count = -1;
|
||||
my $create_count = -1;
|
||||
my $close_count = -1;
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}} = { display => $self->{option_results}->{datasource} };
|
||||
|
||||
$init_pool_size = $1 if $webcontent =~ /InitialPoolSize=(\d+)\s/i;
|
||||
$max_pool_size = $1 if $webcontent =~ /MaxPoolSize=(\d+)\s/i;
|
||||
$idle_timeout = $1 if $webcontent =~ /IdleTimeout=(\d+)\s/i;
|
||||
$cur_conn_count = $1 if $webcontent =~ /CurrentConnectionCount=(\d+)\s/i;
|
||||
$cur_avail_conn_count = $1 if $webcontent =~ /CurrentAvailableConnectionCount=(\d+)\s/i;
|
||||
$max_conn_count = $1 if $webcontent =~ /MaxConnectionCount=(\d+)\s/i;
|
||||
$create_count = $1 if $webcontent =~ /CreateCount=(\d+)\s/i;
|
||||
$close_count = $1 if $webcontent =~ /CloseCount=(\d+)\s/i;
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{init_pool_size} = $1 if ($webcontent =~ /InitialPoolSize=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{max_pool_size} = $1 if ($webcontent =~ /MaxPoolSize=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{idle_timeout} = $1 if ($webcontent =~ /IdleTimeout=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{cur_conn_count} = $1 if ($webcontent =~ /CurrentConnectionCount=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{cur_avail_conn_count} = $1 if ($webcontent =~ /CurrentAvailableConnectionCount=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{max_conn_count} = $1 if ($webcontent =~ /MaxConnectionCount=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{create_count} = $1 if ($webcontent =~ /CreateCount=(\d+)\s/i);
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{close_count} = $1 if ($webcontent =~ /CloseCount=(\d+)\s/i);
|
||||
|
||||
my $active_conn_count = $cur_conn_count - $cur_avail_conn_count;
|
||||
$self->{datasource}->{$self->{option_results}->{datasource}}->{active_conn_count} = $self->{datasource}->{$self->{option_results}->{datasource}}->{cur_conn_count} - $self->{datasource}->{$self->{option_results}->{datasource}}->{cur_avail_conn_count};
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("InitialPoolSize: %d", $init_pool_size));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxPoolSize: %d", $max_pool_size));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("IdleTimeout: %d", $idle_timeout));
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $active_conn_count, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("ActiveConnectionCount: %d", $active_conn_count));
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CurrentConnectionCount: %d", $cur_conn_count));
|
||||
#$self->{output}->output_add(severity => "ok", short_msg => sprintf("CurrentAvailableConnectionCount: %d", $cur_avail_conn_count));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxConnectionCount: %d", $max_conn_count));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CreateCount: %d", $create_count));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CloseCount: %d", $close_count));
|
||||
|
||||
$self->{output}->perfdata_add(label => "InitPoolSize", unit => '',
|
||||
value => sprintf("%d", $init_pool_size),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxPoolSize", unit => '',
|
||||
value => sprintf("%d", $max_pool_size),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "IdleTimeout", unit => '',
|
||||
value => sprintf("%d", $idle_timeout),
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "ActiveConnectionCount", unit => '',
|
||||
value => sprintf("%d", $active_conn_count),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "CurrentConnectionCount", unit => '',
|
||||
value => sprintf("%d", $cur_conn_count),
|
||||
);
|
||||
#$self->{output}->perfdata_add(label => "CurrentAvailableConnectionCount", unit => '',
|
||||
# value => sprintf("%d", $cur_avail_conn_count),
|
||||
# );
|
||||
$self->{output}->perfdata_add(label => "MaxConnectionCount", unit => '',
|
||||
value => sprintf("%d", $max_conn_count),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[CreateCount]", unit => '',
|
||||
value => sprintf("%d", $create_count),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[CloseCount]", unit => '',
|
||||
value => sprintf("%d", $close_count),
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
$self->{cache_name} = 'kingdee_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{datasource}) ? md5_hex($self->{option_results}->{datasource}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -160,13 +177,12 @@ Specify path to get status page. (Default: '/easportal/tools/nagios/checkdatasou
|
|||
|
||||
Specify the datasource name.
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning Threshold for active connection count.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for active connection count.
|
||||
Thresholds.
|
||||
Can be: 'pool-size-initial', 'pool-size-max',
|
||||
'idle-timeout', 'connections-active', 'connections-current',
|
||||
'connections-max', 'connections-created', 'connections-closed'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -0,0 +1,256 @@
|
|||
#
|
||||
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author : CHEN JUN , aladdin.china@gmail.com
|
||||
|
||||
package apps::kingdee::eas::mode::handlers;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'handlers', type => 1, cb_prefix_output => 'prefix_handler_output', message_multiple => 'All handlers are ok', skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{handlers} = [
|
||||
{ label => 'threads-max', nlabel => 'handler.threads.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxthreads' } ],
|
||||
output_template => 'threads max: %s',
|
||||
perfdatas => [
|
||||
{ value => 'maxthreads_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-spare-min', nlabel => 'handler.threads.spare.min.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'minsparethreads' } ],
|
||||
output_template => 'threads spare min: %s',
|
||||
perfdatas => [
|
||||
{ value => 'minsparethreads_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-spare-max', nlabel => 'handler.threads.spare.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxsparethreads' } ],
|
||||
output_template => 'threads spare max: %s',
|
||||
perfdatas => [
|
||||
{ value => 'maxsparethreads_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'queue-size-max', nlabel => 'handler.queue.size.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxqueuesize' } ],
|
||||
output_template => 'max queue size: %s',
|
||||
perfdatas => [
|
||||
{ value => 'maxqueuesize_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'idle-timeout', nlabel => 'handler.idle.timeout.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'idle_timeout' } ],
|
||||
output_template => 'idle timeout: %s',
|
||||
perfdatas => [
|
||||
{ value => 'idle_timeout_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-processed', nlabel => 'handler.threads.processed.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'processedcount', diff => 1 } ],
|
||||
output_template => 'threads processed: %s',
|
||||
perfdatas => [
|
||||
{ value => 'processedcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-current', nlabel => 'handler.threads.current.count', set => {
|
||||
key_values => [ { name => 'currentthreadcount' } ],
|
||||
output_template => 'threads current: %s',
|
||||
perfdatas => [
|
||||
{ value => 'currentthreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-current', nlabel => 'handler.threads.current.count', set => {
|
||||
key_values => [ { name => 'currentthreadcount' } ],
|
||||
output_template => 'threads current: %s',
|
||||
perfdatas => [
|
||||
{ value => 'currentthreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-available', nlabel => 'handler.threads.available.count', set => {
|
||||
key_values => [ { name => 'availablethreadcount' } ],
|
||||
output_template => 'threads available: %s',
|
||||
perfdatas => [
|
||||
{ value => 'availablethreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-busy', nlabel => 'handler.threads.busy.count', set => {
|
||||
key_values => [ { name => 'busythreadcount' } ],
|
||||
output_template => 'threads busy: %s',
|
||||
perfdatas => [
|
||||
{ value => 'busythreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-available-max', nlabel => 'handler.threads.available.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxavailablethreadcount' } ],
|
||||
output_template => 'threads available max: %s',
|
||||
perfdatas => [
|
||||
{ value => 'maxavailablethreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-busy-max', nlabel => 'handler.threads.busy.max.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxbusythreadcount' } ],
|
||||
output_template => 'threads busy max: %s',
|
||||
perfdatas => [
|
||||
{ value => 'maxbusythreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-processedtime-max', nlabel => 'handler.threads.processedtime.max.milliseconds', display_ok => 0, set => {
|
||||
key_values => [ { name => 'maxprocessedtime' } ],
|
||||
output_template => 'threads processed time max: %s ms',
|
||||
perfdatas => [
|
||||
{ value => 'maxprocessedtime_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-created', nlabel => 'handler.threads.created.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'createcount' } ],
|
||||
output_template => 'threads created: %s',
|
||||
perfdatas => [
|
||||
{ value => 'createcount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'threads-destroyed', nlabel => 'handler.threads.destroyed.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'destroycount' } ],
|
||||
output_template => 'threads destroyed: %s',
|
||||
perfdatas => [
|
||||
{ value => 'destroycount_absolute', template => '%s', min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_handler_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Handler '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options( arguments => {
|
||||
'urlpath-httphandler:s' => { name => 'url_path_httphandler', default => "/easportal/tools/nagios/checkhttphandler.jsp" },
|
||||
'urlpath-muxhandler:s' => { name => 'url_path_muxhandler', default => "/easportal/tools/nagios/checkmuxhandler.jsp" },
|
||||
'filter-handler:s' => { name => 'filter_handler' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manager_handler {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{filter_handler}) && $self->{option_results}->{filter_handler} ne "" &&
|
||||
$options{name} !~ /$self->{option_results}->{filter_handler}/
|
||||
) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{'url_path_' . $options{name} . 'handler'});
|
||||
if ($webcontent !~ /MaxThreads=\d+/i) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot find ' . $options{name} . 'handler status in response');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{handlers}->{$options{name}} = { display => $options{name} };
|
||||
$self->{handlers}->{$options{name}}->{maxthreads} = $1 if ($webcontent =~ /MaxThreads=(\d+)/mi);
|
||||
$self->{handlers}->{$options{name}}->{minsparethreads} = $1 if $webcontent =~ /MinSpareThreads=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{maxsparethreads} = $1 if $webcontent =~ /MaxSpareThreads=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{maxqueuesize} = $1 if $webcontent =~ /MaxQueueSize=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{idle_timeout} = $1 if $webcontent =~ /IdleTimeout=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{processedcount} = $1 if $webcontent =~ /ProcessedCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{currentthreadcount} = $1 if $webcontent =~ /CurrentThreadCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{availablethreadcount} = $1 if $webcontent =~ /AvailableThreadCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{busythreadcount} = $1 if $webcontent =~ /BusyThreadCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{maxavailablethreadcount} = $1 if $webcontent =~ /MaxAvailableThreadCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{maxbusythreadcount} = $1 if $webcontent =~ /MaxBusyThreadCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{maxprocessedtime} = $1 if $webcontent =~ /MaxProcessedTime=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{createcount} = $1 if $webcontent =~ /CreateCount=(\d+)/mi ;
|
||||
$self->{handlers}->{$options{name}}->{destroycount} = $1 if $webcontent =~ /DestroyCount=(\d+)/mi ;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{handlers} = {};
|
||||
$self->manager_handler(custom => $options{custom}, name => 'http');
|
||||
$self->manager_handler(custom => $options{custom}, name => 'mux');
|
||||
|
||||
$self->{cache_name} = 'kingdee_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_handler}) ? md5_hex($self->{option_results}->{filter_handler}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check EAS instance handlers (http and mux).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--urlpath-httphandler>
|
||||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkhttphandler.jsp')
|
||||
|
||||
=item B<--urlpath-muxhandler>
|
||||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkmuxhandler.jsp')
|
||||
|
||||
=item B<--filter-handler>
|
||||
|
||||
Handler filter (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'threads-max', 'threads-spare-min', 'threads-spare-max', 'queue-size-max'
|
||||
'idle-timeout', 'threads-processed', 'threads-current', 'threads-current',
|
||||
'threads-available', 'threads-busy', 'threads-available-max', 'threads-busy-max',
|
||||
'threads-processedtime-max', 'threads-created threads-destroyed'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,185 +0,0 @@
|
|||
#
|
||||
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author : CHEN JUN , aladdin.china@gmail.com
|
||||
|
||||
package apps::kingdee::eas::mode::httphandler;
|
||||
|
||||
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;
|
||||
|
||||
$options{options}->add_options(
|
||||
arguments => {
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkhttphandler.jsp" },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
}
|
||||
);
|
||||
|
||||
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->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /MaxThreads=\d+/i) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find httphandler status in response: '" . $webcontent . "'"
|
||||
);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my ($maxthreads, $minsparethreads, $maxsparethreads, $maxqueuesize, $idletimeout, $processedcount) = (0, 0, 0, 0, 0, 0);
|
||||
my ($currentthreadcount, $availablethreadcount, $busythreadcount, $maxavailablethreadcount, $maxbusythreadcount) = (0, 0, 0, 0, 0);
|
||||
my ($maxprocessedtime, $createcount, $destroycount) = (0, 0, 0);
|
||||
|
||||
$maxthreads = $1 if $webcontent =~ /MaxThreads=(\d+)/mi ;
|
||||
$minsparethreads = $1 if $webcontent =~ /MinSpareThreads=(\d+)/mi ;
|
||||
$maxsparethreads = $1 if $webcontent =~ /MaxSpareThreads=(\d+)/mi ;
|
||||
$maxqueuesize = $1 if $webcontent =~ /MaxQueueSize=(\d+)/mi ;
|
||||
$idletimeout = $1 if $webcontent =~ /IdleTimeout=(\d+)/mi ;
|
||||
$processedcount = $1 if $webcontent =~ /ProcessedCount=(\d+)/mi ;
|
||||
$currentthreadcount = $1 if $webcontent =~ /CurrentThreadCount=(\d+)/mi ;
|
||||
$availablethreadcount = $1 if $webcontent =~ /AvailableThreadCount=(\d+)/mi ;
|
||||
$busythreadcount = $1 if $webcontent =~ /BusyThreadCount=(\d+)/mi ;
|
||||
$maxavailablethreadcount = $1 if $webcontent =~ /MaxAvailableThreadCount=(\d+)/mi ;
|
||||
$maxbusythreadcount = $1 if $webcontent =~ /MaxBusyThreadCount=(\d+)/mi ;
|
||||
$maxprocessedtime = $1 if $webcontent =~ /MaxProcessedTime=(\d+)/mi ;
|
||||
$createcount = $1 if $webcontent =~ /CreateCount=(\d+)/mi ;
|
||||
$destroycount = $1 if $webcontent =~ /DestroyCount=(\d+)/mi ;
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxThreads: %d", $maxthreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MinSpareThreads: %d", $minsparethreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxSpareThreads: %d", $maxsparethreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxQueueSize: %d", $maxqueuesize));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("IdleTimeout: %ds", $idletimeout));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("ProcessedCount: %d", $processedcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CurrentThreadCount: %d", $currentthreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("AvailableThreadCount: %d", $availablethreadcount));
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $busythreadcount, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("BusyThreadCount: %d", $busythreadcount));
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxAvailableThreadCount: %d", $maxavailablethreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxBusyThreadCount: %d", $maxbusythreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxProcessedTime: %dms", $maxprocessedtime));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CreateCount: %d", $createcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("DestroyCount: %d", $destroycount));
|
||||
|
||||
$self->{output}->perfdata_add(label => "MaxThreads", unit => '',
|
||||
value => sprintf("%d", $maxthreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MinSpareThreads", unit => '',
|
||||
value => sprintf("%d", $minsparethreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxSpareThreads", unit => '',
|
||||
value => sprintf("%d", $maxsparethreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxQueueSize", unit => '',
|
||||
value => sprintf("%d", $maxqueuesize),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "IdleTimeout", unit => 's',
|
||||
value => sprintf("%d", $idletimeout),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[ProcessedCount]", unit => '',
|
||||
value => sprintf("%d", $processedcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "CurrentThreadCount", unit => '',
|
||||
value => sprintf("%d", $currentthreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "AvailableThreadCount", unit => '',
|
||||
value => sprintf("%d", $availablethreadcount),
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "BusyThreadCount", unit => '',
|
||||
value => sprintf("%d", $busythreadcount),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "MaxAvailableThreadCount", unit => '',
|
||||
value => sprintf("%d", $maxavailablethreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxBusyThreadCount", unit => '',
|
||||
value => sprintf("%d", $maxbusythreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxProcessedTime", unit => 'ms',
|
||||
value => sprintf("%d", $maxprocessedtime),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[CreateCount]", unit => '',
|
||||
value => sprintf("%d", $createcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[DestroyCount]", unit => '',
|
||||
value => sprintf("%d", $destroycount),
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check EAS instance httphandler(Apusic) threads pool status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--urlpath>
|
||||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkhttphandler.jsp')
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Warning Threshold for busy thread count.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for busy thread count.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -21,70 +21,70 @@
|
|||
|
||||
package apps::kingdee::eas::mode::ibmjvmgc;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'collection', nlabel => 'gc.collection.count', set => {
|
||||
key_values => [ { name => 'collection_count', diff => 1 } ],
|
||||
output_template => 'gc collection count: %s',
|
||||
perfdatas => [
|
||||
{ value => 'collection_count_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'collection-time', nlabel => 'gc.collection.time.milliseconds', set => {
|
||||
key_values => [ { name => 'collection_time', diff => 1 } ],
|
||||
output_template => 'gc collection time: %s ms',
|
||||
perfdatas => [
|
||||
{ value => 'collection_time_absolute', template => '%s', min => 0, unit => 'ms' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkgc_j9gen.jsp" },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkgc_j9gen.jsp" },
|
||||
});
|
||||
|
||||
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->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /CollectionCount=\d+/mi) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find ibm jdk j9 gc status."
|
||||
);
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot find ibm jdk j9 gc status');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
my ($collectioncount, $collectiontime) = (0, 0);
|
||||
|
||||
($collectioncount, $collectiontime) = ($1, $2) if ($webcontent =~ /CollectionCount=(\d+)\sCollectionTime=(\d+)/mi);
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CollectionCount: %d", $collectioncount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CollectionTime: %dms", $collectiontime));
|
||||
|
||||
$self->{output}->perfdata_add(label => "c[CollectionCount]", unit => '',
|
||||
value => sprintf("%d", $collectioncount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[CollectionTime]", unit => 'ms',
|
||||
value => sprintf("%d", $collectiontime),
|
||||
);
|
||||
$self->{global} = {};
|
||||
if ($webcontent =~ /CollectionCount=(\d+)\sCollectionTime=(\d+)/mi) {
|
||||
$self->{global}->{collection_count} = $1;
|
||||
$self->{global}->{collection_time} = $2;
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
$self->{cache_name} = 'kingdee_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -101,13 +101,10 @@ Check EAS application jvm gc status.
|
|||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkgc_j9.jsp')
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning Threshold for class loaded
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for class unloaded
|
||||
Thresholds.
|
||||
Can be: 'collection', 'collection-time'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -21,84 +21,74 @@
|
|||
|
||||
package apps::kingdee::eas::mode::javaruntime;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use POSIX;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'uptime', nlabel => 'java.uptime.milliseconds', set => {
|
||||
key_values => [ { name => 'uptime' }, { name => 'uptime_date' } ],
|
||||
output_template => 'java uptime: %s',
|
||||
output_use => 'uptime_date_absolute',
|
||||
perfdatas => [
|
||||
{ value => 'uptime_absolute', template => '%s',
|
||||
unit => 'ms' },
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
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 =>
|
||||
{
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkjavaruntime.jsp" },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkjavaruntime.jsp" },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
sub manage_selection {
|
||||
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->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /VmName=/mi) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find java runtime status."
|
||||
);
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot find java runtime status.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $vmname = $1 if $webcontent =~ /VmName=\'(.*?)\'/i;
|
||||
my $specversion = $1 if $webcontent =~ /SpecVersion=([\d\.]+)/i;
|
||||
my $vmversion = $1 if $webcontent =~ /VmVersion=(.*?)\s/i;
|
||||
my $vender = $1 if $webcontent =~ /VmVendor=\'(.*?)\'/i;
|
||||
my $uptime = $1 if $webcontent =~ /Uptime=(\d*)/i; #unit:ms
|
||||
my $startime = $1 if $webcontent =~ /StartTime=(\d*)/i;
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $uptime / 1000, threshold => [
|
||||
{ label => 'critical', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("Uptime: %s",
|
||||
centreon::plugins::misc::change_seconds(value => floor($uptime / 1000), start => 'd'))
|
||||
);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("%s %s (build %s), %s",
|
||||
$vmname ,$specversion, $vmversion,$vender)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "Uptime", unit => 's',
|
||||
value => sprintf("%d", floor($uptime / 1000)),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "SpecVersion", unit => '',
|
||||
value => sprintf("%s", $specversion),
|
||||
);
|
||||
my ($vmname, $specversion, $vmversion, $vendor, $uptime);
|
||||
$vmname = $1 if ($webcontent =~ /VmName=\'(.*?)\'/i);
|
||||
$specversion = $1 if ($webcontent =~ /SpecVersion=([\d\.]+)/i);
|
||||
$vmversion = $1 if ($webcontent =~ /VmVersion=(.*?)\s/i);
|
||||
$vendor = $1 if ($webcontent =~ /VmVendor=\'(.*?)\'/i);
|
||||
$uptime = $1 if ($webcontent =~ /Uptime=(\d*)/i); #unit:ms
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
'%s %s (build %s), %s',
|
||||
$vmname, $specversion, $vmversion, $vendor
|
||||
)
|
||||
);
|
||||
|
||||
$self->{global} = {
|
||||
uptime => $uptime,
|
||||
uptime_date => centreon::plugins::misc::change_seconds(value => floor($uptime / 1000), start => 'd')
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -115,13 +105,10 @@ Check EAS application java runtime status.
|
|||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkjavaruntime.jsp')
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning Threshold for uptime (sec)
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for uptime (sec)
|
||||
Thresholds.
|
||||
Can be: 'uptime'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -21,277 +21,78 @@
|
|||
|
||||
package apps::kingdee::eas::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'heap', cb_prefix_output => 'prefix_memory_output', type => 0 },
|
||||
{ name => 'nonheap', cb_prefix_output => 'prefix_memory_output', type => 0 },
|
||||
];
|
||||
|
||||
foreach (('heap', 'nonheap')) {
|
||||
$self->{maps_counters}->{$_} = [];
|
||||
foreach my $def ((['init', 0], ['max', 0], ['used', 1], ['commited', 1])) {
|
||||
push @{$self->{maps_counters}->{$_}},
|
||||
{ label => 'memory-' . $_ . '-' . $def->[0], nlabel => 'java.memory.' . $_ . '.' . $def->[0] . '.count', display_ok => $def->[1], set => {
|
||||
key_values => [ { name => $def->[0] } ],
|
||||
output_template => $def->[0] . ': %s',
|
||||
perfdatas => [
|
||||
{ value => $def->[0] . '_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub prefix_memory_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Memory '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
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 => {
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkmemory.jsp" },
|
||||
"warning-heap:s" => { name => 'warning-heap' , default => ",,,"},
|
||||
"warning-nonheap:s" => { name => 'warning-nonheap' , default => ",,,"},
|
||||
"critical-heap:s" => { name => 'critical-heap' , default => ",,,"},
|
||||
"critical-nonheap:s" => { name => 'critical-nonheap' , default => ",,,"},
|
||||
}
|
||||
);
|
||||
$options{options}->add_options( arguments => {
|
||||
'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkmemory.jsp" },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ( $self, %options ) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
($self->{warn_init_heap}, $self->{warn_max_heap}, $self->{warn_used_heap}, $self->{warn_committed_heap})
|
||||
= split /,/, $self->{option_results}->{"warning-heap"};
|
||||
($self->{warn_init_nonheap}, $self->{warn_max_nonheap}, $self->{warn_used_nonheap}, $self->{warn_committed_nonheap})
|
||||
= split /,/, $self->{option_results}->{"warning-nonheap"};
|
||||
($self->{crit_init_heap}, $self->{crit_max_heap}, $self->{crit_used_heap}, $self->{crit_committed_heap})
|
||||
= split /,/, $self->{option_results}->{"critical-heap"};
|
||||
($self->{crit_init_nonheap}, $self->{crit_max_nonheap}, $self->{crit_used_nonheap}, $self->{crit_committed_nonheap})
|
||||
= split /,/, $self->{option_results}->{"critical-nonheap"};
|
||||
|
||||
# warning-heap
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_init_heap', value => $self->{warn_init_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap init threshold '" . $self->{warn_init_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_max_heap', value => $self->{warn_max_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap max threshold '" . $self->{warn_max_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_used_heap', value => $self->{warn_used_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap used threshold '" . $self->{warn_used_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_committed_heap', value => $self->{warn_committed_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap committed threshold '" . $self->{warn_committed_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
# waring-nonheap
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_init_nonheap', value => $self->{warn_init_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap init threshold '" . $self->{warn_init_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_max_nonheap', value => $self->{warn_max_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap max threshold '" . $self->{warn_max_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_used_nonheap', value => $self->{warn_used_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap used threshold '" . $self->{warn_used_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warn_committed_nonheap', value => $self->{warn_committed_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap committed threshold '" . $self->{warn_committed_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
# critical-heap
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_init_heap', value => $self->{crit_init_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap init threshold '" . $self->{crit_init_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_max_heap', value => $self->{crit_max_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap max threshold '" . $self->{crit_max_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_used_heap', value => $self->{crit_used_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap used threshold '" . $self->{crit_used_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_committed_heap', value => $self->{crit_committed_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap committed threshold '" . $self->{crit_committed_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
# critical-nonheap
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_init_nonheap', value => $self->{crit_init_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap init threshold '" . $self->{crit_init_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_max_nonheap', value => $self->{crit_max_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap max threshold '" . $self->{crit_max_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_used_nonheap', value => $self->{crit_used_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap used threshold '" . $self->{crit_used_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'crit_committed_nonheap', value => $self->{crit_committed_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap committed threshold '" . $self->{crit_committed_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ( $self, %options ) = @_;
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /(^Type=HeapMemoryUsage|^Type=NonHeapMemoryUsage)/mi) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find heap or nonheap memory usage status."
|
||||
);
|
||||
if ($webcontent !~ /^(Type=HeapMemoryUsage|Type=NonHeapMemoryUsage)/mi) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot find heap or nonheap memory usage status.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my ( $init_heap, $max_heap, $used_heap, $committed_heap ) = ( 0, 0, 0, 0 );
|
||||
my ( $init_nonheap, $max_nonheap, $used_nonheap, $committed_nonheap ) = ( 0, 0, 0, 0 );
|
||||
if ( $webcontent =~ /^Type=HeapMemoryUsage\sinit=(\d+)\smax=(\d+)\sused=(\d+)\scommitted=(\d+)/mi ){
|
||||
( $init_heap, $max_heap, $used_heap, $committed_heap ) = ( $1, $2, $3, $4 );
|
||||
$self->{output}->output_add(
|
||||
severity => 'ok',
|
||||
short_msg => sprintf(
|
||||
"Heap Memory: init %d , max %d ,used %d ,commited %d",
|
||||
$init_heap, $max_heap, $used_heap, $committed_heap
|
||||
)
|
||||
);
|
||||
if ($webcontent =~ /^Type=HeapMemoryUsage\sinit=(\d+)\smax=(\d+)\sused=(\d+)\scommitted=(\d+)/mi) {
|
||||
$self->{heap} = {
|
||||
init => $1,
|
||||
max => $2,
|
||||
used => $3,
|
||||
commited => $4
|
||||
};
|
||||
}
|
||||
if ( $webcontent =~ /^Type=NonHeapMemoryUsage\sinit=(\d+)\smax=(-{0,1}\d+)\sused=(\d+)\scommitted=(\d+)/mi ){
|
||||
( $init_nonheap, $max_nonheap, $used_nonheap, $committed_nonheap ) = ( $1, $2, $3, $4 );
|
||||
$self->{output}->output_add(
|
||||
severity => 'ok',
|
||||
short_msg => sprintf(
|
||||
"NonHeap Memory: init %d , max %d ,used %d ,commited %d",
|
||||
$init_nonheap, $max_nonheap,
|
||||
$used_nonheap, $committed_nonheap
|
||||
)
|
||||
);
|
||||
if ($webcontent =~ /^Type=NonHeapMemoryUsage\sinit=(\d+)\smax=(-{0,1}\d+)\sused=(\d+)\scommitted=(\d+)/mi) {
|
||||
$self->{nonheap} = {
|
||||
init => $1,
|
||||
max => $2,
|
||||
used => $3,
|
||||
commited => $4
|
||||
};
|
||||
}
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $init_heap,
|
||||
threshold => [ { label => 'crit_init_heap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_init_heap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Init Heap: %d", $init_heap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $max_heap,
|
||||
threshold => [ { label => 'crit_max_heap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_max_heap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Max Heap: %d", $max_heap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $used_heap,
|
||||
threshold => [ { label => 'crit_used_heap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_used_heap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Used Heap: %d", $used_heap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $committed_heap,
|
||||
threshold => [ { label => 'crit_committed_heap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_committed_heap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Committed Heap: %d", $committed_heap)
|
||||
);
|
||||
}
|
||||
|
||||
$exit = $self->{perfdata}->threshold_check(value => $init_nonheap,
|
||||
threshold => [ { label => 'crit_init_nonheap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_init_nonheap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Init NonHeap: %d", $init_nonheap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $max_nonheap,
|
||||
threshold => [ { label => 'crit_max_nonheap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_max_nonheap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Max NonHeap: %d", $max_nonheap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $used_nonheap,
|
||||
threshold => [ { label => 'crit_used_nonheap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_used_nonheap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Used NonHeap: %d", $used_nonheap)
|
||||
);
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $committed_nonheap,
|
||||
threshold => [ { label => 'crit_committed_nonheap', 'exit_litteral' => 'critical' },
|
||||
{ label => 'warn_committed_nonheap', 'exit_litteral' => 'warning' } ]);
|
||||
if ($exit ne "ok"){
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Committed NonHeap: %d", $committed_nonheap)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => "init_heap",
|
||||
value => $init_heap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_init_heap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_init_heap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "max_heap",
|
||||
value => $max_heap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_max_heap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_max_heap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "used_heap",
|
||||
value => $used_heap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_used_heap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_used_heap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "committed_heap",
|
||||
value => $committed_heap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_committed_heap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_committed_heap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "init_nonheap",
|
||||
value => $init_nonheap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_init_nonheap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_init_nonheap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "max_nonheap",
|
||||
value => $max_nonheap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_max_nonheap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_max_nonheap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "used_nonheap",
|
||||
value => $used_nonheap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_used_nonheap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_used_nonheap'),
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "committed_nonheap",
|
||||
value => $committed_nonheap,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_committed_nonheap'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_committed_nonheap'),
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -308,13 +109,11 @@ Check EAS instance heap & nonheap memory usage.
|
|||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkmemory.jsp')
|
||||
|
||||
=item B<--warning-*>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning Threshold (init,max,used,committed), '*' Can be: 'heap', 'nonheap'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical Threshold (init,max,used,committed), '*' Can be: 'heap', 'nonheap'.
|
||||
Thresholds.
|
||||
Can be: 'memory-heap-init', 'memory-heap-max', 'memory-heap-used', 'memory-heap-commited',
|
||||
'memory-nonheap-init', 'memory-nonheap-max', 'memory-nonheap-used', 'memory-nonheap-commited'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
#
|
||||
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Author : CHEN JUN , aladdin.china@gmail.com
|
||||
|
||||
package apps::kingdee::eas::mode::muxhandler;
|
||||
|
||||
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;
|
||||
|
||||
$options{options}->add_options(
|
||||
arguments => {
|
||||
"urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkmuxhandler.jsp" },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
}
|
||||
);
|
||||
|
||||
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->{option_results}->{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->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ( $self, %options ) = @_;
|
||||
|
||||
my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path});
|
||||
|
||||
if ($webcontent !~ /MaxThreads=\d+/i) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Cannot find httphandler status in response: '" . $webcontent . "'"
|
||||
);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my ($maxthreads, $minsparethreads, $maxsparethreads, $maxqueuesize, $idletimeout, $processedcount) = (0, 0, 0, 0, 0, 0);
|
||||
my ($currentthreadcount, $availablethreadcount, $busythreadcount, $maxavailablethreadcount, $maxbusythreadcount) = (0, 0, 0, 0, 0);
|
||||
my ($maxprocessedtime, $createcount, $destroycount) = (0, 0, 0);
|
||||
|
||||
$maxthreads = $1 if $webcontent =~ /MaxThreads=(\d+)/mi ;
|
||||
$minsparethreads = $1 if $webcontent =~ /MinSpareThreads=(\d+)/mi ;
|
||||
$maxsparethreads = $1 if $webcontent =~ /MaxSpareThreads=(\d+)/mi ;
|
||||
$maxqueuesize = $1 if $webcontent =~ /MaxQueueSize=(\d+)/mi ;
|
||||
$idletimeout = $1 if $webcontent =~ /IdleTimeout=(\d+)/mi ;
|
||||
$processedcount = $1 if $webcontent =~ /ProcessedCount=(\d+)/mi ;
|
||||
$currentthreadcount = $1 if $webcontent =~ /CurrentThreadCount=(\d+)/mi ;
|
||||
$availablethreadcount = $1 if $webcontent =~ /AvailableThreadCount=(\d+)/mi ;
|
||||
$busythreadcount = $1 if $webcontent =~ /BusyThreadCount=(\d+)/mi ;
|
||||
$maxavailablethreadcount = $1 if $webcontent =~ /MaxAvailableThreadCount=(\d+)/mi ;
|
||||
$maxbusythreadcount = $1 if $webcontent =~ /MaxBusyThreadCount=(\d+)/mi ;
|
||||
$maxprocessedtime = $1 if $webcontent =~ /MaxProcessedTime=(\d+)/mi ;
|
||||
$createcount = $1 if $webcontent =~ /CreateCount=(\d+)/mi ;
|
||||
$destroycount = $1 if $webcontent =~ /DestroyCount=(\d+)/mi ;
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxThreads: %d", $maxthreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MinSpareThreads: %d", $minsparethreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxSpareThreads: %d", $maxsparethreads));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxQueueSize: %d", $maxqueuesize));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("IdleTimeout: %ds", $idletimeout));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("ProcessedCount: %d", $processedcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CurrentThreadCount: %d", $currentthreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("AvailableThreadCount: %d", $availablethreadcount));
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $busythreadcount, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => sprintf("BusyThreadCount: %d", $busythreadcount));
|
||||
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxAvailableThreadCount: %d", $maxavailablethreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxBusyThreadCount: %d", $maxbusythreadcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("MaxProcessedTime: %dms", $maxprocessedtime));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("CreateCount: %d", $createcount));
|
||||
$self->{output}->output_add(severity => "ok", short_msg => sprintf("DestroyCount: %d", $destroycount));
|
||||
|
||||
$self->{output}->perfdata_add(label => "MaxThreads", unit => '',
|
||||
value => sprintf("%d", $maxthreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MinSpareThreads", unit => '',
|
||||
value => sprintf("%d", $minsparethreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxSpareThreads", unit => '',
|
||||
value => sprintf("%d", $maxsparethreads),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxQueueSize", unit => '',
|
||||
value => sprintf("%d", $maxqueuesize),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "IdleTimeout", unit => 's',
|
||||
value => sprintf("%d", $idletimeout),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[ProcessedCount]", unit => '',
|
||||
value => sprintf("%d", $processedcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "CurrentThreadCount", unit => '',
|
||||
value => sprintf("%d", $currentthreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "AvailableThreadCount", unit => '',
|
||||
value => sprintf("%d", $availablethreadcount),
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "BusyThreadCount", unit => '',
|
||||
value => sprintf("%d", $busythreadcount),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "MaxAvailableThreadCount", unit => '',
|
||||
value => sprintf("%d", $maxavailablethreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxBusyThreadCount", unit => '',
|
||||
value => sprintf("%d", $maxbusythreadcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "MaxProcessedTime", unit => 'ms',
|
||||
value => sprintf("%d", $maxprocessedtime),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[CreateCount]", unit => '',
|
||||
value => sprintf("%d", $createcount),
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "c[DestroyCount]", unit => '',
|
||||
value => sprintf("%d", $destroycount),
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check EAS instance muxhandler(Apusic) threads pool status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--urlpath>
|
||||
|
||||
Set path to get status page. (Default: '/easportal/tools/nagios/checkmuxhandler.jsp')
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Warning Threshold for busy thread count.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical Threshold for busy thread count.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -31,25 +31,24 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'classloading' => 'apps::kingdee::eas::mode::classloading',
|
||||
'memory' => 'apps::kingdee::eas::mode::memory',
|
||||
'javaruntime' => 'apps::kingdee::eas::mode::javaruntime',
|
||||
'datasource' => 'apps::kingdee::eas::mode::datasource',
|
||||
'httphandler' => 'apps::kingdee::eas::mode::httphandler',
|
||||
'muxhandler' => 'apps::kingdee::eas::mode::muxhandler',
|
||||
'transaction' => 'apps::kingdee::eas::mode::transaction',
|
||||
'oraclejvmgc' => 'apps::kingdee::eas::mode::oraclejvmgc',
|
||||
'ibmjvmgc' => 'apps::kingdee::eas::mode::ibmjvmgc',
|
||||
'ormrpc' => 'apps::kingdee::eas::mode::ormrpc',
|
||||
'easlicense' => 'apps::kingdee::eas::mode::easlicense',
|
||||
'activeusers' => 'apps::kingdee::eas::mode::activeusers',
|
||||
'oracleversion' => 'apps::kingdee::eas::mode::oracleversion',
|
||||
'oraclesession' => 'apps::kingdee::eas::mode::oraclesession',
|
||||
'oracletable' => 'apps::kingdee::eas::mode::oracletable',
|
||||
'oraclerecyclebin' => 'apps::kingdee::eas::mode::oraclerecyclebin',
|
||||
'oracleksqltemptable' => 'apps::kingdee::eas::mode::oracleksqltemptable',
|
||||
'oracleredolog' => 'apps::kingdee::eas::mode::oracleredolog',
|
||||
);
|
||||
'classloading' => 'apps::kingdee::eas::mode::classloading',
|
||||
'memory' => 'apps::kingdee::eas::mode::memory',
|
||||
'javaruntime' => 'apps::kingdee::eas::mode::javaruntime',
|
||||
'datasource' => 'apps::kingdee::eas::mode::datasource',
|
||||
'handlers' => 'apps::kingdee::eas::mode::handlers',
|
||||
'transaction' => 'apps::kingdee::eas::mode::transaction',
|
||||
'oraclejvmgc' => 'apps::kingdee::eas::mode::oraclejvmgc',
|
||||
'ibmjvmgc' => 'apps::kingdee::eas::mode::ibmjvmgc',
|
||||
'ormrpc' => 'apps::kingdee::eas::mode::ormrpc',
|
||||
'easlicense' => 'apps::kingdee::eas::mode::easlicense',
|
||||
'activeusers' => 'apps::kingdee::eas::mode::activeusers',
|
||||
'oracleversion' => 'apps::kingdee::eas::mode::oracleversion',
|
||||
'oraclesession' => 'apps::kingdee::eas::mode::oraclesession',
|
||||
'oracletable' => 'apps::kingdee::eas::mode::oracletable',
|
||||
'oraclerecyclebin' => 'apps::kingdee::eas::mode::oraclerecyclebin',
|
||||
'oracleksqltemptable' => 'apps::kingdee::eas::mode::oracleksqltemptable',
|
||||
'oracleredolog' => 'apps::kingdee::eas::mode::oracleredolog',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{api} = 'apps::kingdee::eas::custom::api';
|
||||
return $self;
|
||||
|
|
Loading…
Reference in New Issue