From ae3dce98b41381602c8b55707f8a78496db76ace Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 29 Jul 2015 16:44:25 +0200 Subject: [PATCH] + use bytes for http size --- apps/protocols/http/mode/expectedcontent.pm | 26 ++++++++++++--------- apps/protocols/http/mode/response.pm | 26 ++++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/apps/protocols/http/mode/expectedcontent.pm b/apps/protocols/http/mode/expectedcontent.pm index 742e16d4d..cd818c741 100644 --- a/apps/protocols/http/mode/expectedcontent.pm +++ b/apps/protocols/http/mode/expectedcontent.pm @@ -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(); diff --git a/apps/protocols/http/mode/response.pm b/apps/protocols/http/mode/response.pm index 0f925d962..f9cada349 100644 --- a/apps/protocols/http/mode/response.pm +++ b/apps/protocols/http/mode/response.pm @@ -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();