enh(plugin)apps-protocols-snmp metricsv2 (#2582)

This commit is contained in:
itoussies 2021-02-09 13:47:45 +01:00 committed by GitHub
parent 0275a85c77
commit 141cbf8e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 27 deletions

View File

@ -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;

View File

@ -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;
}