enh(plugin): PVX Rest API metricsv2 (#2820)

* enh(plugin): PVX Restapi metricsv2

* nlabel name fix
This commit is contained in:
itoussies 2021-05-24 11:47:28 +02:00 committed by GitHub
parent cb5d170caf
commit 1e79829632
5 changed files with 50 additions and 50 deletions

View File

@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -33,42 +39,36 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'ratio', set => { { label => 'ratio', nlabel => 'http.hits.percentage', set => {
key_values => [ { name => 'ratio' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'ratio' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Ratio: %.2f', output_template => 'Ratio: %.2f',
perfdatas => [ perfdatas => [
{ label => 'ratio', template => '%.2f', { label => 'ratio', template => '%.2f',
min => 0, label_extra_instance => 1, instance_use => 'key' }, min => 0, label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, },
{ label => 'hits-error', set => { { label => 'hits-error', nlabel => 'http.hits.error.hitspersecond', set => {
key_values => [ { name => 'error_hits' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'error_hits' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Hits Error: %.3f hits/s', output_template => 'Hits Error: %.3f hits/s',
perfdatas => [ perfdatas => [
{ label => 'hits_error', template => '%.3f', { label => 'hits_error', template => '%.3f',
min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }, min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, },
{ label => 'hits', set => { { label => 'hits', nlabel => 'http.hits.hitspersecond', set => {
key_values => [ { name => 'hits' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'hits' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Hits: %.3f hits/s', output_template => 'Hits: %.3f hits/s',
perfdatas => [ perfdatas => [
{ label => 'hits', template => '%.3f', { label => 'hits', template => '%.3f',
min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }, min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, }
]; ];
} }
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);

View File

@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -33,51 +39,45 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'ratio', set => { { label => 'ratio', nlabel => 'connections.ratio.percentage.', set => {
key_values => [ { name => 'syns_ratio' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'syns_ratio' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Ratio: %.2f', output_template => 'Ratio: %.2f',
perfdatas => [ perfdatas => [
{ label => 'ratio', template => '%.2f', { label => 'ratio', template => '%.2f',
min => 0, label_extra_instance => 1, instance_use => 'key' }, min => 0, label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, },
{ label => 'attempt', set => { { label => 'attempt', nlabel => 'connections.attempt.connectionspersecond', set => {
key_values => [ { name => 'syns' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'syns' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Connections Attempts: %.2f conn/s', output_template => 'Connections Attempts: %.2f conn/s',
perfdatas => [ perfdatas => [
{ label => 'attempt', template => '%.2f', { label => 'attempt', template => '%.2f',
min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }, min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, },
{ label => 'successful', set => { { label => 'successful', nlabel => 'connections.successful.connectionspersecond', set => {
key_values => [ { name => 'ct_count' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'ct_count' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Successful Connections: %.2f conn/s', output_template => 'Successful Connections: %.2f conn/s',
perfdatas => [ perfdatas => [
{ label => 'successful', template => '%.2f', { label => 'successful', template => '%.2f',
min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }, min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, },
{ label => 'connection-time', set => { { label => 'connection-time', nlabel => 'connection.time.millisecond', set => {
key_values => [ { name => 'ct' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'ct' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Average Connection Time: %.3f ms', output_template => 'Average Connection Time: %.3f ms',
perfdatas => [ perfdatas => [
{ label => 'connection_time', template => '%.3f', { label => 'connection_time', template => '%.3f',
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'key' }, min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'key' }
], ]
} }
}, }
]; ];
} }
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);

View File

@ -34,7 +34,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-traffic', set => { { label => 'total-traffic', nlabel => 'traffic.total.bitspersecond', set => {
key_values => [ { name => 'total_traffic' } ], key_values => [ { name => 'total_traffic' } ],
output_template => 'Total Traffic: %.2f %s/s', output_template => 'Total Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -43,7 +43,7 @@ sub set_counters {
] ]
} }
}, },
{ label => 'total-server-traffic', set => { { label => 'total-server-traffic', nlabel => 'traffic.server.total.bitspersecond', set => {
key_values => [ { name => 'total_server_traffic' } ], key_values => [ { name => 'total_server_traffic' } ],
output_template => 'Total Server Traffic: %.2f %s/s', output_template => 'Total Server Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -52,7 +52,7 @@ sub set_counters {
] ]
} }
}, },
{ label => 'total-client-traffic', set => { { label => 'total-client-traffic', nlabel => 'traffic.client.total.bitspersecond', set => {
key_values => [ { name => 'total_client_traffic' } ], key_values => [ { name => 'total_client_traffic' } ],
output_template => 'Total Client Traffic: %.2f %s/s', output_template => 'Total Client Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -64,7 +64,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'traffic', set => { { label => 'traffic', nlabel => 'traffic.bitspersecond', set => {
key_values => [ { name => 'traffic' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'traffic' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Traffic: %.2f %s/s', output_template => 'Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -74,7 +74,7 @@ sub set_counters {
] ]
} }
}, },
{ label => 'server-traffic', set => { { label => 'server-traffic', nlabel => 'traffic.server.bitspersecond', set => {
key_values => [ { name => 'server_traffic' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'server_traffic' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Server Traffic: %.2f %s/s', output_template => 'Server Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -84,7 +84,7 @@ sub set_counters {
] ]
} }
}, },
{ label => 'client-traffic', set => { { label => 'client-traffic', nlabel => 'traffic.client.bitspersecond', set => {
key_values => [ { name => 'client_traffic' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'client_traffic' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Client Traffic: %.2f %s/s', output_template => 'Client Traffic: %.2f %s/s',
output_change_bytes => 2, output_change_bytes => 2,

View File

@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -33,7 +39,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'time', set => { { label => 'time', nlabel => 'enduser.experience.second', set => {
key_values => [ { name => 'user_experience' }, { name => 'key' }, { name => 'instance_label' } ], key_values => [ { name => 'user_experience' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'End-User Experience: %.3f s', output_template => 'End-User Experience: %.3f s',
perfdatas => [ perfdatas => [
@ -45,12 +51,6 @@ sub set_counters {
]; ];
} }
sub prefix_instances_output {
my ($self, %options) = @_;
return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);

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} => {
'http-hits' => 'apps::pvx::restapi::mode::httphits', 'http-hits' => 'apps::pvx::restapi::mode::httphits',
'network-connection' => 'apps::pvx::restapi::mode::networkconnection', 'network-connection' => 'apps::pvx::restapi::mode::networkconnection',
'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience', 'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience',
'network-traffic' => 'apps::pvx::restapi::mode::networktraffic', 'network-traffic' => 'apps::pvx::restapi::mode::networktraffic',
); };
$self->{custom_modes}{api} = 'apps::pvx::restapi::custom::api'; $self->{custom_modes}{api} = 'apps::pvx::restapi::custom::api';
return $self; return $self;