diff --git a/centreon-plugins/apps/tomcat/web/mode/application.pm b/centreon-plugins/apps/tomcat/web/mode/applications.pm similarity index 96% rename from centreon-plugins/apps/tomcat/web/mode/application.pm rename to centreon-plugins/apps/tomcat/web/mode/applications.pm index 9fc319040..3c15c954c 100644 --- a/centreon-plugins/apps/tomcat/web/mode/application.pm +++ b/centreon-plugins/apps/tomcat/web/mode/applications.pm @@ -35,13 +35,12 @@ # 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 strict; use warnings; -use apps::tomcat::web::mode::libconnect; +use centreon::plugins::httplib; sub new { my ($class, %options) = @_; @@ -59,7 +58,7 @@ sub new { "password:s" => { name => 'password' }, "proxyurl:s" => { name => 'proxyurl' }, "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' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, @@ -93,7 +92,7 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $webcontent = apps::tomcat::web::mode::libconnect::connect($self); + my $webcontent = centreon::plugins::httplib::connect($self); while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) { 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 -=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 7: '/manager/text/list' diff --git a/centreon-plugins/apps/tomcat/web/mode/libconnect.pm b/centreon-plugins/apps/tomcat/web/mode/libconnect.pm deleted file mode 100644 index 9955483b6..000000000 --- a/centreon-plugins/apps/tomcat/web/mode/libconnect.pm +++ /dev/null @@ -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 . -# -# 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 -# -# 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; - diff --git a/centreon-plugins/apps/tomcat/web/mode/listapplication.pm b/centreon-plugins/apps/tomcat/web/mode/listapplication.pm index e4383835d..85bcaa9bb 100644 --- a/centreon-plugins/apps/tomcat/web/mode/listapplication.pm +++ b/centreon-plugins/apps/tomcat/web/mode/listapplication.pm @@ -38,10 +38,9 @@ package apps::tomcat::web::mode::listapplication; use base qw(centreon::plugins::mode); - use strict; use warnings; -use apps::tomcat::web::mode::libconnect; +use centreon::plugins::httplib; sub new { my ($class, %options) = @_; @@ -59,7 +58,7 @@ sub new { "password:s" => { name => 'password' }, "proxyurl:s" => { name => 'proxyurl' }, "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-state:s" => { name => 'filter_state', }, "filter-path:s" => { name => 'filter_path', }, @@ -92,7 +91,7 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $webcontent = apps::tomcat::web::mode::libconnect::connect($self); + my $webcontent = centreon::plugins::httplib::connect($self); while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) { 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 -=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 7: '/manager/text/list' diff --git a/centreon-plugins/apps/tomcat/web/mode/sessions.pm b/centreon-plugins/apps/tomcat/web/mode/sessions.pm index 20423f3a2..f50645328 100644 --- a/centreon-plugins/apps/tomcat/web/mode/sessions.pm +++ b/centreon-plugins/apps/tomcat/web/mode/sessions.pm @@ -38,10 +38,9 @@ package apps::tomcat::web::mode::sessions; use base qw(centreon::plugins::mode); - use strict; use warnings; -use apps::tomcat::web::mode::libconnect; +use centreon::plugins::httplib; sub new { my ($class, %options) = @_; @@ -59,7 +58,7 @@ sub new { "password:s" => { name => 'password' }, "proxyurl:s" => { name => 'proxyurl' }, "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' }, "critical:s" => { name => 'critical' }, "name:s" => { name => 'name' }, @@ -104,7 +103,7 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $webcontent = apps::tomcat::web::mode::libconnect::connect($self); + my $webcontent = centreon::plugins::httplib::connect($self); while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) { 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 -=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 7: '/manager/text/list' diff --git a/centreon-plugins/apps/tomcat/web/plugin.pm b/centreon-plugins/apps/tomcat/web/plugin.pm index 37ffb7e3e..12322ed83 100644 --- a/centreon-plugins/apps/tomcat/web/plugin.pm +++ b/centreon-plugins/apps/tomcat/web/plugin.pm @@ -49,7 +49,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'application' => 'apps::tomcat::web::mode::application', + 'applications' => 'apps::tomcat::web::mode::applications', 'list-application' => 'apps::tomcat::web::mode::listapplication', 'sessions' => 'apps::tomcat::web::mode::sessions', 'threads' => 'apps::tomcat::web::mode::threads',