diff --git a/centreon-plugins/apps/pvx/restapi/mode/httphits.pm b/centreon-plugins/apps/pvx/restapi/mode/httphits.pm index d4f46fe70..59963a104 100644 --- a/centreon-plugins/apps/pvx/restapi/mode/httphits.pm +++ b/centreon-plugins/apps/pvx/restapi/mode/httphits.pm @@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_instances_output { + my ($self, %options) = @_; + + return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' "; +} + sub set_counters { my ($self, %options) = @_; @@ -33,42 +39,36 @@ sub set_counters { ]; $self->{maps_counters}->{instances} = [ - { label => 'ratio', set => { + { label => 'ratio', nlabel => 'http.hits.percentage', set => { key_values => [ { name => 'ratio' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Ratio: %.2f', perfdatas => [ { 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' } ], output_template => 'Hits Error: %.3f hits/s', perfdatas => [ { 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' } ], output_template => 'Hits: %.3f hits/s', perfdatas => [ { 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/apps/pvx/restapi/mode/networkconnection.pm b/centreon-plugins/apps/pvx/restapi/mode/networkconnection.pm index f1097b05c..bf676ce52 100644 --- a/centreon-plugins/apps/pvx/restapi/mode/networkconnection.pm +++ b/centreon-plugins/apps/pvx/restapi/mode/networkconnection.pm @@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_instances_output { + my ($self, %options) = @_; + + return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' "; +} + sub set_counters { my ($self, %options) = @_; @@ -33,51 +39,45 @@ sub set_counters { ]; $self->{maps_counters}->{instances} = [ - { label => 'ratio', set => { + { label => 'ratio', nlabel => 'connections.ratio.percentage.', set => { key_values => [ { name => 'syns_ratio' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Ratio: %.2f', perfdatas => [ { 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' } ], output_template => 'Connections Attempts: %.2f conn/s', perfdatas => [ { 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' } ], output_template => 'Successful Connections: %.2f conn/s', perfdatas => [ { 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' } ], output_template => 'Average Connection Time: %.3f ms', perfdatas => [ { 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/apps/pvx/restapi/mode/networktraffic.pm b/centreon-plugins/apps/pvx/restapi/mode/networktraffic.pm index 68c9a4766..b6705ff37 100644 --- a/centreon-plugins/apps/pvx/restapi/mode/networktraffic.pm +++ b/centreon-plugins/apps/pvx/restapi/mode/networktraffic.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-traffic', set => { + { label => 'total-traffic', nlabel => 'traffic.total.bitspersecond', set => { key_values => [ { name => 'total_traffic' } ], output_template => 'Total Traffic: %.2f %s/s', 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' } ], output_template => 'Total Server Traffic: %.2f %s/s', 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' } ], output_template => 'Total Client Traffic: %.2f %s/s', output_change_bytes => 2, @@ -64,7 +64,7 @@ sub set_counters { ]; $self->{maps_counters}->{instances} = [ - { label => 'traffic', set => { + { label => 'traffic', nlabel => 'traffic.bitspersecond', set => { key_values => [ { name => 'traffic' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Traffic: %.2f %s/s', 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' } ], output_template => 'Server Traffic: %.2f %s/s', 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' } ], output_template => 'Client Traffic: %.2f %s/s', output_change_bytes => 2, diff --git a/centreon-plugins/apps/pvx/restapi/mode/networkuserexperience.pm b/centreon-plugins/apps/pvx/restapi/mode/networkuserexperience.pm index 8640de609..404270f82 100644 --- a/centreon-plugins/apps/pvx/restapi/mode/networkuserexperience.pm +++ b/centreon-plugins/apps/pvx/restapi/mode/networkuserexperience.pm @@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_instances_output { + my ($self, %options) = @_; + + return $options{instance_value}->{instance_label} . " '" . $options{instance_value}->{key} . "' "; +} + sub set_counters { my ($self, %options) = @_; @@ -33,7 +39,7 @@ sub set_counters { ]; $self->{maps_counters}->{instances} = [ - { label => 'time', set => { + { label => 'time', nlabel => 'enduser.experience.second', set => { key_values => [ { name => 'user_experience' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'End-User Experience: %.3f s', 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); diff --git a/centreon-plugins/apps/pvx/restapi/plugin.pm b/centreon-plugins/apps/pvx/restapi/plugin.pm index 659fe42ff..3d74954d3 100644 --- a/centreon-plugins/apps/pvx/restapi/plugin.pm +++ b/centreon-plugins/apps/pvx/restapi/plugin.pm @@ -30,12 +30,12 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{modes} => { 'http-hits' => 'apps::pvx::restapi::mode::httphits', 'network-connection' => 'apps::pvx::restapi::mode::networkconnection', 'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience', 'network-traffic' => 'apps::pvx::restapi::mode::networktraffic', - ); + }; $self->{custom_modes}{api} = 'apps::pvx::restapi::custom::api'; return $self;