en(perfdata): some minor perfdata changes + fix (#2825)

This commit is contained in:
qgarnier 2021-05-25 09:02:17 +02:00 committed by GitHub
parent deb7a381b7
commit 5b788acf23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 90 additions and 92 deletions

View File

@ -41,25 +41,25 @@ sub set_counters {
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'ratio', nlabel => 'http.hits.percentage', 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', nlabel => 'http.hits.error.hitspersecond', set => { { label => 'hits-error', nlabel => 'http.hits.error.persecond', 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', nlabel => 'http.hits.hitspersecond', set => { { label => 'hits', nlabel => 'http.hits.persecond', 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' }

View File

@ -39,36 +39,36 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'ratio', nlabel => 'connections.ratio.percentage.', 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', nlabel => 'connections.attempt.connectionspersecond', set => { { label => 'attempt', nlabel => 'connections.attempts.persecond', 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', nlabel => 'connections.successful.connectionspersecond', set => { { label => 'successful', nlabel => 'connections.successful.persecond', 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', nlabel => 'connection.time.millisecond', set => { { label => 'connection-time', nlabel => 'connection.time.milliseconds', 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' }
@ -87,7 +87,7 @@ sub new {
'instance:s' => { name => 'instance', default => 'layer' }, 'instance:s' => { name => 'instance', default => 'layer' },
'top:s' => { name => 'top' }, 'top:s' => { name => 'top' },
'filter:s' => { name => 'filter' }, 'filter:s' => { name => 'filter' },
'from:s' => { name => 'from' }, 'from:s' => { name => 'from' }
}); });
return $self; return $self;

View File

@ -34,63 +34,60 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-traffic', nlabel => 'traffic.total.bitspersecond', set => { { label => 'total-traffic', nlabel => 'traffic.aggregated.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,
perfdatas => [ perfdatas => [
{ label => 'total_traffic', template => '%d', min => 0, unit => 'b/s' } { template => '%d', min => 0, unit => 'b/s' }
] ]
} }
}, },
{ label => 'total-server-traffic', nlabel => 'traffic.server.total.bitspersecond', set => { { label => 'total-server-traffic', nlabel => 'traffic.server.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,
perfdatas => [ perfdatas => [
{ label => 'total_server_traffic', template => '%d', min => 0, unit => 'b/s' } { template => '%d', min => 0, unit => 'b/s' }
] ]
} }
}, },
{ label => 'total-client-traffic', nlabel => 'traffic.client.total.bitspersecond', set => { { label => 'total-client-traffic', nlabel => 'traffic.client.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,
perfdatas => [ perfdatas => [
{ label => 'total_client_traffic', template => '%d', min => 0, unit => 'b/s' } { template => '%d', min => 0, unit => 'b/s' }
] ]
} }
} }
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'traffic', nlabel => 'traffic.bitspersecond', set => { { label => 'traffic', nlabel => 'instance.traffic.aggregated.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,
perfdatas => [ perfdatas => [
{ label => 'traffic', template => '%d', { template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
] ]
} }
}, },
{ label => 'server-traffic', nlabel => 'traffic.server.bitspersecond', set => { { label => 'server-traffic', nlabel => 'instance.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,
perfdatas => [ perfdatas => [
{ label => 'server_traffic', template => '%d', { template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
] ]
} }
}, },
{ label => 'client-traffic', nlabel => 'traffic.client.bitspersecond', set => { { label => 'client-traffic', nlabel => 'instance.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,
perfdatas => [ perfdatas => [
{ label => 'client_traffic', template => '%d', { template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
] ]
} }
} }
@ -112,14 +109,14 @@ sub prefix_instances_output {
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, force_new_perfdata => 1);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'instance:s' => { name => 'instance', default => 'layer' }, 'instance:s' => { name => 'instance', default => 'layer' },
'top:s' => { name => 'top' }, 'top:s' => { name => 'top' },
'filter:s' => { name => 'filter' }, 'filter:s' => { name => 'filter' },
'from:s' => { name => 'from' }, 'from:s' => { name => 'from' }
}); });
return $self; return $self;

View File

@ -39,9 +39,9 @@ sub set_counters {
]; ];
$self->{maps_counters}->{instances} = [ $self->{maps_counters}->{instances} = [
{ label => 'time', nlabel => 'enduser.experience.second', set => { { label => 'time', nlabel => 'enduser.experience.seconds', 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: %.3fs',
perfdatas => [ perfdatas => [
{ label => 'time', template => '%.3f', { label => 'time', template => '%.3f',
min => 0, unit => 's', label_extra_instance => 1, instance_use => 'key' } min => 0, unit => 's', label_extra_instance => 1, instance_use => 'key' }

View File

@ -36,8 +36,7 @@ my %handlers = (ALRM => {});
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf('status is %s', $self->{result_values}->{status}); return sprintf('status is %s', $self->{result_values}->{status});
return $msg;
} }
sub custom_status_calc { sub custom_status_calc {
@ -70,7 +69,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } },
{ name => 'steps', type => 1, cb_prefix_output => 'prefix_step_output', message_multiple => 'All steps are ok', sort_method => 'num' }, { name => 'steps', type => 1, cb_prefix_output => 'prefix_step_output', message_multiple => 'All steps are ok', sort_method => 'num' }
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
@ -87,7 +86,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold_ng closure_custom_threshold_check => \&catalog_status_threshold_ng
} }
}, },
{ label => 'total-time', nlabel => 'scenario.execution.time.second', set => { { label => 'total-time', nlabel => 'scenario.execution.time.seconds', set => {
key_values => [ { name => 'time_taken' } ], key_values => [ { name => 'time_taken' } ],
output_template => 'execution time: %s ms', output_template => 'execution time: %s ms',
perfdatas => [ perfdatas => [
@ -107,7 +106,7 @@ sub set_counters {
key_values => [ { name => 'failures' } ], key_values => [ { name => 'failures' } ],
output_template => 'failures: %s', output_template => 'failures: %s',
perfdatas => [ perfdatas => [
{ label => 'failures', value => 'failures', template => '%s', min => 0 } { label => 'failures', template => '%s', min => 0 }
] ]
} }
}, },
@ -115,7 +114,7 @@ sub set_counters {
key_values => [ { name => 'errors' } ], key_values => [ { name => 'errors' } ],
output_template => 'errors: %s', output_template => 'errors: %s',
perfdatas => [ perfdatas => [
{ label => 'errors', value => 'errors', template => '%s', min => 0 } { label => 'errors', template => '%s', min => 0 }
] ]
} }
}, },
@ -126,12 +125,11 @@ sub set_counters {
key_values => [ { name => 'time_taken' }, { name => 'step' } ], key_values => [ { name => 'time_taken' }, { name => 'step' } ],
output_template => 'execution time: %s ms', output_template => 'execution time: %s ms',
perfdatas => [ perfdatas => [
{ label => 'step_time', value => 'time_taken', template => '%s', { label => 'step_time', template => '%s',
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'step' } min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'step' }
] ]
} }
} }
]; ];
} }

View File

@ -48,9 +48,13 @@ sub custom_info_perfdata {
sub custom_info_threshold { sub custom_info_threshold {
my ($self, %options) = @_; my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{num_members}, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, value => $self->{result_values}->{num_members},
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -108,7 +112,7 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-channel:s" => { name => 'filter_channel' }, 'filter-channel:s' => { name => 'filter_channel' }
}); });
return $self; return $self;

View File

@ -60,6 +60,7 @@ sub set_counters {
} }
]; ];
} }
sub custom_info_output { sub custom_info_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -82,9 +83,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {});
{
});
return $self; return $self;
} }

View File

