Refs #5385
This commit is contained in:
parent
aa54a4bd90
commit
bb370cfea2
|
@ -35,13 +35,12 @@
|
||||||
# Based on Apache Mode by Simon BOMM
|
# Based on Apache Mode by Simon BOMM
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
package apps::tomcat::web::mode::application;
|
package apps::tomcat::web::mode::applications;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use apps::tomcat::web::mode::libconnect;
|
use centreon::plugins::httplib;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -59,7 +58,7 @@ sub new {
|
||||||
"password:s" => { name => 'password' },
|
"password:s" => { name => 'password' },
|
||||||
"proxyurl:s" => { name => 'proxyurl' },
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout', default => '3' },
|
||||||
"path:s" => { name => 'path', default => '/manager/text/list' },
|
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
|
||||||
"name:s" => { name => 'name' },
|
"name:s" => { name => 'name' },
|
||||||
"regexp" => { name => 'use_regexp' },
|
"regexp" => { name => 'use_regexp' },
|
||||||
"regexp-isensitive" => { name => 'use_regexpi' },
|
"regexp-isensitive" => { name => 'use_regexpi' },
|
||||||
|
@ -93,7 +92,7 @@ sub check_options {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $webcontent = apps::tomcat::web::mode::libconnect::connect($self);
|
my $webcontent = centreon::plugins::httplib::connect($self);
|
||||||
|
|
||||||
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
||||||
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
||||||
|
@ -207,9 +206,9 @@ Specify password for basic authentification (Mandatory if --credentials is speci
|
||||||
|
|
||||||
Threshold for HTTP timeout
|
Threshold for HTTP timeout
|
||||||
|
|
||||||
=item B<--path>
|
=item B<--url-path>
|
||||||
|
|
||||||
Path to the Tomcat Manager List (Default: '/manager/text/list')
|
Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list')
|
||||||
Tomcat 6: '/manager/list'
|
Tomcat 6: '/manager/list'
|
||||||
Tomcat 7: '/manager/text/list'
|
Tomcat 7: '/manager/text/list'
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
###############################################################################
|
|
||||||
# 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 timeelapsedutable,
|
|
||||||
# regardless of the license terms of these independent modules, and to copy and
|
|
||||||
# distribute the resulting timeelapsedutable 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
|
|
||||||
# Author : Florian Asche <info@florian-asche.de>
|
|
||||||
#
|
|
||||||
# Based on De Bodt Lieven plugin
|
|
||||||
# Based on Apache Mode by Simon BOMM
|
|
||||||
####################################################################################
|
|
||||||
|
|
||||||
package apps::tomcat::web::mode::libconnect;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use LWP::UserAgent;
|
|
||||||
|
|
||||||
sub connect {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
my $ua = LWP::UserAgent->new( protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout});
|
|
||||||
my $connection_exit = defined($options{connection_exit}) ? $options{connection_exit} : 'unknown';
|
|
||||||
|
|
||||||
my ($response, $content);
|
|
||||||
|
|
||||||
my $req = HTTP::Request->new( GET => $self->{option_results}->{proto}."://" .$self->{option_results}->{hostname}.':'.$self->{option_results}->{port}.$self->{option_results}->{path});
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{credentials})) {
|
|
||||||
$req->authorization_basic($self->{option_results}->{username}, $self->{option_results}->{password});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{proxyurl})) {
|
|
||||||
$ua->proxy(['http', 'https'], $self->{option_results}->{proxyurl});
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $ua->request($req);
|
|
||||||
|
|
||||||
if ($response->is_success) {
|
|
||||||
$content = $response->content;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $connection_exit,
|
|
||||||
short_msg => $response->status_line);
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
|
@ -38,10 +38,9 @@
|
||||||
package apps::tomcat::web::mode::listapplication;
|
package apps::tomcat::web::mode::listapplication;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use apps::tomcat::web::mode::libconnect;
|
use centreon::plugins::httplib;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -59,7 +58,7 @@ sub new {
|
||||||
"password:s" => { name => 'password' },
|
"password:s" => { name => 'password' },
|
||||||
"proxyurl:s" => { name => 'proxyurl' },
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout', default => '3' },
|
||||||
"path:s" => { name => 'path', default => '/manager/text/list' },
|
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
|
||||||
"filter-name:s" => { name => 'filter_name', },
|
"filter-name:s" => { name => 'filter_name', },
|
||||||
"filter-state:s" => { name => 'filter_state', },
|
"filter-state:s" => { name => 'filter_state', },
|
||||||
"filter-path:s" => { name => 'filter_path', },
|
"filter-path:s" => { name => 'filter_path', },
|
||||||
|
@ -92,7 +91,7 @@ sub check_options {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $webcontent = apps::tomcat::web::mode::libconnect::connect($self);
|
my $webcontent = centreon::plugins::httplib::connect($self);
|
||||||
|
|
||||||
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
||||||
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
||||||
|
@ -184,9 +183,9 @@ Specify password for basic authentification (Mandatory if --credentials is speci
|
||||||
|
|
||||||
Threshold for HTTP timeout
|
Threshold for HTTP timeout
|
||||||
|
|
||||||
=item B<--path>
|
=item B<--url-path>
|
||||||
|
|
||||||
Path to the Tomcat Manager List (Default: '/manager/text/list')
|
Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list')
|
||||||
Tomcat 6: '/manager/list'
|
Tomcat 6: '/manager/list'
|
||||||
Tomcat 7: '/manager/text/list'
|
Tomcat 7: '/manager/text/list'
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,9 @@
|
||||||
package apps::tomcat::web::mode::sessions;
|
package apps::tomcat::web::mode::sessions;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use apps::tomcat::web::mode::libconnect;
|
use centreon::plugins::httplib;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -59,7 +58,7 @@ sub new {
|
||||||
"password:s" => { name => 'password' },
|
"password:s" => { name => 'password' },
|
||||||
"proxyurl:s" => { name => 'proxyurl' },
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout', default => '3' },
|
||||||
"path:s" => { name => 'path', default => '/manager/text/list' },
|
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
"name:s" => { name => 'name' },
|
"name:s" => { name => 'name' },
|
||||||
|
@ -104,7 +103,7 @@ sub check_options {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $webcontent = apps::tomcat::web::mode::libconnect::connect($self);
|
my $webcontent = centreon::plugins::httplib::connect($self);
|
||||||
|
|
||||||
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) {
|
||||||
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
|
||||||
|
@ -210,9 +209,9 @@ Specify password for basic authentification (Mandatory if --credentials is speci
|
||||||
|
|
||||||
Threshold for HTTP timeout
|
Threshold for HTTP timeout
|
||||||
|
|
||||||
=item B<--path>
|
=item B<--url-path>
|
||||||
|
|
||||||
Path to the Tomcat Manager List (Default: '/manager/text/list')
|
Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list')
|
||||||
Tomcat 6: '/manager/list'
|
Tomcat 6: '/manager/list'
|
||||||
Tomcat 7: '/manager/text/list'
|
Tomcat 7: '/manager/text/list'
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
%{$self->{modes}} = (
|
||||||
'application' => 'apps::tomcat::web::mode::application',
|
'applications' => 'apps::tomcat::web::mode::applications',
|
||||||
'list-application' => 'apps::tomcat::web::mode::listapplication',
|
'list-application' => 'apps::tomcat::web::mode::listapplication',
|
||||||
'sessions' => 'apps::tomcat::web::mode::sessions',
|
'sessions' => 'apps::tomcat::web::mode::sessions',
|
||||||
'threads' => 'apps::tomcat::web::mode::threads',
|
'threads' => 'apps::tomcat::web::mode::threads',
|
||||||
|
|
Loading…
Reference in New Issue