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} = [
{ label => 'ratio', nlabel => 'http.hits.percentage', set => {
key_values => [ { name => 'ratio' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Ratio: %.2f',
output_template => 'ratio: %.2f',
perfdatas => [
{ label => 'ratio', template => '%.2f',
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' } ],
output_template => 'Hits Error: %.3f hits/s',
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' }
]
}
},
{ label => 'hits', nlabel => 'http.hits.hitspersecond', set => {
{ label => 'hits', nlabel => 'http.hits.persecond', set => {
key_values => [ { name => 'hits' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Hits: %.3f hits/s',
output_template => 'hits: %.3f hits/s',
perfdatas => [
{ label => 'hits', template => '%.3f',
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} = [
{ label => 'ratio', nlabel => 'connections.ratio.percentage.', set => {
{ label => 'ratio', nlabel => 'connections.ratio.percentage', set => {
key_values => [ { name => 'syns_ratio' }, { name => 'key' }, { name => 'instance_label' } ],
output_template => 'Ratio: %.2f',
output_template => 'ratio: %.2f',
perfdatas => [
{ label => 'ratio', template => '%.2f',
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' } ],
output_template => 'Connections Attempts: %.2f conn/s',
output_template => 'connections attempts: %.2f conn/s',
perfdatas => [
{ label => 'attempt', template => '%.2f',
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' } ],
output_template => 'Successful Connections: %.2f conn/s',
output_template => 'successful connections: %.2f conn/s',
perfdatas => [
{ label => 'successful', template => '%.2f',
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' } ],
output_template => 'Average Connection Time: %.3f ms',
output_template => 'average connection time: %.3f ms',
perfdatas => [
{ label => 'connection_time', template => '%.3f',
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'key' }
@ -87,7 +87,7 @@ sub new {
'instance:s' => { name => 'instance', default => 'layer' },
'top:s' => { name => 'top' },
'filter:s' => { name => 'filter' },
'from:s' => { name => 'from' },
'from:s' => { name => 'from' }
});
return $self;

View File

@ -34,63 +34,60 @@ sub set_counters {
];
$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' } ],
output_template => 'Total Traffic: %.2f %s/s',
output_change_bytes => 2,
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' } ],
output_template => 'Total Server Traffic: %.2f %s/s',
output_change_bytes => 2,
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' } ],
output_template => 'Total Client Traffic: %.2f %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'total_client_traffic', template => '%d', min => 0, unit => 'b/s' }
{ template => '%d', min => 0, unit => 'b/s' }
]
}
}
];
$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' } ],
output_template => 'Traffic: %.2f %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'traffic', template => '%d',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
{ template => '%d', 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' } ],
output_template => 'Server Traffic: %.2f %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'server_traffic', template => '%d',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
{ template => '%d', 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' } ],
output_template => 'Client Traffic: %.2f %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'client_traffic', template => '%d',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
{ template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }
]
}
}
@ -112,14 +109,14 @@ sub prefix_instances_output {
sub new {
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;
$options{options}->add_options(arguments => {
'instance:s' => { name => 'instance', default => 'layer' },
'top:s' => { name => 'top' },
'filter:s' => { name => 'filter' },
'from:s' => { name => 'from' },
'from:s' => { name => 'from' }
});
return $self;

View File

@ -39,9 +39,9 @@ sub set_counters {
];
$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' } ],
output_template => 'End-User Experience: %.3f s',
output_template => 'end-user experience: %.3fs',
perfdatas => [
{ label => 'time', template => '%.3f',
min => 0, unit => 's', label_extra_instance => 1, instance_use => 'key' }

View File

@ -36,8 +36,7 @@ my %handlers = (ALRM => {});
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf('status is %s', $self->{result_values}->{status});
return $msg;
return sprintf('status is %s', $self->{result_values}->{status});
}
sub custom_status_calc {
@ -70,7 +69,7 @@ sub set_counters {
$self->{maps_counters_type} = [
{ 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} = [
@ -87,9 +86,9 @@ sub set_counters {
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' } ],
output_template => 'execution time : %s ms',
output_template => 'execution time: %s ms',
perfdatas => [
{ label => 'total_time', template => '%s', min => 0, unit => 'ms' }
]
@ -97,7 +96,7 @@ sub set_counters {
},
{ label => 'total-steps', nlabel => 'scenario.steps.count', set => {
key_values => [ { name => 'total_steps' } ],
output_template => 'total steps : %s',
output_template => 'total steps: %s',
perfdatas => [
{ label => 'total_steps', template => '%s', min => 0 }
]
@ -105,17 +104,17 @@ sub set_counters {
},
{ label => 'failures', nlabel => 'scenario.failures.count', set => {
key_values => [ { name => 'failures' } ],
output_template => 'failures : %s',
output_template => 'failures: %s',
perfdatas => [
{ label => 'failures', value => 'failures', template => '%s', min => 0 }
{ label => 'failures', template => '%s', min => 0 }
]
}
},
{ label => 'errors', nlabel => 'scenario.errors.count', set => {
key_values => [ { name => 'errors' } ],
output_template => 'errors : %s',
output_template => 'errors: %s',
perfdatas => [
{ label => 'errors', value => 'errors', template => '%s', min => 0 }
{ label => 'errors', template => '%s', min => 0 }
]
}
},
@ -124,14 +123,13 @@ sub set_counters {
$self->{maps_counters}->{steps} = [
{ label => 'step-time', nlabel => 'step.execution.time.second', set => {
key_values => [ { name => 'time_taken' }, { name => 'step' } ],
output_template => 'execution time : %s ms',
output_template => 'execution time: %s ms',
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' }
]
}
}
];
}
@ -225,7 +223,7 @@ sub decode_xml_response {
$self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@");
$self->{output}->option_exit();
}
return $content;
}
@ -250,7 +248,7 @@ sub time2ms {
sub killed_scenario {
my ($self, %options) = @_;
return if (!defined($self->{user_defined_id}));
$self->{http}->request(
proto => $self->{option_results}->{sahi_proto},
@ -265,7 +263,7 @@ sub killed_scenario {
sub cleanup_scenario {
my ($self, %options) = @_;
return if (!defined($self->{user_defined_id}));
$self->{http}->request(
proto => $self->{option_results}->{sahi_proto},
@ -280,7 +278,7 @@ sub cleanup_scenario {
sub run_scenario {
my ($self, %options) = @_;
my $user_defined_id = $self->generate_user_defined_id();
my ($content) = $self->{http}->request(
proto => $self->{option_results}->{sahi_proto},
@ -300,18 +298,18 @@ sub run_scenario {
'userDefinedId=' . $user_defined_id,
]
);
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => 'run scenario issue:' . $content);
$self->{output}->option_exit();
}
$self->{user_defined_id} = $user_defined_id;
}
sub check_scenario_status {
my ($self, %options) = @_;
my $content;
my $retries = 0;
while (1) {
@ -339,16 +337,16 @@ sub check_scenario_status {
sleep($self->{option_results}->{interval_scenario_status});
}
my $status = 'UNKNOWN';
$status = $1 if ($content =~ /(SUCCESS|FAILURE|ABORTED|SKIPPED|USER_ABORTED)/);
$self->{global}->{status} = $status;
}
sub get_suite_report {
my ($self, %options) = @_;
my ($content) = $self->{http}->request(
proto => $self->{option_results}->{sahi_proto},
port => $self->{option_results}->{sahi_port},

View File

@ -48,9 +48,13 @@ sub custom_info_perfdata {
sub custom_info_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{num_members},
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
my $exit = $self->{perfdata}->threshold_check(
value => $self->{result_values}->{num_members},
threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit;
}
@ -82,7 +86,7 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'count', nlabel => 'channels.count', set => {
key_values => [ { name => 'count' } ],
output_template => 'Number of channels : %d',
output_template => 'Number of channels: %d',
perfdatas => [
{ label => 'count', template => '%d', min => 0 }
]
@ -108,7 +112,7 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"filter-channel:s" => { name => 'filter_channel' },
'filter-channel:s' => { name => 'filter_channel' }
});
return $self;

View File

@ -42,7 +42,7 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'count', nlabel => 'members.count', set => {
key_values => [ { name => 'count' } ],
output_template => 'Number of members : %d',
output_template => 'Number of members: %d',
perfdatas => [
{ label => 'count', template => '%d', min => 0 }
]
@ -60,6 +60,7 @@ sub set_counters {
}
];
}
sub custom_info_output {
my ($self, %options) = @_;
@ -82,9 +83,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {});
return $self;
}

View File

@ -33,17 +33,17 @@ sub set_counters {
];
$self->{maps_counters}->{global} = [
{ label => 'cpu', nlabel => 'cpu.cache.utilization.percentage', set => {
{ label => 'cpu', nlabel => 'cache.cpu.utilization.percentage', set => {
key_values => [ { name => 'cacheCpuUsage' } ],
output_template => 'Cpu usage : %s %%',
output_template => 'Cpu usage: %s %%',
perfdatas => [
{ label => 'cpu', template => '%s', min => 0, max => 100, unit => '%' }
]
}
},
{ label => 'memory', nlabel => 'memory.cache.usage.bytes', set => {
{ label => 'memory', nlabel => 'cache.memory.usage.bytes', set => {
key_values => [ { name => 'cacheMemUsage' } ],
output_template => 'Memory usage : %s %s',
output_template => 'Memory usage: %s %s',
output_change_bytes => 1,
perfdatas => [
{ label => 'memory', template => '%s', min => 0, unit => 'B' }
@ -52,7 +52,7 @@ sub set_counters {
},
{ label => 'fd', nlabel => 'cache.filedescriptors.count', set => {
key_values => [ { name => 'cacheCurrentFileDescrCnt' } ],
output_template => 'Number of file descriptors : %s',
output_template => 'Number of file descriptors: %s',
perfdatas => [
{ label => 'fd', template => '%s', min => 0 }
]
@ -60,7 +60,7 @@ sub set_counters {
},
{ label => 'object', nlabel => 'cache.objects.count', set => {
key_values => [ { name => 'cacheNumObjCount' } ],
output_template => 'Number of object stored : %s',
output_template => 'Number of object stored: %s',
perfdatas => [
{ label => 'objects', template => '%s', min => 0 }
]
@ -73,10 +73,10 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
@ -87,11 +87,11 @@ sub manage_selection {
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',
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 => [
values %oids
], nothing_quit => 1);
my $snmp_result = $options{snmp}->get_leef(
oids => [ values %oids ],
nothing_quit => 1);
$snmp_result->{$oids{cacheMemUsage}} *= 1024;
$self->{global} = {};

View File

@ -59,7 +59,7 @@ sub prefix_server_output {
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global_http', type => 0, cb_prefix_output => 'prefix_http_output', skipped_code => { -10 => 1 } },
{ name => 'global_icp', type => 0, cb_prefix_output => 'prefix_icp_output', skipped_code => { -10 => 1 } },
@ -70,15 +70,15 @@ sub set_counters {
{ label => 'http-hits-rate', nlabel => 'http.hits.percentage', set => {
key_values => [ { name => 'cacheProtoClientHttpRequests', diff => 1 }, { name => 'cacheHttpHits', diff => 1 } ],
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 => [
{ label => 'http_hits_rate'template => '%.2f', min => 0, max => 100, unit => '%' }
{ label => 'http_hits_rate', template => '%.2f', min => 0, max => 100, unit => '%' }
]
}
},
{ label => 'http-errors', nlabel => 'http.errors.count', set => {
key_values => [ { name => 'cacheHttpErrors', diff => 1 } ],
output_template => 'errors : %s',
output_template => 'errors: %s',
perfdatas => [
{ label => 'http_errors', template => '%s', min => 0 }
]
@ -86,7 +86,7 @@ sub set_counters {
},
{ label => 'http-traffic-in', nlabel => 'http.traffic.in.bitspersecond', set => {
key_values => [ { name => 'cacheHttpInKb', per_second => 1 } ],
output_template => 'traffic in : %s %s/s',
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'http_traffic_in', template => '%s', min => 0, unit => 'b/s' }
@ -95,7 +95,7 @@ sub set_counters {
},
{ label => 'http-traffic-out', nlabel => 'http.traffic.out.bitspersecond', set => {
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,
perfdatas => [
{ label => 'http_traffic_out', template => '%s', min => 0, unit => 'b/s' }
@ -107,7 +107,7 @@ sub set_counters {
$self->{maps_counters}->{global_icp} = [
{ label => 'icp-traffic-in', nlabel => 'icp.traffic.in.bitspersecond', set => {
key_values => [ { name => 'cacheIcpKbRecv', per_second => 1 } ],
output_template => 'traffic in : %s %s/s',
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'icp_traffic_in', template => '%s', min => 0, unit => 'b/s' }
@ -116,7 +116,7 @@ sub set_counters {
},
{ label => 'icp-traffic-out', nlabel => 'icp.traffic.out.bitspersecond', set => {
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,
perfdatas => [
{ label => 'icp_traffic_out', template => '%s', min => 0, unit => 'b/s' }
@ -126,27 +126,27 @@ sub set_counters {
];
$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 } ],
output_template => 'traffic in : %s %s/s',
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'server_traffic_in', template => '%s', min => 0, unit => 'b/s' }
]
}
},
{ 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 } ],
output_template => 'traffic Out : %s %s/s',
output_template => 'traffic out: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ 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' } ],
output_template => 'current number of clients : %s',
output_template => 'current number of clients: %s',
perfdatas => [
{ label => 'clients', template => '%s', min => 0 }
]
@ -159,7 +159,7 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});