apps-protocol-http metricsv2 (#2524)

This commit is contained in:
itoussies 2021-01-25 10:16:13 +01:00 committed by GitHub
parent 4ea35cb699
commit 717dcf859f
3 changed files with 20 additions and 20 deletions

View File

@ -26,12 +26,12 @@ use strict;
use warnings; use warnings;
use centreon::plugins::http; use centreon::plugins::http;
use Time::HiRes qw(gettimeofday tv_interval); use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_content_threshold { sub custom_content_threshold {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{instance_mode}->{content_status} = catalog_status_threshold($self, %options); $self->{instance_mode}->{content_status} = catalog_status_threshold_ng($self, %options);
return $self->{instance_mode}->{content_status}; return $self->{instance_mode}->{content_status};
} }
@ -74,30 +74,30 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_content_threshold'), closure_custom_threshold_check => $self->can('custom_content_threshold'),
} }
}, },
{ label => 'size', display_ok => 0, set => { { label => 'size', nlabel => 'http.content.size.bytes', display_ok => 0, set => {
key_values => [ { name => 'size' } ], key_values => [ { name => 'size' } ],
output_template => 'Content size : %s', output_template => 'Content size : %s',
perfdatas => [ perfdatas => [
{ label => 'size', value => 'size', template => '%s', min => 0, unit => 'B' }, { label => 'size', template => '%s', min => 0, unit => 'B' }
], ]
} }
}, },
{ label => 'time', display_ok => 0, set => { { label => 'time', nlabel => 'http.response.time.seconds', display_ok => 0, set => {
key_values => [ { name => 'time' } ], key_values => [ { name => 'time' } ],
output_template => 'Response time : %.3fs', output_template => 'Response time : %.3fs',
perfdatas => [ perfdatas => [
{ label => 'time', value => 'time', template => '%.3f', min => 0, unit => 's' }, { label => 'time', template => '%.3f', min => 0, unit => 's' }
], ]
} }
}, },
{ label => 'extracted', display_ok => 0, set => { { label => 'extracted', nlabel => 'http.extracted.value', display_ok => 0, set => {
key_values => [ { name => 'extracted' } ], key_values => [ { name => 'extracted' } ],
output_template => 'Extracted value : %s', output_template => 'Extracted value : %s',
perfdatas => [ perfdatas => [
{ label => 'value', value => 'extracted', template => '%s' }, { label => 'value', template => '%s' }
], ]
} }
}, }
]; ];
} }

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng catalog_status_calc);
use Time::HiRes qw(gettimeofday tv_interval); use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::http; use centreon::plugins::http;
@ -49,7 +49,7 @@ sub set_counters {
closure_custom_calc => \&catalog_status_calc, closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold closure_custom_threshold_check => \&catalog_status_threshold_ng
} }
}, },
{ label => 'time', nlabel => 'http.response.time.seconds', set => { { label => 'time', nlabel => 'http.response.time.seconds', set => {

View File

@ -30,12 +30,12 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( $self->{modes} = (
'expected-content' => 'apps::protocols::http::mode::expectedcontent', 'expected-content' => 'apps::protocols::http::mode::expectedcontent',
'json-content' => 'apps::protocols::http::mode::jsoncontent', 'json-content' => 'apps::protocols::http::mode::jsoncontent',
'response' => 'apps::protocols::http::mode::response', 'response' => 'apps::protocols::http::mode::response',
'soap-content' => 'apps::protocols::http::mode::soapcontent', 'soap-content' => 'apps::protocols::http::mode::soapcontent'
); };
return $self; return $self;
} }