diff --git a/centreon-plugins/apps/varnish/local/mode/backend.pm b/centreon-plugins/apps/varnish/local/mode/backend.pm index 13b0e1fb2..f3ae7e149 100644 --- a/centreon-plugins/apps/varnish/local/mode/backend.pm +++ b/centreon-plugins/apps/varnish/local/mode/backend.pm @@ -97,6 +97,13 @@ my $maps_counters = { output_msg => 'Backend conn. retry: %.2f', 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 { @@ -245,7 +252,7 @@ __END__ =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 @@ -283,7 +290,8 @@ fail => Backend conn. failures, reuse => Backend conn. reuses, toolate => Backend conn. was closed, recycle => Backend conn. recycles, -retry => Backend conn. retry +retry => Backend conn. retry, +req => Backend requests made =item B<--critical-*> @@ -295,7 +303,8 @@ fail => Backend conn. failures, reuse => Backend conn. reuses, toolate => Backend conn. was closed, recycle => Backend conn. recycles, -retry => Backend conn. retry +retry => Backend conn. retry, +req => Backend requests made =back diff --git a/centreon-plugins/apps/varnish/local/mode/bans.pm b/centreon-plugins/apps/varnish/local/mode/bans.pm new file mode 100644 index 000000000..5ea88aa00 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/bans.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/cache.pm b/centreon-plugins/apps/varnish/local/mode/cache.pm index b678e12ad..c37dfa3e0 100644 --- a/centreon-plugins/apps/varnish/local/mode/cache.pm +++ b/centreon-plugins/apps/varnish/local/mode/cache.pm @@ -216,7 +216,7 @@ __END__ =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 diff --git a/centreon-plugins/apps/varnish/local/mode/connections.pm b/centreon-plugins/apps/varnish/local/mode/connections.pm index 9e52c8bd5..2a00018a3 100644 --- a/centreon-plugins/apps/varnish/local/mode/connections.pm +++ b/centreon-plugins/apps/varnish/local/mode/connections.pm @@ -55,6 +55,13 @@ my $maps_counters = { output_msg => 'Connection dropped, no sess/wrk: %.2f', 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 => { warning_req => { label => 'warning-req', exit_value => 'warning' }, critical_req => { label => 'critical-req', exit_value => 'critical' }, @@ -210,7 +217,7 @@ __END__ =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 @@ -241,16 +248,18 @@ Parameter for Binary File (Default: ' -1 ') =item B<--warning-*> Warning Threshold for: -conn => Client connections accepted, -drop => Connection dropped, no sess/wrk, -req => Client requests received +conn => Client connections accepted, +drop => Connection dropped, no sess/wrk, +droplate => Connection dropped late, +req => Client requests received =item B<--critical-*> Critical Threshold for: -conn => Client connections accepted, -drop => Connection dropped, no sess/wrk, -req => Client requests received +conn => Client connections accepted, +drop => Connection dropped, no sess/wrk, +droplate => Connection dropped late, +req => Client requests received =back diff --git a/centreon-plugins/apps/varnish/local/mode/dns.pm b/centreon-plugins/apps/varnish/local/mode/dns.pm new file mode 100644 index 000000000..083ce2bd5 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/dns.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/esi.pm b/centreon-plugins/apps/varnish/local/mode/esi.pm new file mode 100644 index 000000000..a06cdfbac --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/esi.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/fetch.pm b/centreon-plugins/apps/varnish/local/mode/fetch.pm index e87ddfc3a..a27ac85d4 100644 --- a/centreon-plugins/apps/varnish/local/mode/fetch.pm +++ b/centreon-plugins/apps/varnish/local/mode/fetch.pm @@ -41,84 +41,84 @@ use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); my $maps_counters = { - backend_head => { thresholds => { + fetch_head => { thresholds => { warning_head => { label => 'warning-head', exit_value => 'warning' }, critical_head => { label => 'critical-head', exit_value => 'critical' }, }, output_msg => 'Fetch head: %.2f', factor => 1, unit => '', }, - backend_length => { thresholds => { + fetch_length => { thresholds => { warning_length => { label => 'warning-length', exit_value => 'warning' }, critical_length => { label => 'critical-length', exit_value => 'critical' }, }, output_msg => 'Fetch with Length: %.2f', factor => 1, unit => '', }, - backend_chunked => { thresholds => { + fetch_chunked => { thresholds => { warning_chunked => { label => 'warning-chunked', exit_value => 'warning' }, critical_chunked => { label => 'critical-chunked', exit_value => 'critical' }, }, output_msg => 'Fetch chunked: %.2f', factor => 1, unit => '', }, - backend_eof => { thresholds => { + fetch_eof => { thresholds => { warning_eof => { label => 'warning-eof', exit_value => 'warning' }, critical_eof => { label => 'critical-eof', exit_value => 'critical' }, }, output_msg => 'Fetch EOF: %.2f', factor => 1, unit => '', }, - backend_bad => { thresholds => { + fetch_bad => { thresholds => { warning_bad => { label => 'warning-bad', exit_value => 'warning' }, critical_bad => { label => 'critical-bad', exit_value => 'critical' }, }, output_msg => 'Fetch had bad headers: %.2f', factor => 1, unit => '', }, - backend_close => { thresholds => { + fetch_close => { thresholds => { warning_close => { label => 'warning-close', exit_value => 'warning' }, critical_close => { label => 'critical-close', exit_value => 'critical' }, }, output_msg => 'Fetch wanted close: %.2f', factor => 1, unit => '', }, - backend_oldhttp => { thresholds => { + fetch_oldhttp => { thresholds => { warning_oldhttp => { label => 'warning-oldhttp', exit_value => 'warning' }, critical_oldhttp => { label => 'critical-oldhttp', exit_value => 'critical' }, }, output_msg => 'Fetch pre HTTP/1.1 closed: %.2f', factor => 1, unit => '', }, - backend_zero => { thresholds => { + fetch_zero => { thresholds => { warning_zero => { label => 'warning-zero', exit_value => 'warning' }, critical_zero => { label => 'critical-zero', exit_value => 'critical' }, }, output_msg => 'Fetch zero len: %.2f', factor => 1, unit => '', }, - backend_failed => { thresholds => { + fetch_failed => { thresholds => { warning_failed => { label => 'warning-failed', exit_value => 'warning' }, critical_failed => { label => 'critical-failed', exit_value => 'critical' }, }, output_msg => 'Fetch failed: %.2f', factor => 1, unit => '', }, - backend_1xx => { thresholds => { + fetch_1xx => { thresholds => { warning_1xx => { label => 'warning-1xx', exit_value => 'warning' }, critical_1xx => { label => 'critical-1xx', exit_value => 'critical' }, }, output_msg => 'Fetch no body (1xx): %.2f', factor => 1, unit => '', }, - backend_204 => { thresholds => { + fetch_204 => { thresholds => { warning_204 => { label => 'warning-204', exit_value => 'warning' }, critical_204 => { label => 'critical-204', exit_value => 'critical' }, }, output_msg => 'Fetch no body (204): %.2f', factor => 1, unit => '', }, - backend_304 => { thresholds => { + fetch_304 => { thresholds => { warning_304 => { label => 'warning-304', exit_value => 'warning' }, critical_304 => { label => 'critical-304', exit_value => 'critical' }, }, @@ -273,7 +273,7 @@ __END__ =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 diff --git a/centreon-plugins/apps/varnish/local/mode/hcb.pm b/centreon-plugins/apps/varnish/local/mode/hcb.pm new file mode 100644 index 000000000..5a856a9f6 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/hcb.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/n.pm b/centreon-plugins/apps/varnish/local/mode/n.pm new file mode 100644 index 000000000..90eda5b09 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/n.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/objects.pm b/centreon-plugins/apps/varnish/local/mode/objects.pm new file mode 100644 index 000000000..a98221ad1 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/objects.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/sessions.pm b/centreon-plugins/apps/varnish/local/mode/sessions.pm new file mode 100644 index 000000000..4caf03d20 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/sessions.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/shm.pm b/centreon-plugins/apps/varnish/local/mode/shm.pm new file mode 100644 index 000000000..9e408171b --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/shm.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/sms.pm b/centreon-plugins/apps/varnish/local/mode/sms.pm new file mode 100644 index 000000000..f54d40d70 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/sms.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/totals.pm b/centreon-plugins/apps/varnish/local/mode/totals.pm index a63edd5af..b9ce28e81 100644 --- a/centreon-plugins/apps/varnish/local/mode/totals.pm +++ b/centreon-plugins/apps/varnish/local/mode/totals.pm @@ -90,6 +90,13 @@ my $maps_counters = { output_msg => 'Total body bytes: %.2f', 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 { @@ -238,7 +245,7 @@ __END__ =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 @@ -275,7 +282,8 @@ pipe => Total pipe, pass => Total pass, fetch => Total fetch, hdrbytes => Total header bytes, -bodybytes => Total body bytes +bodybytes => Total body bytes, +fail => Accept failures =item B<--critical-*> @@ -286,7 +294,8 @@ pipe => Total pipe, pass => Total pass, fetch => Total fetch, hdrbytes => Total header bytes, -bodybytes => Total body bytes +bodybytes => Total body bytes, +fail => Accept failures =back diff --git a/centreon-plugins/apps/varnish/local/mode/uptime.pm b/centreon-plugins/apps/varnish/local/mode/uptime.pm new file mode 100644 index 000000000..4c5b6099d --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/uptime.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/vcl.pm b/centreon-plugins/apps/varnish/local/mode/vcl.pm new file mode 100644 index 000000000..f801daa39 --- /dev/null +++ b/centreon-plugins/apps/varnish/local/mode/vcl.pm @@ -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 . +# +# 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 +# +#################################################################################### + +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 \ No newline at end of file diff --git a/centreon-plugins/apps/varnish/local/mode/workers.pm b/centreon-plugins/apps/varnish/local/mode/workers.pm index ad14ee44b..ff610eda3 100644 --- a/centreon-plugins/apps/varnish/local/mode/workers.pm +++ b/centreon-plugins/apps/varnish/local/mode/workers.pm @@ -238,7 +238,7 @@ __END__ =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 diff --git a/centreon-plugins/apps/varnish/local/plugin.pm b/centreon-plugins/apps/varnish/local/plugin.pm index d39818f55..d2f52b136 100644 --- a/centreon-plugins/apps/varnish/local/plugin.pm +++ b/centreon-plugins/apps/varnish/local/plugin.pm @@ -33,7 +33,7 @@ # #################################################################################### -package apps::varnish::plugin; +package apps::varnish::local::plugin; use strict; use warnings; @@ -47,18 +47,23 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'connections' => 'apps::varnish::mode::connections', - 'cache' => 'apps::varnish::mode::cache', - 'backend' => 'apps::varnish::mode::backend', - 'fetch' => 'apps::varnish::mode::fetch', - 'workers' => 'apps::varnish::mode::workers', - 'totals' => 'apps::varnish::mode::totals', - 'shm' => 'apps::varnish::mode::shm', - 'sm' => 'apps::varnish::mode::sm', - 'sma' => 'apps::varnish::mode::sma', - 'sms' => 'apps::varnish::mode::sms', - 'hcb' => 'apps::varnish::mode::hcb', - 'esi' => 'apps::varnish::mode::esi', + 'connections' => 'apps::varnish::local::mode::connections', + 'cache' => 'apps::varnish::local::mode::cache', + 'backend' => 'apps::varnish::local::mode::backend', + 'sessions' => 'apps::varnish::local::mode::sessions', + 'fetch' => 'apps::varnish::local::mode::fetch', + 'workers' => 'apps::varnish::local::mode::workers', + 'totals' => 'apps::varnish::local::mode::totals', + 'objects' => 'apps::varnish::local::mode::objects', + 'uptime' => 'apps::varnish::local::mode::uptime', + 'bans' => 'apps::varnish::local::mode::bans', + 'dns' => 'apps::varnish::local::mode::dns', + '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; @@ -70,6 +75,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Varnish with Local Command or with SSH +Check Varnish Cache with varnishstat Command =cut