+ use bytes for http size

This commit is contained in:
garnier-quentin 2015-07-29 16:44:25 +02:00
parent b06dad62b6
commit ae3dce98b4
2 changed files with 30 additions and 22 deletions

View File

@ -128,18 +128,22 @@ sub run {
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
# Size check
my $content_size = length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
{
require bytes;
my $content_size = bytes::length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
}
$self->{output}->perfdata_add(label => "size", unit => 'B',
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
}
$self->{output}->perfdata_add(label => "size",
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
$self->{output}->display();
$self->{output}->exit();

View File

@ -114,18 +114,22 @@ sub run {
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
# Size check
my $content_size = length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
{
require bytes;
my $content_size = bytes::length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
}
$self->{output}->perfdata_add(label => "size", unit => 'B',
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
}
$self->{output}->perfdata_add(label => "size",
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
$self->{output}->display();
$self->{output}->exit();