@ -33,7 +33,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'cpu', nlabel => 'cpu.cache.utilization.percentage', set => { { label => 'cpu', nlabel => 'cache.cpu.utilization.percentage', set => {
key_values => [ { name => 'cacheCpuUsage' } ], key_values => [ { name => 'cacheCpuUsage' } ],
output_template => 'Cpu usage: %s %%', output_template => 'Cpu usage: %s %%',
perfdatas => [ perfdatas => [
@ -41,7 +41,7 @@ sub set_counters {
] ]
} }
}, },
{ label => 'memory', nlabel => 'memory.cache.usage.bytes', set => { { label => 'memory', nlabel => 'cache.memory.usage.bytes', set => {
key_values => [ { name => 'cacheMemUsage' } ], key_values => [ { name => 'cacheMemUsage' } ],
output_template => 'Memory usage: %s %s', output_template => 'Memory usage: %s %s',
output_change_bytes => 1, output_change_bytes => 1,
@ -87,11 +87,11 @@ sub manage_selection {
cacheMemUsage => '.1.3.6.1.4.1.3495.1.3.1.3.0', cacheMemUsage => '.1.3.6.1.4.1.3495.1.3.1.3.0',
cacheCpuUsage => '.1.3.6.1.4.1.3495.1.3.1.5.0', cacheCpuUsage => '.1.3.6.1.4.1.3495.1.3.1.5.0',
cacheNumObjCount => '.1.3.6.1.4.1.3495.1.3.1.7.0', cacheNumObjCount => '.1.3.6.1.4.1.3495.1.3.1.7.0',
cacheCurrentFileDescrCnt => '.1.3.6.1.4.1.3495.1.3.1.12.0', cacheCurrentFileDescrCnt => '.1.3.6.1.4.1.3495.1.3.1.12.0'
); );
my $snmp_result = $options{snmp}->get_leef(oids => [ my $snmp_result = $options{snmp}->get_leef(
values %oids oids => [ values %oids ],
], nothing_quit => 1); nothing_quit => 1);
$snmp_result->{$oids{cacheMemUsage}} *= 1024; $snmp_result->{$oids{cacheMemUsage}} *= 1024;
$self->{global} = {}; $self->{global} = {};

View File

@ -72,7 +72,7 @@ sub set_counters {
closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc => $self->can('custom_data_calc'),
output_template => 'hits rate: %.2f %%', output_use => 'hits_prct', threshold_use => 'hits_prct', output_template => 'hits rate: %.2f %%', output_use => 'hits_prct', threshold_use => 'hits_prct',
perfdatas => [ perfdatas => [
{ label => 'http_hits_rate'template => '%.2f', min => 0, max => 100, unit => '%' } { label => 'http_hits_rate', template => '%.2f', min => 0, max => 100, unit => '%' }
] ]
} }
}, },
@ -95,7 +95,7 @@ sub set_counters {
}, },
{ label => 'http-traffic-out', nlabel => 'http.traffic.out.bitspersecond', set => { { label => 'http-traffic-out', nlabel => 'http.traffic.out.bitspersecond', set => {
key_values => [ { name => 'cacheHttpOutKb', per_second => 1 } ], key_values => [ { name => 'cacheHttpOutKb', per_second => 1 } ],
output_template => 'traffic Out : %s %s/s', output_template => 'traffic out: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'http_traffic_out', template => '%s', min => 0, unit => 'b/s' } { label => 'http_traffic_out', template => '%s', min => 0, unit => 'b/s' }
@ -116,7 +116,7 @@ sub set_counters {
}, },
{ label => 'icp-traffic-out', nlabel => 'icp.traffic.out.bitspersecond', set => { { label => 'icp-traffic-out', nlabel => 'icp.traffic.out.bitspersecond', set => {
key_values => [ { name => 'cacheIcpKbSent', per_second => 1 } ], key_values => [ { name => 'cacheIcpKbSent', per_second => 1 } ],
output_template => 'traffic Out : %s %s/s', output_template => 'traffic out: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'icp_traffic_out', template => '%s', min => 0, unit => 'b/s' } { label => 'icp_traffic_out', template => '%s', min => 0, unit => 'b/s' }
@ -126,7 +126,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'server-traffic-in', nlabel => 'server.traffic.in.bitspersecond', set => { { label => 'server-traffic-in', nlabel => 'cache.server.traffic.in.bitspersecond', set => {
key_values => [ { name => 'cacheServerInKb', per_second => 1 } ], key_values => [ { name => 'cacheServerInKb', per_second => 1 } ],
output_template => 'traffic in: %s %s/s', output_template => 'traffic in: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -135,16 +135,16 @@ sub set_counters {
] ]
} }
}, },
{ label => 'server-traffic-out', nlabel => 'server.traffic.out.bitspersecond', set => { { label => 'server-traffic-out', nlabel => 'cache.server.traffic.out.bitspersecond', set => {
key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ], key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ],
output_template => 'traffic Out : %s %s/s', output_template => 'traffic out: %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'server_traffic_out', template => '%s', min => 0, unit => 'b/s' } { label => 'server_traffic_out', template => '%s', min => 0, unit => 'b/s' }
] ]
} }
}, },
{ label => 'clients', nlabel => 'clients.count', set => { { label => 'clients', nlabel => 'cache.clients.count', set => {
key_values => [ { name => 'cacheClients' } ], key_values => [ { name => 'cacheClients' } ],
output_template => 'current number of clients: %s', output_template => 'current number of clients: %s',
perfdatas => [ perfdatas => [