diff --git a/apps/protocols/snmp/mode/responsetime.pm b/apps/protocols/snmp/mode/responsetime.pm index eedabaabd..199453559 100644 --- a/apps/protocols/snmp/mode/responsetime.pm +++ b/apps/protocols/snmp/mode/responsetime.pm @@ -26,6 +26,12 @@ use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); +sub prefix_output { + my ($self, %options) = @_; + + return "SNMP Agent "; +} + sub set_counters { my ($self, %options) = @_; @@ -34,45 +40,39 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'rta', set => { + { label => 'rta', nlabel => 'response.time.average', set => { key_values => [ { name => 'rta' } ], output_template => 'rta %.3fms', perfdatas => [ - { label => 'rta', value => 'rta', template => '%.3f', min => 0, unit => 'ms' }, - ], + { label => 'rta', template => '%.3f', min => 0, unit => 'ms' } + ] } }, - { label => 'rtmax', display_ok => 0, set => { + { label => 'rtmax', nlabel => 'response.time.max', display_ok => 0, set => { key_values => [ { name => 'rtmax' } ], perfdatas => [ - { label => 'rtmax', value => 'rtmax', template => '%.3f', min => 0, unit => 'ms' }, - ], + { label => 'rtmax', template => '%.3f', min => 0, unit => 'ms' } + ] } }, - { label => 'rtmin', display_ok => 0, set => { + { label => 'rtmin', nlabel => 'response.time.max', display_ok => 0, set => { key_values => [ { name => 'rtmin' } ], perfdatas => [ - { label => 'rtmin', value => 'rtmin', template => '%.3f', min => 0, unit => 'ms' }, - ], + { label => 'rtmin', template => '%.3f', min => 0, unit => 'ms' } + ] } }, - { label => 'pl', set => { + { label => 'pl', nlabel => 'packets.loss.percentage', set => { key_values => [ { name => 'pl' } ], output_template => 'lost %s%%', perfdatas => [ - { label => 'pl', value => 'pl', template => '%s', min => 0, max => 100, unit => '%' }, - ], + { label => 'pl', template => '%s', min => 0, max => 100, unit => '%' } + ] } - }, + } ]; } -sub prefix_output { - my ($self, %options) = @_; - - return "SNMP Agent "; -} - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -80,7 +80,7 @@ sub new { $options{options}->add_options(arguments => { "timeout:s" => { name => 'timeout' }, - "packets:s" => { name => 'packets' }, + "packets:s" => { name => 'packets' } }); return $self; diff --git a/apps/protocols/snmp/plugin.pm b/apps/protocols/snmp/plugin.pm index f031b5ef2..1d68b9807 100644 --- a/apps/protocols/snmp/plugin.pm +++ b/apps/protocols/snmp/plugin.pm @@ -30,13 +30,13 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'dynamic-command' => 'snmp_standard::mode::dynamiccommand', - 'numeric-value' => 'snmp_standard::mode::numericvalue', - 'response-time' => 'apps::protocols::snmp::mode::responsetime', - 'string-value' => 'snmp_standard::mode::stringvalue', - 'uptime' => 'snmp_standard::mode::uptime', - ); + $self->{modes} = { + 'dynamic-command' => 'snmp_standard::mode::dynamiccommand', + 'numeric-value' => 'snmp_standard::mode::numericvalue', + 'response-time' => 'apps::protocols::snmp::mode::responsetime', + 'string-value' => 'snmp_standard::mode::stringvalue', + 'uptime' => 'snmp_standard::mode::uptime' + }; return $self; }