Refs #5499: Working on Varnish Plugin
This commit is contained in:
parent
5229edd668
commit
868b13a745
|
@ -33,13 +33,72 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package apps::varnish::mode::backend;
|
||||
package apps::varnish::mode::cache;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my $maps_counters = {
|
||||
backend_conn => { thresholds => {
|
||||
warning_conn => { label => 'warning-conn', exit_value => 'warning' },
|
||||
critical_conn => { label => 'critical-conn', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. success: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_unhealthy => { thresholds => {
|
||||
warning_unhealthy => { label => 'warning-unhealthy', exit_value => 'warning' },
|
||||
critical_unhealthy => { label => 'critical-unhealthy', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. not attempted: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_busy => { thresholds => {
|
||||
warning_busy => { label => 'warning-busy', exit_value => 'warning' },
|
||||
critical_busy => { label => 'critical-busy', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. too many: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_fail => { thresholds => {
|
||||
warning_fail => { label => 'warning-fail', exit_value => 'warning' },
|
||||
critical_fail => { label => 'critical-fail', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. failures: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_reuse => { thresholds => {
|
||||
warning_reuse => { label => 'warning-reuse', exit_value => 'warning' },
|
||||
critical_reuse => { label => 'critical-reuse', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. reuses: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_toolate => { thresholds => {
|
||||
warning_toolate => { label => 'warning-toolate', exit_value => 'warning' },
|
||||
critical_toolate => { label => 'critical-toolate', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. was closed: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_recycle => { thresholds => {
|
||||
warning_recycle => { label => 'warning-recycle', exit_value => 'warning' },
|
||||
critical_recycle => { label => 'critical-recycle', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. recycles: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
backend_retry => { thresholds => {
|
||||
warning_retry => { label => 'warning-retry', exit_value => 'warning' },
|
||||
critical_retry => { label => 'critical-retry', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Backend conn. retry: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
};
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,129 +106,47 @@ sub new {
|
|||
|
||||
$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' },
|
||||
"warning-conn:s" => { name => 'warning_conn', default => '' },
|
||||
"critical-conn:s" => { name => 'critical_conn', default => '' },
|
||||
"warning-unhealthy:s" => { name => 'warning_unhealthy', default => '' },
|
||||
"critical-unhealthy:s" => { name => 'critical_unhealthy', default => '' },
|
||||
"warning-busy:s" => { name => 'warning_busy', default => '' },
|
||||
"critical-busy:s" => { name => 'critical_busy', default => '' },
|
||||
"warning-fail:s" => { name => 'warning_fail', default => '' },
|
||||
"critical-fail:s" => { name => 'critical_fail', default => '' },
|
||||
"warning-reuse:s" => { name => 'warning_reuse', default => '' },
|
||||
"critical-reuse:s" => { name => 'critical_reuse', default => '' },
|
||||
"warning-toolate:s" => { name => 'warning_toolate', default => '' },
|
||||
"critical-toolate:s" => { name => 'critical_toolate', default => '' },
|
||||
"warning-recycle:s" => { name => 'warning_recycle', default => '' },
|
||||
"critical-recycle:s" => { name => 'critical_recycle', default => '' },
|
||||
"warning-retry:s" => { name => 'warning_retry', default => '' },
|
||||
"critical-retry:s" => { name => 'critical_retry', default => '' },
|
||||
});
|
||||
{
|
||||
"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);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-conn', value => $self->{option_results}->{warning_conn})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-conn threshold '" . $self->{option_results}->{warning_conn} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-conn', value => $self->{option_results}->{critical_conn})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-conn threshold '" . $self->{option_results}->{critical_conn} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-unhealthy', value => $self->{option_results}->{warning_unhealthy})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-unhealthy threshold '" . $self->{option_results}->{warning_unhealthy} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-unhealthy', value => $self->{option_results}->{critical_unhealthy})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-unhealthy threshold '" . $self->{option_results}->{critical_unhealthy} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-busy', value => $self->{option_results}->{warning_busy})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-busy threshold '" . $self->{option_results}->{warning_busy} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-busy', value => $self->{option_results}->{critical_busy})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-busy threshold '" . $self->{option_results}->{critical_busy} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-fail', value => $self->{option_results}->{warning_fail})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-fail threshold '" . $self->{option_results}->{warning_fail} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-fail', value => $self->{option_results}->{critical_fail})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-fail threshold '" . $self->{option_results}->{critical_fail} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-reuse', value => $self->{option_results}->{warning_reuse})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-reuse threshold '" . $self->{option_results}->{warning_reuse} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-reuse', value => $self->{option_results}->{critical_reuse})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-reuse threshold '" . $self->{option_results}->{critical_reuse} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-toolate', value => $self->{option_results}->{warning_toolate})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-toolate threshold '" . $self->{option_results}->{warning_toolate} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-toolate', value => $self->{option_results}->{critical_toolate})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-toolate threshold '" . $self->{option_results}->{critical_toolate} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-recycle', value => $self->{option_results}->{warning_recycle})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-recycle threshold '" . $self->{option_results}->{warning_recycle} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-recycle', value => $self->{option_results}->{critical_recycle})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-recycle threshold '" . $self->{option_results}->{critical_recycle} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-retry', value => $self->{option_results}->{warning_retry})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-retry threshold '" . $self->{option_results}->{warning_retry} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-retry', value => $self->{option_results}->{critical_retry})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-retry threshold '" . $self->{option_results}->{critical_retry} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#my $stdout = '
|
||||
#backend_conn 13746 0.00 Backend conn. success
|
||||
#backend_unhealthy 0 0.00 Backend conn. not attempted
|
||||
#backend_busy 0 0.00 Backend conn. too many
|
||||
#backend_fail 0 0.00 Backend conn. failures
|
||||
#backend_reuse 0 0.00 Backend conn. reuses
|
||||
#backend_toolate 0 0.00 Backend conn. was closed
|
||||
#backend_recycle 0 0.00 Backend conn. recycles
|
||||
#backend_retry 0 0.00 Backend conn. retry
|
||||
#';
|
||||
};
|
||||
|
||||
sub getdata {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -204,123 +181,59 @@ sub run {
|
|||
$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');
|
||||
my $old_backend_conn = $self->{statefile_value}->get(name => 'backend_conn');
|
||||
my $old_backend_unhealthy = $self->{statefile_value}->get(name => 'backend_unhealthy');
|
||||
my $old_backend_busy = $self->{statefile_value}->get(name => 'backend_busy');
|
||||
my $old_backend_fail = $self->{statefile_value}->get(name => 'backend_fail');
|
||||
my $old_backend_reuse = $self->{statefile_value}->get(name => 'backend_reuse');
|
||||
my $old_backend_toolate = $self->{statefile_value}->get(name => 'backend_toolate');
|
||||
my $old_backend_recycle = $self->{statefile_value}->get(name => 'backend_recycle');
|
||||
my $old_backend_retry = $self->{statefile_value}->get(name => 'backend_retry');
|
||||
|
||||
# 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) || !defined($old_backend_conn)) {
|
||||
if (!defined($old_timestamp)) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "Buffer creation...");
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
# Set 0 if Cache > Result
|
||||
$old_backend_conn = 0 if ($old_backend_conn > $self->{result}->{backend_conn} );
|
||||
$old_backend_unhealthy = 0 if ($old_hitpass > $self->{result}->{backend_unhealthy});
|
||||
$old_backend_busy = 0 if ($old_miss > $self->{result}->{backend_busy});
|
||||
$old_backend_fail = 0 if ($old_miss > $self->{result}->{backend_fail});
|
||||
$old_backend_reuse = 0 if ($old_miss > $self->{result}->{backend_reuse});
|
||||
$old_backend_toolate = 0 if ($old_miss > $self->{result}->{backend_toolate});
|
||||
$old_backend_recycle = 0 if ($old_miss > $self->{result}->{backend_recycle});
|
||||
$old_backend_retry = 0 if ($old_miss > $self->{result}->{backend_retry});
|
||||
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} }]);
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate
|
||||
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||
my $backend_conn = ($self->{result}->{backend_conn} - $old_backend_conn) / $delta_time;
|
||||
my $backend_unhealthy = ($self->{result}->{backend_unhealthy} - $old_backend_unhealthy) / $delta_time;
|
||||
my $backend_busy = ($self->{result}->{backend_busy} - $old_backend_busy) / $delta_time;
|
||||
my $backend_fail = ($self->{result}->{backend_fail} - $old_backend_fail) / $delta_time;
|
||||
my $backend_reuse = ($self->{result}->{backend_reuse} - $old_backend_reuse) / $delta_time;
|
||||
my $backend_toolate = ($self->{result}->{backend_toolate} - $old_backend_toolate) / $delta_time;
|
||||
my $backend_recycle = ($self->{result}->{backend_recycle} - $old_backend_recycle) / $delta_time;
|
||||
my $backend_retry = ($self->{result}->{backend_retry} - $old_backend_retry) / $delta_time;
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $backend_conn, threshold => [ { label => 'critical-conn', 'exit_litteral' => 'critical' }, { label => 'warning-conn', exit_litteral => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $backend_unhealthy, threshold => [ { label => 'critical-unhealthy', 'exit_litteral' => 'critical' }, { label => 'warning-unhealthy', exit_litteral => 'warning' } ]);
|
||||
my $exit3 = $self->{perfdata}->threshold_check(value => $backend_busy, threshold => [ { label => 'critical-busy', 'exit_litteral' => 'critical' }, { label => 'warning-busy', exit_litteral => 'warning' } ]);
|
||||
my $exit4 = $self->{perfdata}->threshold_check(value => $backend_fail, threshold => [ { label => 'critical-fail', 'exit_litteral' => 'critical' }, { label => 'warning-fail', exit_litteral => 'warning' } ]);
|
||||
my $exit5 = $self->{perfdata}->threshold_check(value => $backend_reuse, threshold => [ { label => 'critical-reuse', 'exit_litteral' => 'critical' }, { label => 'warning-reuse', exit_litteral => 'warning' } ]);
|
||||
my $exit6 = $self->{perfdata}->threshold_check(value => $backend_toolate, threshold => [ { label => 'critical-toolate', 'exit_litteral' => 'critical' }, { label => 'warning-toolate', exit_litteral => 'warning' } ]);
|
||||
my $exit7 = $self->{perfdata}->threshold_check(value => $backend_recycle, threshold => [ { label => 'critical-recycle', 'exit_litteral' => 'critical' }, { label => 'warning-recycle', exit_litteral => 'warning' } ]);
|
||||
my $exit8 = $self->{perfdata}->threshold_check(value => $backend_retry, threshold => [ { label => 'critical-retry', 'exit_litteral' => 'critical' }, { label => 'warning-retry', exit_litteral => 'warning' } ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4, $exit5, $exit6, $exit7, $exit8 ]);
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Backend conn. success: %.2f
|
||||
Backend conn. not attempted: %.2f
|
||||
Backend conn. too many: %.2f
|
||||
Backend conn. failures: %.2f
|
||||
Backend conn. reuses: %.2f
|
||||
Backend conn. was closed: %.2f
|
||||
Backend conn. recycles: %.2f
|
||||
Backend conn. retry: %.2f ",
|
||||
$backend_conn,
|
||||
$backend_unhealthy,
|
||||
$backend_busy,
|
||||
$backend_fail,
|
||||
$backend_reuse,
|
||||
$backend_toolate,
|
||||
$backend_recycle,
|
||||
$backend_retry,
|
||||
));
|
||||
|
||||
$self->{output}->perfdata_add(label => "backend_conn",
|
||||
value => $backend_conn,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-conn'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-conn'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_unhealthy",
|
||||
value => $backend_unhealthy,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-unhealthy'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-unhealthy'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_busy",
|
||||
value => $backend_busy,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-busy'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-busy'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_fail",
|
||||
value => $backend_fail,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-fail'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-fail'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_reuse",
|
||||
value => $backend_reuse,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-reuse'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-reuse'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_toolate",
|
||||
value => $backend_toolate,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-toolate'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-toolate'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_recycle",
|
||||
value => $backend_recycle,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-recycle'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-recycle'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "backend_retry",
|
||||
value => $backend_retry,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-retry'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-retry'),
|
||||
min => 0
|
||||
);
|
||||
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();
|
||||
};
|
||||
|
@ -332,16 +245,7 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check Varnish Cache with varnishstat Command
|
||||
This Mode Checks:
|
||||
- Backend conn. success
|
||||
- Backend conn. not attempted
|
||||
- Backend conn. too many
|
||||
- Backend conn. failures
|
||||
- Backend conn. reuses
|
||||
- Backend conn. was closed
|
||||
- Backend conn. recycles
|
||||
- Backend conn. unused
|
||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
||||
|
||||
=over 8
|
||||
|
||||
|
@ -363,75 +267,35 @@ Varnishstat Binary Filename (Default: varnishstat)
|
|||
|
||||
=item B<--command-path>
|
||||
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin/)
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Parameter for Binary File (Default: ' -1 ')
|
||||
|
||||
=item B<--warning-conn>
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning Threshold for Backend conn. success
|
||||
Warning Threshold for:
|
||||
conn => Backend conn. success,
|
||||
unhealthy => Backend conn. not attempted,
|
||||
busy => Backend conn. too many,
|
||||
fail => Backend conn. failures,
|
||||
reuse => Backend conn. reuses,
|
||||
toolate => Backend conn. was closed,
|
||||
recycle => Backend conn. recycles,
|
||||
retry => Backend conn. retry
|
||||
|
||||
=item B<--critical-conn>
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical Threshold for Backend conn. success
|
||||
|
||||
=item B<--warning-unhealthy>
|
||||
|
||||
Warning Threshold for Backend conn. not attempted
|
||||
|
||||
=item B<--critical-unhealthy>
|
||||
|
||||
Critical Threshold for Backend conn. not attempted
|
||||
|
||||
=item B<--warning-busy>
|
||||
|
||||
Warning Threshold for Backend conn. too many
|
||||
|
||||
=item B<--critical-busy>
|
||||
|
||||
Critical Threshold for Backend conn. too many
|
||||
|
||||
=item B<--warning-fail>
|
||||
|
||||
Warning Threshold for Backend conn. failures
|
||||
|
||||
=item B<--critical-fail>
|
||||
|
||||
Critical Threshold for Backend conn. failures
|
||||
|
||||
=item B<--warning-reuse>
|
||||
|
||||
Warning Threshold for Backend conn. reuses
|
||||
|
||||
=item B<--critical-reuse>
|
||||
|
||||
Critical Threshold for Backend conn. reuses
|
||||
|
||||
=item B<--warning-toolate>
|
||||
|
||||
Warning Threshold for Backend conn. was closed
|
||||
|
||||
=item B<--critical-toolate>
|
||||
|
||||
Critical Threshold for Backend conn. was closed
|
||||
|
||||
=item B<--warning-recycle>
|
||||
|
||||
Warning Threshold for Backend conn. recycles
|
||||
|
||||
=item B<--critical-recycle>
|
||||
|
||||
Critical Threshold for Backend conn. recycles
|
||||
|
||||
=item B<--warning-retry>
|
||||
|
||||
Warning Threshold for Backend conn. retry
|
||||
|
||||
=item B<--critical-retry>
|
||||
|
||||
Critical Threshold for Backend conn. retry
|
||||
Critical Threshold for:
|
||||
conn => Backend conn. success,
|
||||
unhealthy => Backend conn. not attempted,
|
||||
busy => Backend conn. too many,
|
||||
fail => Backend conn. failures,
|
||||
reuse => Backend conn. reuses,
|
||||
toolate => Backend conn. was closed,
|
||||
recycle => Backend conn. recycles,
|
||||
retry => Backend conn. retry
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -205,10 +205,6 @@ sub run {
|
|||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => $str_output);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
};
|
||||
|
@ -242,7 +238,7 @@ Varnishstat Binary Filename (Default: varnishstat)
|
|||
|
||||
=item B<--command-path>
|
||||
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin/)
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
|
@ -250,11 +246,17 @@ Parameter for Binary File (Default: ' -1 ')
|
|||
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning Threshold for: hit => Cache Hits, hitpass => Cache hits for Pass, miss => Cache Misses
|
||||
Warning Threshold for:
|
||||
hit => Cache Hits,
|
||||
hitpass => Cache hits for Pass,
|
||||
miss => Cache Misses
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Warning Threshold for: hit => Cache Hits, hitpass => Cache hits for Pass, miss => Cache Misses
|
||||
Critical Threshold for:
|
||||
hit => Cache Hits,
|
||||
hitpass => Cache hits for Pass,
|
||||
miss => Cache Misses
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -33,13 +33,37 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package apps::varnish::mode::connections;
|
||||
package apps::varnish::mode::cache;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my $maps_counters = {
|
||||
client_conn => { thresholds => {
|
||||
warning_conn => { label => 'warning-conn', exit_value => 'warning' },
|
||||
critical_conn => { label => 'critical-conn', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Client connections accepted: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
client_drop => { thresholds => {
|
||||
warning_drop => { label => 'warning-drop', exit_value => 'warning' },
|
||||
critical_drop => { label => 'critical-drop', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Connection dropped, no sess/wrk: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
client_req => { thresholds => {
|
||||
warning_req => { label => 'warning-req', exit_value => 'warning' },
|
||||
critical_req => { label => 'critical-req', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Client requests received: %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
};
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,69 +71,47 @@ sub new {
|
|||
|
||||
$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' },
|
||||
"warning-hit:s" => { name => 'warning_hit', default => '' },
|
||||
"critical-hit:s" => { name => 'critical_hit', default => '' },
|
||||
"warning-hitpass:s" => { name => 'warning_hitpass', default => '' },
|
||||
"critical-hitpass:s" => { name => 'critical_hitpass', default => '' },
|
||||
"warning-miss:s" => { name => 'warning_miss', default => '' },
|
||||
"critical-miss:s" => { name => 'critical_miss', default => '' },
|
||||
});
|
||||
{
|
||||
"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);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-conn', value => $self->{option_results}->{warning_conn})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-conn threshold '" . $self->{option_results}->{warning_conn} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-conn', value => $self->{option_results}->{critical_conn})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-conn threshold '" . $self->{option_results}->{critical_conn} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-drop', value => $self->{option_results}->{warning_drop})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-drop threshold '" . $self->{option_results}->{warning_drop} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-drop', value => $self->{option_results}->{critical_drop})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-drop threshold '" . $self->{option_results}->{critical_drop} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-req', value => $self->{option_results}->{warning_req})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-req threshold '" . $self->{option_results}->{warning_req} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-req', value => $self->{option_results}->{critical_req})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-req threshold '" . $self->{option_results}->{critical_req} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#my $stdout = '
|
||||
#client_conn 7287199 1.00 Client connections accepted
|
||||
#client_drop 0 0.00 Connection dropped, no sess/wrk
|
||||
#client_req 24187 0.00 Client requests received
|
||||
#';
|
||||
};
|
||||
|
||||
sub getdata {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -144,65 +146,58 @@ sub run {
|
|||
$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');
|
||||
my $old_client_conn = $self->{statefile_value}->get(name => 'client_conn');
|
||||
my $old_client_drop = $self->{statefile_value}->get(name => 'client_drop');
|
||||
my $old_client_req = $self->{statefile_value}->get(name => 'client_req');
|
||||
|
||||
# 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) || !defined($old_client_conn)) {
|
||||
if (!defined($old_timestamp)) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "Buffer creation...");
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
# Set 0 if Cache > Result
|
||||
$old_client_conn = 0 if ($old_client_conn > $self->{result}->{client_conn} );
|
||||
$old_client_drop = 0 if ($old_hitpass > $self->{result}->{client_drop});
|
||||
$old_client_req = 0 if ($old_miss > $self->{result}->{client_req});
|
||||
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} }]);
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate
|
||||
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||
my $client_conn = ($self->{result}->{client_conn} - $old_client_conn) / $delta_time;
|
||||
my $client_drop = ($self->{result}->{client_drop} - $old_client_drop) / $delta_time;
|
||||
my $client_req = ($self->{result}->{client_req} - $old_client_req) / $delta_time;
|
||||
|
||||
#print $old_client_conn . "\n";
|
||||
#print $self->{result}->{client_conn} . "\n";
|
||||
#print $client_conn . "\n";
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $client_conn, threshold => [ { label => 'critical-conn', 'exit_litteral' => 'critical' }, { label => 'warning-conn', exit_litteral => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $client_drop, threshold => [ { label => 'critical-drop', 'exit_litteral' => 'critical' }, { label => 'warning-drop', exit_litteral => 'warning' } ]);
|
||||
my $exit3 = $self->{perfdata}->threshold_check(value => $client_req, threshold => [ { label => 'critical-req', 'exit_litteral' => 'critical' }, { label => 'warning-req', exit_litteral => 'warning' } ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
|
||||
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 => sprintf("Client connections accepted: %.2f Connection dropped, no sess/wrk: %.2f Client requests received: %.2f ",
|
||||
$client_conn,
|
||||
$client_drop,
|
||||
$client_req,
|
||||
));
|
||||
|
||||
$self->{output}->perfdata_add(label => "client_conn",
|
||||
value => $client_conn,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-conn'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-conn'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "client_drop",
|
||||
value => $client_drop,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-drop'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-drop'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "client_req",
|
||||
value => $client_req,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-req'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-req'),
|
||||
min => 0
|
||||
);
|
||||
short_msg => $str_output);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
@ -215,11 +210,7 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check Varnish Cache with varnishstat Command
|
||||
This Mode Checks:
|
||||
- Client connections accepted
|
||||
- Connection dropped, no sess
|
||||
- Client requests received
|
||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
||||
|
||||
=over 8
|
||||
|
||||
|
@ -241,35 +232,25 @@ Varnishstat Binary Filename (Default: varnishstat)
|
|||
|
||||
=item B<--command-path>
|
||||
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin/)
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Parameter for Binary File (Default: ' -1 ')
|
||||
|
||||
=item B<--warning-conn>
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning Threshold for Client connections accepted
|
||||
Warning Threshold for:
|
||||
conn => Client connections accepted,
|
||||
drop => Connection dropped, no sess/wrk,
|
||||
req => Client requests received
|
||||
|
||||
=item B<--critical-conn>
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical Threshold for Client connections accepted
|
||||
|
||||
=item B<--warning-drop>
|
||||
|
||||
Warning Threshold for Connection dropped, no sess/wrk
|
||||
|
||||
=item B<--critical-drop>
|
||||
|
||||
Critical Threshold for Connection dropped, no sess/wrk
|
||||
|
||||
=item B<--warning-req>
|
||||
|
||||
Warning Threshold for Client requests received
|
||||
|
||||
=item B<--critical-req>
|
||||
|
||||
Critical Threshold for Client requests received
|
||||
Critical Threshold for:
|
||||
conn => Client connections accepted,
|
||||
drop => Connection dropped, no sess/wrk,
|
||||
req => Client requests received
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -33,13 +33,100 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package apps::varnish::mode::fetch;
|
||||
package apps::varnish::mode::cache;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my $maps_counters = {
|
||||
backend_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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
warning_304 => { label => 'warning-304', exit_value => 'warning' },
|
||||
critical_304 => { label => 'critical-304', exit_value => 'critical' },
|
||||
},
|
||||
output_msg => 'Fetch no body (304): %.2f',
|
||||
factor => 1, unit => '',
|
||||
},
|
||||
};
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,177 +134,47 @@ sub new {
|
|||
|
||||
$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' },
|
||||
"warning-head:s" => { name => 'warning_head', default => '' },
|
||||
"critical-head:s" => { name => 'critical_head', default => '' },
|
||||
"warning-length:s" => { name => 'warning_length', default => '' },
|
||||
"critical-length:s" => { name => 'critical_length', default => '' },
|
||||
"warning-chunked:s" => { name => 'warning_chunked', default => '' },
|
||||
"critical-chunked:s" => { name => 'critical_chunked', default => '' },
|
||||
"warning-eof:s" => { name => 'warning_eof', default => '' },
|
||||
"critical-eof:s" => { name => 'critical_eof', default => '' },
|
||||
"warning-bad:s" => { name => 'warning_bad', default => '' },
|
||||
"critical-bad:s" => { name => 'critical_bad', default => '' },
|
||||
"warning-close:s" => { name => 'warning_close', default => '' },
|
||||
"critical-close:s" => { name => 'critical_close', default => '' },
|
||||
"warning-oldhttp:s" => { name => 'warning_oldhttp', default => '' },
|
||||
"critical-oldhttp:s" => { name => 'critical_oldhttp', default => '' },
|
||||
"warning-zero:s" => { name => 'warning_zero', default => '' },
|
||||
"critical-zero:s" => { name => 'critical_zero', default => '' },
|
||||
"warning-failed:s" => { name => 'warning_failed', default => '' },
|
||||
"critical-failed:s" => { name => 'critical_failed', default => '' },
|
||||
"warning-1xx:s" => { name => 'warning_1xx', default => '' },
|
||||
"critical-1xx:s" => { name => 'critical_1xx', default => '' },
|
||||
"warning-204:s" => { name => 'warning_204', default => '' },
|
||||
"critical-204:s" => { name => 'critical_204', default => '' },
|
||||
"warning-304:s" => { name => 'warning_304', default => '' },
|
||||
"critical-304:s" => { name => 'critical_304', default => '' },
|
||||
});
|
||||
{
|
||||
"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);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-head', value => $self->{option_results}->{warning_head})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-head threshold '" . $self->{option_results}->{warning_head} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-head', value => $self->{option_results}->{critical_head})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-head threshold '" . $self->{option_results}->{critical_head} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-length', value => $self->{option_results}->{warning_length})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-length threshold '" . $self->{option_results}->{warning_length} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-length', value => $self->{option_results}->{critical_length})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-length threshold '" . $self->{option_results}->{critical_length} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-chunked', value => $self->{option_results}->{warning_chunked})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-chunked threshold '" . $self->{option_results}->{warning_chunked} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-chunked', value => $self->{option_results}->{critical_chunked})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-chunked threshold '" . $self->{option_results}->{critical_chunked} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-eof', value => $self->{option_results}->{warning_eof})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-eof threshold '" . $self->{option_results}->{warning_eof} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-eof', value => $self->{option_results}->{critical_eof})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-eof threshold '" . $self->{option_results}->{critical_eof} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-bad', value => $self->{option_results}->{warning_bad})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-bad threshold '" . $self->{option_results}->{warning_bad} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-bad', value => $self->{option_results}->{critical_bad})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-bad threshold '" . $self->{option_results}->{critical_bad} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-close', value => $self->{option_results}->{warning_close})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-close threshold '" . $self->{option_results}->{warning_close} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-close', value => $self->{option_results}->{critical_close})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-close threshold '" . $self->{option_results}->{critical_close} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-oldhttp', value => $self->{option_results}->{warning_oldhttp})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-oldhttp threshold '" . $self->{option_results}->{warning_oldhttp} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-oldhttp', value => $self->{option_results}->{critical_oldhttp})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-oldhttp threshold '" . $self->{option_results}->{critical_oldhttp} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-zero', value => $self->{option_results}->{warning_zero})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-zero threshold '" . $self->{option_results}->{warning_zero} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-zero', value => $self->{option_results}->{critical_zero})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-zero threshold '" . $self->{option_results}->{critical_zero} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-failed', value => $self->{option_results}->{warning_failed})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-failed threshold '" . $self->{option_results}->{warning_failed} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-failed', value => $self->{option_results}->{critical_failed})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-failed threshold '" . $self->{option_results}->{critical_failed} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-1xx', value => $self->{option_results}->{warning_1xx})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-1xx threshold '" . $self->{option_results}->{warning_1xx} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-1xx', value => $self->{option_results}->{critical_1xx})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-1xx threshold '" . $self->{option_results}->{critical_1xx} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-204', value => $self->{option_results}->{warning_204})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-204 threshold '" . $self->{option_results}->{warning_204} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-204', value => $self->{option_results}->{critical_204})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-204 threshold '" . $self->{option_results}->{critical_204} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-304', value => $self->{option_results}->{warning_304})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-304 threshold '" . $self->{option_results}->{warning_304} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-304', value => $self->{option_results}->{critical_304})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-304 threshold '" . $self->{option_results}->{critical_304} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#my $stdout = '
|
||||
#fetch_head 0 0.00 Fetch head
|
||||
#fetch_length 13742 0.00 Fetch with Length
|
||||
#fetch_chunked 0 0.00 Fetch chunked
|
||||
#fetch_eof 0 0.00 Fetch EOF
|
||||
#fetch_bad 0 0.00 Fetch had bad headers
|
||||
#fetch_close 0 0.00 Fetch wanted close
|
||||
#fetch_oldhttp 0 0.00 Fetch pre HTTP/1.1 closed
|
||||
#fetch_zero 0 0.00 Fetch zero len
|
||||
#fetch_failed 0 0.00 Fetch failed
|
||||
#fetch_1xx 0 0.00 Fetch no body (1xx)
|
||||
#fetch_204 0 0.00 Fetch no body (204)
|
||||
#fetch_304 0 0.00 Fetch no body (304)
|
||||
#';
|
||||
};
|
||||
|
||||
sub getdata {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -252,173 +209,58 @@ sub run {
|
|||
$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');
|
||||
my $old_fetch_head = $self->{statefile_value}->get(name => 'fetch_head');
|
||||
my $old_fetch_length = $self->{statefile_value}->get(name => 'fetch_length');
|
||||
my $old_fetch_chunked = $self->{statefile_value}->get(name => 'fetch_chunked');
|
||||
my $old_fetch_eof = $self->{statefile_value}->get(name => 'fetch_eof');
|
||||
my $old_fetch_bad = $self->{statefile_value}->get(name => 'fetch_bad');
|
||||
my $old_fetch_close = $self->{statefile_value}->get(name => 'fetch_close');
|
||||
my $old_fetch_oldhttp = $self->{statefile_value}->get(name => 'fetch_oldhttp');
|
||||
my $old_fetch_zero = $self->{statefile_value}->get(name => 'fetch_zero');
|
||||
my $old_fetch_failed = $self->{statefile_value}->get(name => 'fetch_failed');
|
||||
my $old_fetch_1xx = $self->{statefile_value}->get(name => 'fetch_1xx');
|
||||
my $old_fetch_204 = $self->{statefile_value}->get(name => 'fetch_204');
|
||||
my $old_fetch_304 = $self->{statefile_value}->get(name => 'fetch_304');
|
||||
|
||||
# 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) || !defined($old_fetch_head)) {
|
||||
if (!defined($old_timestamp)) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "Buffer creation...");
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
# Set 0 if Cache > Result
|
||||
$old_fetch_head = 0 if ($old_fetch_head > $self->{result}->{fetch_head} );
|
||||
$old_fetch_length = 0 if ($old_hitpass > $self->{result}->{fetch_length});
|
||||
$old_fetch_chunked = 0 if ($old_miss > $self->{result}->{fetch_chunked});
|
||||
$old_fetch_eof = 0 if ($old_miss > $self->{result}->{fetch_eof});
|
||||
$old_fetch_bad = 0 if ($old_miss > $self->{result}->{fetch_bad});
|
||||
$old_fetch_close = 0 if ($old_miss > $self->{result}->{fetch_close});
|
||||
$old_fetch_oldhttp = 0 if ($old_miss > $self->{result}->{fetch_oldhttp});
|
||||
$old_fetch_zero = 0 if ($old_miss > $self->{result}->{fetch_zero});
|
||||
$old_fetch_failed = 0 if ($old_miss > $self->{result}->{fetch_failed});
|
||||
$old_fetch_1xx = 0 if ($old_miss > $self->{result}->{fetch_1xx});
|
||||
$old_fetch_204 = 0 if ($old_miss > $self->{result}->{fetch_204});
|
||||
$old_fetch_304 = 0 if ($old_miss > $self->{result}->{fetch_304});
|
||||
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} }]);
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate
|
||||
my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp;
|
||||
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
|
||||
my $fetch_head = ($self->{result}->{fetch_head} - $old_fetch_head) / $delta_time;
|
||||
my $fetch_length = ($self->{result}->{fetch_length} - $old_fetch_length) / $delta_time;
|
||||
my $fetch_chunked = ($self->{result}->{fetch_chunked} - $old_fetch_chunked) / $delta_time;
|
||||
my $fetch_eof = ($self->{result}->{fetch_eof} - $old_fetch_eof) / $delta_time;
|
||||
my $fetch_bad = ($self->{result}->{fetch_bad} - $old_fetch_bad) / $delta_time;
|
||||
my $fetch_close = ($self->{result}->{fetch_close} - $old_fetch_close) / $delta_time;
|
||||
my $fetch_oldhttp = ($self->{result}->{fetch_oldhttp} - $old_fetch_oldhttp) / $delta_time;
|
||||
my $fetch_zero = ($self->{result}->{fetch_zero} - $old_fetch_zero) / $delta_time;
|
||||
my $fetch_failed = ($self->{result}->{fetch_failed} - $old_fetch_failed) / $delta_time;
|
||||
my $fetch_1xx = ($self->{result}->{fetch_1xx} - $old_fetch_1xx) / $delta_time;
|
||||
my $fetch_204 = ($self->{result}->{fetch_204} - $old_fetch_204) / $delta_time;
|
||||
my $fetch_304 = ($self->{result}->{fetch_304} - $old_fetch_304) / $delta_time;
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $fetch_head, threshold => [ { label => 'critical-head', 'exit_litteral' => 'critical' }, { label => 'warning-head', exit_litteral => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $fetch_length, threshold => [ { label => 'critical-length', 'exit_litteral' => 'critical' }, { label => 'warning-length', exit_litteral => 'warning' } ]);
|
||||
my $exit3 = $self->{perfdata}->threshold_check(value => $fetch_chunked, threshold => [ { label => 'critical-chunked', 'exit_litteral' => 'critical' }, { label => 'warning-chunked', exit_litteral => 'warning' } ]);
|
||||
my $exit4 = $self->{perfdata}->threshold_check(value => $fetch_eof, threshold => [ { label => 'critical-eof', 'exit_litteral' => 'critical' }, { label => 'warning-eof', exit_litteral => 'warning' } ]);
|
||||
my $exit5 = $self->{perfdata}->threshold_check(value => $fetch_eof, threshold => [ { label => 'critical-eof', 'exit_litteral' => 'critical' }, { label => 'warning-eof', exit_litteral => 'warning' } ]);
|
||||
my $exit6 = $self->{perfdata}->threshold_check(value => $fetch_close, threshold => [ { label => 'critical-close', 'exit_litteral' => 'critical' }, { label => 'warning-close', exit_litteral => 'warning' } ]);
|
||||
my $exit7 = $self->{perfdata}->threshold_check(value => $fetch_oldhttp, threshold => [ { label => 'critical-oldhttp', 'exit_litteral' => 'critical' }, { label => 'warning-oldhttp', exit_litteral => 'warning' } ]);
|
||||
my $exit8 = $self->{perfdata}->threshold_check(value => $fetch_zero, threshold => [ { label => 'critical-zero', 'exit_litteral' => 'critical' }, { label => 'warning-zero', exit_litteral => 'warning' } ]);
|
||||
my $exit9 = $self->{perfdata}->threshold_check(value => $fetch_failed, threshold => [ { label => 'critical-failed', 'exit_litteral' => 'critical' }, { label => 'warning-failed', exit_litteral => 'warning' } ]);
|
||||
my $exit10 = $self->{perfdata}->threshold_check(value => $fetch_1xx, threshold => [ { label => 'critical-1xx', 'exit_litteral' => 'critical' }, { label => 'warning-1xx', exit_litteral => 'warning' } ]);
|
||||
my $exit11 = $self->{perfdata}->threshold_check(value => $fetch_204, threshold => [ { label => 'critical-204', 'exit_litteral' => 'critical' }, { label => 'warning-204', exit_litteral => 'warning' } ]);
|
||||
my $exit12 = $self->{perfdata}->threshold_check(value => $fetch_304, threshold => [ { label => 'critical-304', 'exit_litteral' => 'critical' }, { label => 'warning-304', exit_litteral => 'warning' } ]);
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4, $exit5, $exit6, $exit7, $exit8, $exit9, $exit10, $exit11, $exit12 ]);
|
||||
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 => sprintf("Fetch head: %.2f
|
||||
Fetch with Length: %.2f
|
||||
Fetch chunked: %.2f
|
||||
Fetch EOF: %.2f
|
||||
Fetch had bad headers: %.2f
|
||||
Fetch wanted close: %.2f
|
||||
Fetch pre HTTP/1.1 closed: %.2f
|
||||
Fetch zero len: %.2f
|
||||
Fetch failed: %.2f
|
||||
Fetch no body (1xx): %.2f
|
||||
Fetch no body (204): %.2f
|
||||
Fetch no body (304): %.2f ",
|
||||
$fetch_head,
|
||||
$fetch_length,
|
||||
$fetch_chunked,
|
||||
$fetch_eof,
|
||||
$fetch_bad,
|
||||
$fetch_close,
|
||||
$fetch_oldhttp,
|
||||
$fetch_zero,
|
||||
$fetch_failed,
|
||||
$fetch_1xx,
|
||||
$fetch_204,
|
||||
$fetch_304,
|
||||
));
|
||||
|
||||
$self->{output}->perfdata_add(label => "fetch_head",
|
||||
value => $fetch_head,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-head'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-head'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_length",
|
||||
value => $fetch_length,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-length'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-length'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_chunked",
|
||||
value => $fetch_chunked,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-chunked'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-chunked'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_eof",
|
||||
value => $fetch_eof,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-eof'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-eof'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_bad",
|
||||
value => $fetch_bad,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-bad'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-bad'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_close",
|
||||
value => $fetch_close,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-close'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-close'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_oldhttp",
|
||||
value => $fetch_oldhttp,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-oldhttp'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-oldhttp'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_zero",
|
||||
value => $fetch_zero,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-zero'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-zero'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_failed",
|
||||
value => $fetch_failed,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-failed'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-failed'),
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => "fetch_1xx",
|
||||
value => $fetch_1xx,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-1xx'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-1xx'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_204",
|
||||
value => $fetch_204,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-204'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-204'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(label => "fetch_304",
|
||||
value => $fetch_304,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-304'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-304'),
|
||||
min => 0
|
||||
);
|
||||
short_msg => $str_output);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
@ -431,20 +273,7 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check Varnish Cache with varnishstat Command
|
||||
This Mode Checks:
|
||||
- Fetch head
|
||||
- Fetch with Length
|
||||
- Fetch chunked
|
||||
- Fetch EOF
|
||||
- Fetch had bad headers
|
||||
- Fetch wanted close
|
||||
- Fetch pre HTTP/1.1 closed
|
||||
- Fetch zero len
|
||||
- Fetch failed
|
||||
- Fetch no body (1xx)
|
||||
- Fetch no body (204)
|
||||
- Fetch no body (304)
|
||||
Check Varnish Cache with varnishstat Command for: Cache hits, Cache hits for pass, Cache misses
|
||||
|
||||
=over 8
|
||||
|
||||
|
@ -466,107 +295,43 @@ Varnishstat Binary Filename (Default: varnishstat)
|
|||
|
||||
=item B<--command-path>
|
||||
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin/)
|
||||
Directory Path to Varnishstat Binary File (Default: /usr/bin)
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Parameter for Binary File (Default: ' -1 ')
|
||||
|
||||
=item B<--warning-head>
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning Threshold for Fetch head
|
||||
Warning Threshold for:
|
||||
fetch_head => Fetch head,
|
||||
fetch_length => Fetch with Length,
|
||||
fetch_chunked => Fetch chunked,
|
||||
fetch_eof => Fetch EOF,
|
||||
fetch_bad => Fetch had bad headers,
|
||||
fetch_close => Fetch wanted close,
|
||||
fetch_oldhttp => Fetch pre HTTP/1.1 closed,
|
||||
fetch_zero => Fetch zero len,
|
||||
fetch_failed => Fetch failed,
|
||||
fetch_1xx => Fetch no body (1xx),
|
||||
fetch_204 => Fetch no body (204),
|
||||
fetch_304 => Fetch no body (304)
|
||||
|
||||
=item B<--critical-head>
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical Threshold for Fetch head
|
||||
|
||||
=item B<--warning-length>
|
||||
|
||||
Warning Threshold for Fetch with Length
|
||||
|
||||
=item B<--critical-length>
|
||||
|
||||
Critical Threshold for Fetch with Length
|
||||
|
||||
=item B<--warning-chunked>
|
||||
|
||||
Warning Threshold for Fetch chunked
|
||||
|
||||
=item B<--critical-chunked>
|
||||
|
||||
Critical Threshold for Fetch chunked
|
||||
|
||||
=item B<--warning-eof>
|
||||
|
||||
Warning Threshold for Fetch EOF
|
||||
|
||||
=item B<--critical-eof>
|
||||
|
||||
Critical Threshold for Fetch EOF
|
||||
|
||||
=item B<--warning-bad>
|
||||
|
||||
Warning Threshold for Fetch had bad headers
|
||||
|
||||
=item B<--critical-bad>
|
||||
|
||||
Critical Threshold for Fetch had bad headers
|
||||
|
||||
=item B<--warning-close>
|
||||
|
||||
Warning Threshold for Fetch wanted close
|
||||
|
||||
=item B<--critical-close>
|
||||
|
||||
Critical Threshold for Fetch wanted close
|
||||
|
||||
=item B<--warning-oldhttp>
|
||||
|
||||
Warning Threshold for Fetch pre HTTP/1.1 closed
|
||||
|
||||
=item B<--critical-oldhttp>
|
||||
|
||||
Critical Threshold for Fetch pre HTTP/1.1 closed
|
||||
|
||||
=item B<--warning-zero>
|
||||
|
||||
Warning Threshold for Fetch zero len
|
||||
|
||||
=item B<--critical-zero>
|
||||
|
||||
Critical Threshold for Fetch zero len
|
||||
|
||||
=item B<--warning-failed>
|
||||
|
||||
Warning Threshold for Fetch failed
|
||||
|
||||
=item B<--critical-failed>
|
||||
|
||||
Critical Threshold for Fetch failed
|
||||
|
||||
=item B<--warning-1xx>
|
||||
|
||||
Warning Threshold for Fetch no body (1xx)
|
||||
|
||||
=item B<--critical-1xx>
|
||||
|
||||
Critical Threshold for Fetch no body (1xx)
|
||||
|
||||
=item B<--warning-204>
|
||||
|
||||
Warning Threshold for Fetch no body (204)
|
||||
|
||||
=item B<--critical-204>
|
||||
|
||||
Critical Threshold for Fetch no body (204)
|
||||
|
||||
=item B<--warning-304>
|
||||
|
||||
Warning Threshold for Fetch no body (304)
|
||||
|
||||
=item B<--critical-304>
|
||||
|
||||
Critical Threshold for Fetch no body (304)
|
||||
Critical Threshold for:
|
||||
fetch_head => Fetch head,
|
||||
fetch_length => Fetch with Length,
|
||||
fetch_chunked => Fetch chunked,
|
||||
fetch_eof => Fetch EOF,
|
||||
fetch_bad => Fetch had bad headers,
|
||||
fetch_close => Fetch wanted close,
|
||||
fetch_oldhttp => Fetch pre HTTP/1.1 closed,
|
||||
fetch_zero => Fetch zero len,
|
||||
fetch_failed => Fetch failed,
|
||||
fetch_1xx => Fetch no body (1xx),
|
||||
fetch_204 => Fetch no body (204),
|
||||
fetch_304 => Fetch no body (304)
|
||||
|
||||
=back
|
||||
|
||||
|
|
Loading…
Reference in New Issue