Merge branch 'master' of http://git.centreon.com/centreon-plugins
This commit is contained in:
commit
88db9cc11e
|
@ -0,0 +1,189 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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 : Simon BOMM <sbomm@merethis.com>
|
||||||
|
#
|
||||||
|
# Based on De Bodt Lieven plugin
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::protocols::http::mode::expectedcontent;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::httplib;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', },
|
||||||
|
"proto:s" => { name => 'proto', default => "http" },
|
||||||
|
"urlpath:s" => { name => 'url_path', default => "/" },
|
||||||
|
"credentials" => { name => 'credentials' },
|
||||||
|
"ntlm" => { name => 'ntlm' },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
|
"expected-string:s" => { name => 'expected_string' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => '3' },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{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();
|
||||||
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'warning-bytes', value => $self->{option_results}->{warning_bytes})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong warning-bytes threshold '" . $self->{option_results}->{warning_bytes} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'critical-bytes', value => $self->{option_results}->{critical_bytes})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong critical-bytes threshold '" . $self->{option_results}->{critical_bytes} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'warning-access', value => $self->{option_results}->{warning_access})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong warning-access threshold '" . $self->{option_results}->{warning_access} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'critical-access', value => $self->{option_results}->{critical_access})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong critical-access threshold '" . $self->{option_results}->{critical_access} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "You need to specify hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{expected_string})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "You need to specify --expected-string option.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if ((!defined($self->{option_results}->{credentials})) && (defined($self->{option_results}->{ntlm}))) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{port})) {
|
||||||
|
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $webcontent = centreon::plugins::httplib::connect($self);
|
||||||
|
$self->{output}->output_add(long_msg => $webcontent);
|
||||||
|
|
||||||
|
if ($webcontent =~ /$self->{option_results}->{expected_string}/mi) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => sprintf("'%s' is present in content.", $self->{option_results}->{expected_string}));
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
} else {
|
||||||
|
$self->{output}->output_add(severity => 'Critical',
|
||||||
|
short_msg => sprintf("'%s' is not present in content.", $self->{option_results}->{expected_string}));
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Webpage content
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
IP Addr/FQDN of the Webserver host
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
Port used by Webserver
|
||||||
|
|
||||||
|
=item B<--proxyurl>
|
||||||
|
|
||||||
|
Proxy URL if any
|
||||||
|
|
||||||
|
=item B<--proto>
|
||||||
|
|
||||||
|
Specify https if needed
|
||||||
|
|
||||||
|
=item B<--urlpath>
|
||||||
|
|
||||||
|
Set path to get Webpage (Default: '/')
|
||||||
|
|
||||||
|
=item B<--credentials>
|
||||||
|
|
||||||
|
Specify this option if you access webpage over basic authentification
|
||||||
|
|
||||||
|
=item B<--ntlm>
|
||||||
|
|
||||||
|
Specify this option if you access webpage over ntlm authentification (Use with --credentials option)
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
Specify username for basic authentification (Mandatory if --credentials is specidied)
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
Specify password for basic authentification (Mandatory if --credentials is specidied)
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Threshold for HTTP timeout
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,186 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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 : Simon BOMM <sbomm@merethis.com>
|
||||||
|
#
|
||||||
|
# Based on De Bodt Lieven plugin
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::protocols::http::mode::responsetime;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Time::HiRes qw(gettimeofday tv_interval);
|
||||||
|
use centreon::plugins::httplib;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', },
|
||||||
|
"proto:s" => { name => 'proto', default => "http" },
|
||||||
|
"urlpath:s" => { name => 'url_path', default => "/" },
|
||||||
|
"credentials" => { name => 'credentials' },
|
||||||
|
"ntlm" => { name => 'ntlm' },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
|
"warning:s" => { name => 'warning' },
|
||||||
|
"critical:s" => { name => 'critical' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => '3' },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{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();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{port})) {
|
||||||
|
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $timing0 = [gettimeofday];
|
||||||
|
|
||||||
|
my $webcontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
||||||
|
|
||||||
|
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => $webcontent);
|
||||||
|
|
||||||
|
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
|
||||||
|
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => sprintf("Response time %.3fs", $timeelapsed));
|
||||||
|
$self->{output}->perfdata_add(label => "time",
|
||||||
|
value => sprintf('%.3f', $timeelapsed),
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Webpage Time Response
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
IP Addr/FQDN of the webserver host
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
Port used by Webserver
|
||||||
|
|
||||||
|
=item B<--proto>
|
||||||
|
|
||||||
|
Specify https if needed
|
||||||
|
|
||||||
|
=item B<--urlpath>
|
||||||
|
|
||||||
|
Set path to get webpage (Default: '/')
|
||||||
|
|
||||||
|
=item B<--credentials>
|
||||||
|
|
||||||
|
Specify this option if you access webpage over basic authentification
|
||||||
|
|
||||||
|
=item B<--ntlm>
|
||||||
|
|
||||||
|
Specify this option if you access webpage over ntlm authentification (Use with --credentials option)
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
Specify username for basic authentification (Mandatory if --credentials is specidied)
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
Specify password for basic authentification (Mandatory if --credentials is specidied)
|
||||||
|
|
||||||
|
=item B<--proxyurl>
|
||||||
|
|
||||||
|
Proxy URL if any
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Threshold for HTTP timeout
|
||||||
|
|
||||||
|
=item B<--warning>
|
||||||
|
|
||||||
|
Threshold warning in seconds (Webpage response time)
|
||||||
|
|
||||||
|
=item B<--critical>
|
||||||
|
|
||||||
|
Threshold critical in seconds (Webpage response time)
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,65 @@
|
||||||
|
###############################################################################
|
||||||
|
# Copyright 2005-2013 MERETHIS
|
||||||
|
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||||
|
# GPL Licence 2.0.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation ; either version 2 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||||
|
#
|
||||||
|
# Linking this program statically or dynamically with other modules is making a
|
||||||
|
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||||
|
# General Public License cover the whole combination.
|
||||||
|
#
|
||||||
|
# As a special exception, the copyright holders of this program give MERETHIS
|
||||||
|
# permission to link this program with independent modules to produce an executable,
|
||||||
|
# regardless of the license terms of these independent modules, and to copy and
|
||||||
|
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||||
|
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||||
|
# of the license of that module. An independent module is a module which is not
|
||||||
|
# derived from this program. If you modify this program, you may extend this
|
||||||
|
# exception to your version of the program, but you are not obliged to do so. If you
|
||||||
|
# do not wish to do so, delete this exception statement from your version.
|
||||||
|
#
|
||||||
|
# For more information : contact@centreon.com
|
||||||
|
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::protocols::http::plugin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use base qw(centreon::plugins::script_simple);
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
# $options->{options} = options object
|
||||||
|
|
||||||
|
$self->{version} = '0.1';
|
||||||
|
%{$self->{modes}} = (
|
||||||
|
'response-time' => 'apps::protocols::http::mode::responsetime',
|
||||||
|
'expected-content' => 'apps::protocols::http::mode::expectedcontent',
|
||||||
|
);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
Check HTTP or HTTPS webpage.
|
||||||
|
|
||||||
|
=cut
|
|
@ -97,6 +97,13 @@ my $maps_counters = {
|
||||||
output_msg => 'Backend conn. retry: %.2f',
|
output_msg => 'Backend conn. retry: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
|
backend_req => { thresholds => {
|
||||||
|
warning_req => { label => 'warning-req', exit_value => 'warning' },
|
||||||
|
critical_req => { label => 'critical-req', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Backend requests made: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -245,7 +252,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
@ -283,7 +290,8 @@ fail => Backend conn. failures,
|
||||||
reuse => Backend conn. reuses,
|
reuse => Backend conn. reuses,
|
||||||
toolate => Backend conn. was closed,
|
toolate => Backend conn. was closed,
|
||||||
recycle => Backend conn. recycles,
|
recycle => Backend conn. recycles,
|
||||||
retry => Backend conn. retry
|
retry => Backend conn. retry,
|
||||||
|
req => Backend requests made
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
@ -295,7 +303,8 @@ fail => Backend conn. failures,
|
||||||
reuse => Backend conn. reuses,
|
reuse => Backend conn. reuses,
|
||||||
toolate => Backend conn. was closed,
|
toolate => Backend conn. was closed,
|
||||||
recycle => Backend conn. recycles,
|
recycle => Backend conn. recycles,
|
||||||
retry => Backend conn. retry
|
retry => Backend conn. retry,
|
||||||
|
req => Backend requests made
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,284 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::bans;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
n_ban => { thresholds => {
|
||||||
|
warning_total => { label => 'warning-total', exit_value => 'warning' },
|
||||||
|
critical_total => { label => 'critical-total', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N total active bans: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_ban_add => { thresholds => {
|
||||||
|
warning_add => { label => 'warning-add', exit_value => 'warning' },
|
||||||
|
critical_add => { label => 'critical-add', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N new bans added: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_ban_retire => { thresholds => {
|
||||||
|
warning_retire => { label => 'warning-retire', exit_value => 'warning' },
|
||||||
|
critical_retire => { label => 'critical-retire', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N old bans deleted: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_ban_obj_test => { thresholds => {
|
||||||
|
warning_objtest => { label => 'warning-objtest', exit_value => 'warning' },
|
||||||
|
critical_objtest => { label => 'critical-objtest', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N objects tested: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_ban_re_test => { thresholds => {
|
||||||
|
warning_retest => { label => 'warning-retest', exit_value => 'warning' },
|
||||||
|
critical_retest => { label => 'critical-retest', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N regexps tested against: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_ban_dups => { thresholds => {
|
||||||
|
warning_dups => { label => 'warning-dups', exit_value => 'warning' },
|
||||||
|
critical_dups => { label => 'critical-dups', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N duplicate bans removed: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
total => N total active bans,
|
||||||
|
add => N new bans added,
|
||||||
|
retire => N old bans deleted,
|
||||||
|
objtest => N objects tested,
|
||||||
|
retest => N regexps tested against,
|
||||||
|
dups => N duplicate bans removed
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
total => N total active bans,
|
||||||
|
add => N new bans added,
|
||||||
|
retire => N old bans deleted,
|
||||||
|
objtest => N objects tested,
|
||||||
|
retest => N regexps tested against,
|
||||||
|
dups => N duplicate bans removed
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -216,7 +216,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,13 @@ my $maps_counters = {
|
||||||
output_msg => 'Connection dropped, no sess/wrk: %.2f',
|
output_msg => 'Connection dropped, no sess/wrk: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
|
client_drop_late => { thresholds => {
|
||||||
|
warning_droplate => { label => 'warning-droplate', exit_value => 'warning' },
|
||||||
|
critical_droplate => { label => 'critical-droplate', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Connection dropped late: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
client_req => { thresholds => {
|
client_req => { thresholds => {
|
||||||
warning_req => { label => 'warning-req', exit_value => 'warning' },
|
warning_req => { label => 'warning-req', exit_value => 'warning' },
|
||||||
critical_req => { label => 'critical-req', exit_value => 'critical' },
|
critical_req => { label => 'critical-req', exit_value => 'critical' },
|
||||||
|
@ -210,7 +217,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
@ -241,16 +248,18 @@ Parameter for Binary File (Default: ' -1 ')
|
||||||
=item B<--warning-*>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Warning Threshold for:
|
Warning Threshold for:
|
||||||
conn => Client connections accepted,
|
conn => Client connections accepted,
|
||||||
drop => Connection dropped, no sess/wrk,
|
drop => Connection dropped, no sess/wrk,
|
||||||
req => Client requests received
|
droplate => Connection dropped late,
|
||||||
|
req => Client requests received
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*>
|
||||||
|
|
||||||
Critical Threshold for:
|
Critical Threshold for:
|
||||||
conn => Client connections accepted,
|
conn => Client connections accepted,
|
||||||
drop => Connection dropped, no sess/wrk,
|
drop => Connection dropped, no sess/wrk,
|
||||||
req => Client requests received
|
droplate => Connection dropped late,
|
||||||
|
req => Client requests received
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,266 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::dns;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
dir_dns_lookups => { thresholds => {
|
||||||
|
warning_lookups => { label => 'warning-lookups', exit_value => 'warning' },
|
||||||
|
critical_lookups => { label => 'critical-lookups', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Lookups without lock: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
dir_dns_failed => { thresholds => {
|
||||||
|
warning_failed => { label => 'warning-failed', exit_value => 'warning' },
|
||||||
|
critical_failed => { label => 'critical-failed', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Lookups with lock: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
dir_dns_hit => { thresholds => {
|
||||||
|
warning_hit => { label => 'warning-hit', exit_value => 'warning' },
|
||||||
|
critical_hit => { label => 'critical-hit', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Inserts: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
dir_dns_cache_full => { thresholds => {
|
||||||
|
warning_full => { label => 'warning-full', exit_value => 'warning' },
|
||||||
|
critical_full => { label => 'critical-full', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Inserts: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
lookups => DNS director lookups,
|
||||||
|
failed => DNS director failed lookups,
|
||||||
|
hit => DNS director cached lookups hit,
|
||||||
|
full => DNS director full dnscache
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
lookups => DNS director lookups,
|
||||||
|
failed => DNS director failed lookups,
|
||||||
|
hit => DNS director cached lookups hit,
|
||||||
|
full => DNS director full dnscache
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,248 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::esi;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
esi_errors => { thresholds => {
|
||||||
|
warning_errors => { label => 'warning-errors', exit_value => 'warning' },
|
||||||
|
critical_errors => { label => 'critical-errors', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'ESI parse errors (unlock): %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
esi_warnings => { thresholds => {
|
||||||
|
warning_warnings => { label => 'warning-warnings', exit_value => 'warning' },
|
||||||
|
critical_warnings => { label => 'critical-warnings', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'ESI parse warnings (unlock): %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
errors => ESI parse errors (unlock),
|
||||||
|
warnings => ESI parse warnings (unlock)
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
errors => ESI parse errors (unlock),
|
||||||
|
warnings => ESI parse warnings (unlock)
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -41,84 +41,84 @@ use centreon::plugins::statefile;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
my $maps_counters = {
|
my $maps_counters = {
|
||||||
backend_head => { thresholds => {
|
fetch_head => { thresholds => {
|
||||||
warning_head => { label => 'warning-head', exit_value => 'warning' },
|
warning_head => { label => 'warning-head', exit_value => 'warning' },
|
||||||
critical_head => { label => 'critical-head', exit_value => 'critical' },
|
critical_head => { label => 'critical-head', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch head: %.2f',
|
output_msg => 'Fetch head: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_length => { thresholds => {
|
fetch_length => { thresholds => {
|
||||||
warning_length => { label => 'warning-length', exit_value => 'warning' },
|
warning_length => { label => 'warning-length', exit_value => 'warning' },
|
||||||
critical_length => { label => 'critical-length', exit_value => 'critical' },
|
critical_length => { label => 'critical-length', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch with Length: %.2f',
|
output_msg => 'Fetch with Length: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_chunked => { thresholds => {
|
fetch_chunked => { thresholds => {
|
||||||
warning_chunked => { label => 'warning-chunked', exit_value => 'warning' },
|
warning_chunked => { label => 'warning-chunked', exit_value => 'warning' },
|
||||||
critical_chunked => { label => 'critical-chunked', exit_value => 'critical' },
|
critical_chunked => { label => 'critical-chunked', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch chunked: %.2f',
|
output_msg => 'Fetch chunked: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_eof => { thresholds => {
|
fetch_eof => { thresholds => {
|
||||||
warning_eof => { label => 'warning-eof', exit_value => 'warning' },
|
warning_eof => { label => 'warning-eof', exit_value => 'warning' },
|
||||||
critical_eof => { label => 'critical-eof', exit_value => 'critical' },
|
critical_eof => { label => 'critical-eof', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch EOF: %.2f',
|
output_msg => 'Fetch EOF: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_bad => { thresholds => {
|
fetch_bad => { thresholds => {
|
||||||
warning_bad => { label => 'warning-bad', exit_value => 'warning' },
|
warning_bad => { label => 'warning-bad', exit_value => 'warning' },
|
||||||
critical_bad => { label => 'critical-bad', exit_value => 'critical' },
|
critical_bad => { label => 'critical-bad', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch had bad headers: %.2f',
|
output_msg => 'Fetch had bad headers: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_close => { thresholds => {
|
fetch_close => { thresholds => {
|
||||||
warning_close => { label => 'warning-close', exit_value => 'warning' },
|
warning_close => { label => 'warning-close', exit_value => 'warning' },
|
||||||
critical_close => { label => 'critical-close', exit_value => 'critical' },
|
critical_close => { label => 'critical-close', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch wanted close: %.2f',
|
output_msg => 'Fetch wanted close: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_oldhttp => { thresholds => {
|
fetch_oldhttp => { thresholds => {
|
||||||
warning_oldhttp => { label => 'warning-oldhttp', exit_value => 'warning' },
|
warning_oldhttp => { label => 'warning-oldhttp', exit_value => 'warning' },
|
||||||
critical_oldhttp => { label => 'critical-oldhttp', exit_value => 'critical' },
|
critical_oldhttp => { label => 'critical-oldhttp', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch pre HTTP/1.1 closed: %.2f',
|
output_msg => 'Fetch pre HTTP/1.1 closed: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_zero => { thresholds => {
|
fetch_zero => { thresholds => {
|
||||||
warning_zero => { label => 'warning-zero', exit_value => 'warning' },
|
warning_zero => { label => 'warning-zero', exit_value => 'warning' },
|
||||||
critical_zero => { label => 'critical-zero', exit_value => 'critical' },
|
critical_zero => { label => 'critical-zero', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch zero len: %.2f',
|
output_msg => 'Fetch zero len: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_failed => { thresholds => {
|
fetch_failed => { thresholds => {
|
||||||
warning_failed => { label => 'warning-failed', exit_value => 'warning' },
|
warning_failed => { label => 'warning-failed', exit_value => 'warning' },
|
||||||
critical_failed => { label => 'critical-failed', exit_value => 'critical' },
|
critical_failed => { label => 'critical-failed', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch failed: %.2f',
|
output_msg => 'Fetch failed: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_1xx => { thresholds => {
|
fetch_1xx => { thresholds => {
|
||||||
warning_1xx => { label => 'warning-1xx', exit_value => 'warning' },
|
warning_1xx => { label => 'warning-1xx', exit_value => 'warning' },
|
||||||
critical_1xx => { label => 'critical-1xx', exit_value => 'critical' },
|
critical_1xx => { label => 'critical-1xx', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch no body (1xx): %.2f',
|
output_msg => 'Fetch no body (1xx): %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_204 => { thresholds => {
|
fetch_204 => { thresholds => {
|
||||||
warning_204 => { label => 'warning-204', exit_value => 'warning' },
|
warning_204 => { label => 'warning-204', exit_value => 'warning' },
|
||||||
critical_204 => { label => 'critical-204', exit_value => 'critical' },
|
critical_204 => { label => 'critical-204', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
output_msg => 'Fetch no body (204): %.2f',
|
output_msg => 'Fetch no body (204): %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
backend_304 => { thresholds => {
|
fetch_304 => { thresholds => {
|
||||||
warning_304 => { label => 'warning-304', exit_value => 'warning' },
|
warning_304 => { label => 'warning-304', exit_value => 'warning' },
|
||||||
critical_304 => { label => 'critical-304', exit_value => 'critical' },
|
critical_304 => { label => 'critical-304', exit_value => 'critical' },
|
||||||
},
|
},
|
||||||
|
@ -273,7 +273,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,257 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::hcb;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
hcb_nolock => { thresholds => {
|
||||||
|
warning_nolock => { label => 'warning-nolock', exit_value => 'warning' },
|
||||||
|
critical_nolock => { label => 'critical-nolock', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Lookups without lock: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
hcb_lock => { thresholds => {
|
||||||
|
warning_lock => { label => 'warning-lock', exit_value => 'warning' },
|
||||||
|
critical_lock => { label => 'critical-lock', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Lookups with lock: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
hcb_insert => { thresholds => {
|
||||||
|
warning_insert => { label => 'warning-insert', exit_value => 'warning' },
|
||||||
|
critical_insert => { label => 'critical-insert', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'HCB Inserts: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
nolock => HCB Lookups without lock,
|
||||||
|
lock => HCB Lookups with lock,
|
||||||
|
insert => HCB Inserts
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
nolock => HCB Lookups without lock,
|
||||||
|
lock => HCB Lookups with lock,
|
||||||
|
insert => HCB Inserts
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,338 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::n;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
n_sess_mem => { thresholds => {
|
||||||
|
warning_mem => { label => 'warning-mem', exit_value => 'warning' },
|
||||||
|
critical_mem => { label => 'critical-mem', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct sess_mem: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_sess => { thresholds => {
|
||||||
|
warning_sess => { label => 'warning-sess', exit_value => 'warning' },
|
||||||
|
critical_sess => { label => 'critical-sess', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct sess: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_object => { thresholds => {
|
||||||
|
warning_object => { label => 'warning-object', exit_value => 'warning' },
|
||||||
|
critical_object => { label => 'critical-object', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct object: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_vampireobject => { thresholds => {
|
||||||
|
warning_vampireobject => { label => 'warning-vampireobject', exit_value => 'warning' },
|
||||||
|
critical_vampireobject => { label => 'critical-vampireobject', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N unresurrected objects: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_objectcore => { thresholds => {
|
||||||
|
warning_objectcore => { label => 'warning-objectcore', exit_value => 'warning' },
|
||||||
|
critical_objectcore => { label => 'critical-objectcore', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct objectcore: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_objecthead => { thresholds => {
|
||||||
|
warning_objecthead => { label => 'warning-objecthead', exit_value => 'warning' },
|
||||||
|
critical_objecthead => { label => 'critical-objecthead', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct objecthead: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_waitinglist => { thresholds => {
|
||||||
|
warning_waitinglist => { label => 'warning-waitinglist', exit_value => 'warning' },
|
||||||
|
critical_waitinglist => { label => 'critical-waitinglist', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct waitinglist: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_vbc => { thresholds => {
|
||||||
|
warning_vbc => { label => 'warning-vbc', exit_value => 'warning' },
|
||||||
|
critical_vbc => { label => 'critical-vbc', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N struct vbc: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_backend => { thresholds => {
|
||||||
|
warning_backend => { label => 'warning-backend', exit_value => 'warning' },
|
||||||
|
critical_backend => { label => 'critical-backend', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N backends: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_expired => { thresholds => {
|
||||||
|
warning_expired => { label => 'warning-expired', exit_value => 'warning' },
|
||||||
|
critical_expired => { label => 'critical-expired', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N expired objects: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_lru_nuked => { thresholds => {
|
||||||
|
warning_nuked => { label => 'warning-nuked', exit_value => 'warning' },
|
||||||
|
critical_nuked => { label => 'critical-nuked', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N LRU nuked objects: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_lru_moved => { thresholds => {
|
||||||
|
warning_moved => { label => 'warning-moved', exit_value => 'warning' },
|
||||||
|
critical_moved => { label => 'critical-moved', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N LRU moved objects: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
n_sess_mem => N struct sess_mem,
|
||||||
|
n_sess => N struct sess,
|
||||||
|
n_object => N struct object,
|
||||||
|
n_vampireobject => N unresurrected objects,
|
||||||
|
n_objectcore => N struct objectcore,
|
||||||
|
n_objecthead => N struct objecthead,
|
||||||
|
n_waitinglist => N struct waitinglist,
|
||||||
|
n_vbc => N struct vbc,
|
||||||
|
n_backend => N backends,
|
||||||
|
n_expired => N expired objects,
|
||||||
|
n_lru_nuked => N LRU nuked objects,
|
||||||
|
n_lru_moved => N LRU moved objects
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
n_sess_mem => N struct sess_mem,
|
||||||
|
n_sess => N struct sess,
|
||||||
|
n_object => N struct object,
|
||||||
|
n_vampireobject => N unresurrected objects,
|
||||||
|
n_objectcore => N struct objectcore,
|
||||||
|
n_objecthead => N struct objecthead,
|
||||||
|
n_waitinglist => N struct waitinglist,
|
||||||
|
n_vbc => N struct vbc,
|
||||||
|
n_backend => N backends,
|
||||||
|
n_expired => N expired objects,
|
||||||
|
n_lru_nuked => N LRU nuked objects,
|
||||||
|
n_lru_moved => N LRU moved objects
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,257 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::objects;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
n_objsendfile => { thresholds => {
|
||||||
|
warning_objsendfile => { label => 'warning-objsendfile', exit_value => 'warning' },
|
||||||
|
critical_objsendfile => { label => 'critical-objsendfile', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Objects sent with sendfile: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_objwrite => { thresholds => {
|
||||||
|
warning_objwrite => { label => 'warning-objwrite', exit_value => 'warning' },
|
||||||
|
critical_objwrite => { label => 'critical-objwrite', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Objects sent with write: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_objoverflow => { thresholds => {
|
||||||
|
warning_objoverflow => { label => 'warning-objoverflow', exit_value => 'warning' },
|
||||||
|
critical_objoverflow => { label => 'critical-objoverflow', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Objects overflowing workspace: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
objsendfile => Objects sent with sendfile,
|
||||||
|
objwrite => Objects sent with write,
|
||||||
|
objoverflow => Objects overflowing workspace
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
objsendfile => Objects sent with sendfile,
|
||||||
|
objwrite => Objects sent with write,
|
||||||
|
objoverflow => Objects overflowing workspace
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,275 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::sessions;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
sess_closed => { thresholds => {
|
||||||
|
warning_closed => { label => 'warning-closed', exit_value => 'warning' },
|
||||||
|
critical_closed => { label => 'critical-closed', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Session Closed: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sess_pipeline => { thresholds => {
|
||||||
|
warning_pipeline => { label => 'warning-pipeline', exit_value => 'warning' },
|
||||||
|
critical_pipeline => { label => 'critical-pipeline', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Session Pipeline: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sess_readahead => { thresholds => {
|
||||||
|
warning_readahead => { label => 'warning-readahead', exit_value => 'warning' },
|
||||||
|
critical_readahead => { label => 'critical-readahead', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Session Read Ahead: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sess_linger => { thresholds => {
|
||||||
|
warning_linger => { label => 'warning-linger', exit_value => 'warning' },
|
||||||
|
critical_linger => { label => 'critical-linger', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Session Linger: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sess_herd => { thresholds => {
|
||||||
|
warning_herd => { label => 'warning-herd', exit_value => 'warning' },
|
||||||
|
critical_herd => { label => 'critical-herd', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Session herd: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
closed => Session Closed,
|
||||||
|
pipeline => Session Pipeline,
|
||||||
|
readahead => Session Read Ahead,
|
||||||
|
linger => Session Linger,
|
||||||
|
herd => Session herd
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
closed => Session Closed,
|
||||||
|
pipeline => Session Pipeline,
|
||||||
|
readahead => Session Read Ahead,
|
||||||
|
linger => Session Linger,
|
||||||
|
herd => Session herd
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,275 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::shm;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
shm_records => { thresholds => {
|
||||||
|
warning_records => { label => 'warning-records', exit_value => 'warning' },
|
||||||
|
critical_records => { label => 'critical-records', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SHM records: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
shm_writes => { thresholds => {
|
||||||
|
warning_writes => { label => 'warning-writes', exit_value => 'warning' },
|
||||||
|
critical_writes => { label => 'critical-writes', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SHM writes: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
shm_flushes => { thresholds => {
|
||||||
|
warning_flushes => { label => 'warning-flushes', exit_value => 'warning' },
|
||||||
|
critical_flushes => { label => 'critical-flushes', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SHM flushes due to overflow: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
shm_cont => { thresholds => {
|
||||||
|
warning_cont => { label => 'warning-cont', exit_value => 'warning' },
|
||||||
|
critical_cont => { label => 'critical-cont', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SHM MTX contention: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
shm_cycles => { thresholds => {
|
||||||
|
warning_cycles => { label => 'warning-cycles', exit_value => 'warning' },
|
||||||
|
critical_cycles => { label => 'critical-cycles', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SHM cycles through buffer: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
records => SHM records,
|
||||||
|
writes => SHM writes,
|
||||||
|
flushes => SHM flushes due to overflow,
|
||||||
|
cont => SHM MTX contention,
|
||||||
|
cycles => SHM cycles through buffer
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
records => SHM records,
|
||||||
|
writes => SHM writes,
|
||||||
|
flushes => SHM flushes due to overflow,
|
||||||
|
cont => SHM MTX contention,
|
||||||
|
cycles => SHM cycles through buffer
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,275 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::sms;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
sms_nreq => { thresholds => {
|
||||||
|
warning_nreq => { label => 'warning-nreq', exit_value => 'warning' },
|
||||||
|
critical_nreq => { label => 'critical-nreq', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SMS allocator requests: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sms_nobj => { thresholds => {
|
||||||
|
warning_nobj => { label => 'warning-nobj', exit_value => 'warning' },
|
||||||
|
critical_nobj => { label => 'critical-nobj', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SMS outstanding allocations: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sms_nbytes => { thresholds => {
|
||||||
|
warning_nbytes => { label => 'warning-nbytes', exit_value => 'warning' },
|
||||||
|
critical_nbytes => { label => 'critical-nbytes', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SMS outstanding bytes: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sms_balloc => { thresholds => {
|
||||||
|
warning_balloc => { label => 'warning-balloc', exit_value => 'warning' },
|
||||||
|
critical_balloc => { label => 'critical-balloc', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SMS bytes allocated: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
sms_bfree => { thresholds => {
|
||||||
|
warning_bfree => { label => 'warning-bfree', exit_value => 'warning' },
|
||||||
|
critical_bfree => { label => 'critical-bfree', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'SMS bytes freed: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
nreq => SMS allocator requests,
|
||||||
|
nobj => SMS outstanding allocations,
|
||||||
|
nbytes => SMS outstanding bytes,
|
||||||
|
balloc => SMS bytes allocated,
|
||||||
|
bfree => SMS bytes freed
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
nreq => SMS allocator requests,
|
||||||
|
nobj => SMS outstanding allocations,
|
||||||
|
nbytes => SMS outstanding bytes,
|
||||||
|
balloc => SMS bytes allocated,
|
||||||
|
bfree => SMS bytes freed
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -90,6 +90,13 @@ my $maps_counters = {
|
||||||
output_msg => 'Total body bytes: %.2f',
|
output_msg => 'Total body bytes: %.2f',
|
||||||
factor => 1, unit => '',
|
factor => 1, unit => '',
|
||||||
},
|
},
|
||||||
|
accept_fail => { thresholds => {
|
||||||
|
warning_fail => { label => 'warning-fail', exit_value => 'warning' },
|
||||||
|
critical_fail => { label => 'critical-fail', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Accept failures: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -238,7 +245,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
@ -275,7 +282,8 @@ pipe => Total pipe,
|
||||||
pass => Total pass,
|
pass => Total pass,
|
||||||
fetch => Total fetch,
|
fetch => Total fetch,
|
||||||
hdrbytes => Total header bytes,
|
hdrbytes => Total header bytes,
|
||||||
bodybytes => Total body bytes
|
bodybytes => Total body bytes,
|
||||||
|
fail => Accept failures
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
@ -286,7 +294,8 @@ pipe => Total pipe,
|
||||||
pass => Total pass,
|
pass => Total pass,
|
||||||
fetch => Total fetch,
|
fetch => Total fetch,
|
||||||
hdrbytes => Total header bytes,
|
hdrbytes => Total header bytes,
|
||||||
bodybytes => Total body bytes
|
bodybytes => Total body bytes,
|
||||||
|
fail => Accept failures
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::uptime;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
uptime => { thresholds => {
|
||||||
|
warning => { label => 'warning', exit_value => 'warning' },
|
||||||
|
critical => { label => 'critical', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'Uptime in sec: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning>
|
||||||
|
|
||||||
|
Warning Threshold for Uptime
|
||||||
|
|
||||||
|
=item B<--critical>
|
||||||
|
|
||||||
|
Critical Threshold for Uptime
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,258 @@
|
||||||
|
###############################################################################
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
package apps::varnish::mode::vcl;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
#n_vcl_avail could be max from n_vcl
|
||||||
|
my $maps_counters = {
|
||||||
|
n_vcl => { thresholds => {
|
||||||
|
warning_total => { label => 'warning-total', exit_value => 'warning' },
|
||||||
|
critical_total => { label => 'critical-total', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N vcl total: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_vcl_avail => { thresholds => {
|
||||||
|
warning_avail => { label => 'warning-avail', exit_value => 'warning' },
|
||||||
|
critical_avail => { label => 'critical-avail', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N vcl available: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
n_vcl_discard => { thresholds => {
|
||||||
|
warning_discard => { label => 'warning-discard', exit_value => 'warning' },
|
||||||
|
critical_discard => { label => 'critical-discard', exit_value => 'critical' },
|
||||||
|
},
|
||||||
|
output_msg => 'N vcl discarded: %.2f',
|
||||||
|
factor => 1, unit => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"remote" => { name => 'remote' },
|
||||||
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"sudo" => { name => 'sudo' },
|
||||||
|
"command:s" => { name => 'command', default => 'varnishstat' },
|
||||||
|
"command-path:s" => { name => 'command_path', default => '/usr/bin' },
|
||||||
|
"command-options:s" => { name => 'command_options', default => ' -1 ' },
|
||||||
|
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{instances_done} = {};
|
||||||
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$self->{statefile_value}->check_options(%options);
|
||||||
|
};
|
||||||
|
|
||||||
|
sub getdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
|
options => $self->{option_results},
|
||||||
|
sudo => $self->{option_results}->{sudo},
|
||||||
|
command => $self->{option_results}->{command},
|
||||||
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{command_options2});
|
||||||
|
#print $stdout;
|
||||||
|
|
||||||
|
foreach (split(/\n/, $stdout)) {
|
||||||
|
#client_conn 7390867 1.00 Client connections
|
||||||
|
# - Symbolic entry name
|
||||||
|
# - Value
|
||||||
|
# - Per-second average over process lifetime, or a period if the value can not be averaged
|
||||||
|
# - Descriptive text
|
||||||
|
|
||||||
|
if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) {
|
||||||
|
#print "FOUND: " . $1 . "=" . $2 . "\n";
|
||||||
|
$self->{result}->{$1} = $2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->getdata();
|
||||||
|
|
||||||
|
$self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
|
||||||
|
$self->{result}->{last_timestamp} = time();
|
||||||
|
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
|
# Calculate
|
||||||
|
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||||
|
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||||
|
|
||||||
|
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
#print $_ . "\n";
|
||||||
|
$self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache
|
||||||
|
$self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} );
|
||||||
|
$self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write Cache if not there
|
||||||
|
$self->{statefile_value}->write(data => $self->{result});
|
||||||
|
if (!defined($old_timestamp)) {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "Buffer creation...");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my @exits;
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
|
|
||||||
|
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $instance_output if ($num > 1);
|
||||||
|
|
||||||
|
my $str_output = "";
|
||||||
|
my $str_append = '';
|
||||||
|
foreach (keys %{$maps_counters}) {
|
||||||
|
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor});
|
||||||
|
$str_append = ', ';
|
||||||
|
my ($warning, $critical);
|
||||||
|
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||||
|
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
|
||||||
|
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
|
||||||
|
value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}),
|
||||||
|
warning => $warning,
|
||||||
|
critical => $critical);
|
||||||
|
}
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => $str_output);
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--remote>
|
||||||
|
|
||||||
|
If you dont run this script locally, if you wanna use it remote, you can run it remotely with 'ssh'.
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query (need --remote).
|
||||||
|
|
||||||
|
=item B<--ssh-option>
|
||||||
|
|
||||||
|
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||||
|
|
||||||
|
=item B<--command>
|
||||||
|
|
||||||
|
Varnishstat Binary Filename (Default: varnishstat)
|
||||||
|
|
||||||
|
=item B<--command-path>
|
||||||
|
|
||||||
|
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||||
|
|
||||||
|
=item B<--command-options>
|
||||||
|
|
||||||
|
Parameter for Binary File (Default: ' -1 ')
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Warning Threshold for:
|
||||||
|
total => N vcl total,
|
||||||
|
avail => N vcl available,
|
||||||
|
discard => N vcl discarded
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Critical Threshold for:
|
||||||
|
total => N vcl total,
|
||||||
|
avail => N vcl available,
|
||||||
|
discard => N vcl discarded
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -238,7 +238,7 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#
|
#
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
package apps::varnish::plugin;
|
package apps::varnish::local::plugin;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
@ -47,18 +47,23 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
%{$self->{modes}} = (
|
||||||
'connections' => 'apps::varnish::mode::connections',
|
'connections' => 'apps::varnish::local::mode::connections',
|
||||||
'cache' => 'apps::varnish::mode::cache',
|
'cache' => 'apps::varnish::local::mode::cache',
|
||||||
'backend' => 'apps::varnish::mode::backend',
|
'backend' => 'apps::varnish::local::mode::backend',
|
||||||
'fetch' => 'apps::varnish::mode::fetch',
|
'sessions' => 'apps::varnish::local::mode::sessions',
|
||||||
'workers' => 'apps::varnish::mode::workers',
|
'fetch' => 'apps::varnish::local::mode::fetch',
|
||||||
'totals' => 'apps::varnish::mode::totals',
|
'workers' => 'apps::varnish::local::mode::workers',
|
||||||
'shm' => 'apps::varnish::mode::shm',
|
'totals' => 'apps::varnish::local::mode::totals',
|
||||||
'sm' => 'apps::varnish::mode::sm',
|
'objects' => 'apps::varnish::local::mode::objects',
|
||||||
'sma' => 'apps::varnish::mode::sma',
|
'uptime' => 'apps::varnish::local::mode::uptime',
|
||||||
'sms' => 'apps::varnish::mode::sms',
|
'bans' => 'apps::varnish::local::mode::bans',
|
||||||
'hcb' => 'apps::varnish::mode::hcb',
|
'dns' => 'apps::varnish::local::mode::dns',
|
||||||
'esi' => 'apps::varnish::mode::esi',
|
'shm' => 'apps::varnish::local::mode::shm',
|
||||||
|
'vcl' => 'apps::varnish::local::mode::vcl',
|
||||||
|
'n' => 'apps::varnish::local::mode::n',
|
||||||
|
'sms' => 'apps::varnish::local::mode::sms',
|
||||||
|
'hcb' => 'apps::varnish::local::mode::hcb',
|
||||||
|
'esi' => 'apps::varnish::local::mode::esi',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -70,6 +75,6 @@ __END__
|
||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Check Varnish with Local Command or with SSH
|
Check Varnish Cache with varnishstat Command
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
|
@ -56,7 +56,7 @@ sub get_port {
|
||||||
|
|
||||||
sub connect {
|
sub connect {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $ua = LWP::UserAgent->new( protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout});
|
my $ua = LWP::UserAgent->new( keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout});
|
||||||
my $connection_exit = defined($options{connection_exit}) ? $options{connection_exit} : 'unknown';
|
my $connection_exit = defined($options{connection_exit}) ? $options{connection_exit} : 'unknown';
|
||||||
|
|
||||||
my ($response, $content);
|
my ($response, $content);
|
||||||
|
@ -67,8 +67,10 @@ sub connect {
|
||||||
} else {
|
} else {
|
||||||
$req = HTTP::Request->new( GET => $self->{option_results}->{proto}. "://" . $self->{option_results}->{hostname} . $self->{option_results}->{url_path});
|
$req = HTTP::Request->new( GET => $self->{option_results}->{proto}. "://" . $self->{option_results}->{hostname} . $self->{option_results}->{url_path});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($self->{option_results}->{credentials})) {
|
if (defined($self->{option_results}->{credentials}) && defined($self->{option_results}->{ntlm})) {
|
||||||
|
$ua->credentials($self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, '', $self->{option_results}->{username}, $self->{option_results}->{password});
|
||||||
|
} elsif (defined($self->{option_results}->{credentials})) {
|
||||||
$req->authorization_basic($self->{option_results}->{username}, $self->{option_results}->{password});
|
$req->authorization_basic($self->{option_results}->{username}, $self->{option_results}->{password});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue