From 535eacc4b846ce0c9db147081a8b3734c18b44d8 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Mon, 6 May 2019 13:22:43 +0200 Subject: [PATCH] + refactoring metrics step 2 (#1489) * + refactoring metrics step 2 * s/newlabel/nlabel/ --- .../activedirectory/local/mode/dfsrbacklog.pm | 2 +- database/cassandra/jmx/mode/cachesusage.pm | 4 +- .../cassandra/jmx/mode/clientrequestsusage.pm | 8 ++-- .../cassandra/jmx/mode/threadpoolsusage.pm | 12 +++--- database/firebird/mode/longqueries.pm | 1 + database/firebird/mode/memory.pm | 40 ++++++++++--------- database/firebird/mode/pages.pm | 12 +++--- database/firebird/mode/queries.pm | 20 +++++----- database/firebird/mode/users.pm | 1 + database/sap/hana/mode/blockedtransactions.pm | 2 +- database/sap/hana/mode/connectedusers.pm | 2 +- database/sap/hana/mode/diskusage.pm | 7 ++-- database/sap/hana/mode/hostcpu.pm | 12 +++--- database/sap/hana/mode/hostmemory.pm | 7 ++-- database/sap/hana/mode/volumeusage.pm | 7 ++-- os/windows/snmp/mode/memory.pm | 7 ++-- os/windows/snmp/mode/swap.pm | 1 + 17 files changed, 75 insertions(+), 70 deletions(-) diff --git a/apps/activedirectory/local/mode/dfsrbacklog.pm b/apps/activedirectory/local/mode/dfsrbacklog.pm index 395cda9a2..538c3f094 100644 --- a/apps/activedirectory/local/mode/dfsrbacklog.pm +++ b/apps/activedirectory/local/mode/dfsrbacklog.pm @@ -33,7 +33,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'backlog', set => { + { label => 'backlog', nlabel => 'backlog.file.count', set => { key_values => [ { name => 'backlog' } ], output_template => 'Backlog File Count : %s', perfdatas => [ diff --git a/database/cassandra/jmx/mode/cachesusage.pm b/database/cassandra/jmx/mode/cachesusage.pm index ac52ed3bc..8b0ee51c7 100644 --- a/database/cassandra/jmx/mode/cachesusage.pm +++ b/database/cassandra/jmx/mode/cachesusage.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{ccache} = [ - { label => 'used', set => { + { label => 'used', nlabel => 'ccache.utilization.percentage' set => { key_values => [ { name => 'Capacity_Value' }, { name => 'Size_Value' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), @@ -45,7 +45,7 @@ sub set_counters { ], } }, - { label => 'hits', set => { + { label => 'hits', nlabel => 'ccache.hits.percentage', set => { key_values => [ { name => 'Requests_Count', diff => 1 }, { name => 'Hits_Count', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_hits_calc'), output_template => 'Hits = %.2f %%', output_use => 'hits_prct', threshold_use => 'hits_prct', diff --git a/database/cassandra/jmx/mode/clientrequestsusage.pm b/database/cassandra/jmx/mode/clientrequestsusage.pm index 6ba2b37af..bb18e1f1f 100644 --- a/database/cassandra/jmx/mode/clientrequestsusage.pm +++ b/database/cassandra/jmx/mode/clientrequestsusage.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{cr} = [ - { label => 'total-latency', set => { + { label => 'total-latency', nlabel => 'client.request.latency.microsecond', set => { key_values => [ { name => 'TotalLatency_Count', diff => 1 }, { name => 'display' } ], output_template => 'Total Latency : %s us', perfdatas => [ @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'timeouts', set => { + { label => 'timeouts', nlabel => 'client.request.timeout.count', set => { key_values => [ { name => 'Timeouts_Count', diff => 1 }, { name => 'display' } ], output_template => 'Timeouts : %s', perfdatas => [ @@ -52,7 +52,7 @@ sub set_counters { ], } }, - { label => 'unavailables', set => { + { label => 'unavailables', nlabel => 'client.request.unavailable.count', set => { key_values => [ { name => 'Unavailables_Count', diff => 1 }, { name => 'display' } ], output_template => 'Unavailables : %s', perfdatas => [ @@ -61,7 +61,7 @@ sub set_counters { ], } }, - { label => 'failures', set => { + label => 'failures', nlabel => 'client.request.failure.count', set => { key_values => [ { name => 'Failures_Count', diff => 1 }, { name => 'display' } ], output_template => 'Failures : %s', perfdatas => [ diff --git a/database/cassandra/jmx/mode/threadpoolsusage.pm b/database/cassandra/jmx/mode/threadpoolsusage.pm index 7ffc5aac1..c3ac7ed91 100644 --- a/database/cassandra/jmx/mode/threadpoolsusage.pm +++ b/database/cassandra/jmx/mode/threadpoolsusage.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{thpool} = [ - { label => 'active-tasks', set => { + { label => 'active-tasks', nlabel => 'thread.tasks.active.count', set => { key_values => [ { name => 'ActiveTasks_Value' }, { name => 'display' } ], output_template => 'Current Active Tasks : %s', perfdatas => [ @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'pending-tasks', set => { + { label => 'pending-tasks', nlabel => 'thread.tasks.pending.count', set => { key_values => [ { name => 'PendingTasks_Value' }, { name => 'display' } ], output_template => 'Current Pending Tasks : %s', perfdatas => [ @@ -52,7 +52,7 @@ sub set_counters { ], } }, - { label => 'total-completed-tasks', set => { + { label => 'total-completed-tasks', nlabel => 'thread.tasks.completed.count', set => { key_values => [ { name => 'CompletedTasks_Value', diff => 1 }, { name => 'display' } ], output_template => 'Total Completed Tasks : %s', perfdatas => [ @@ -61,7 +61,7 @@ sub set_counters { ], } }, - { label => 'total-blocked-tasks', set => { + { label => 'total-blocked-tasks', nlabel => 'thread.tasks.blocked.count', set => { key_values => [ { name => 'TotalBlockedTasks_Count', diff => 1 }, { name => 'display' } ], output_template => 'Total Blocked Tasks : %s', perfdatas => [ @@ -70,9 +70,9 @@ sub set_counters { ], } }, - { label => 'current-blocked-tasks', set => { + { label => 'current-blocked-tasks', nlabel => 'thread.tasks.blocked.current.count', set => { key_values => [ { name => 'CurrentlyBlockedTasks_Count', diff => 1 }, { name => 'display' } ], - output_template => 'Total Currently Blocked Tasks : %s', + output_template => 'Currently Blocked Tasks : %s', perfdatas => [ { label => 'current_blocked_tasks', value => 'CurrentlyBlockedTasks_Count_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, diff --git a/database/firebird/mode/longqueries.pm b/database/firebird/mode/longqueries.pm index 51eb4a615..ba6ffb85b 100644 --- a/database/firebird/mode/longqueries.pm +++ b/database/firebird/mode/longqueries.pm @@ -94,6 +94,7 @@ sub run { short_msg => sprintf("%s queries over %s seconds", $long_queries, $self->{option_results}->{seconds})); $self->{output}->perfdata_add(label => 'longqueries', + nlabel => 'longqueries.count', value => $long_queries, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), diff --git a/database/firebird/mode/memory.pm b/database/firebird/mode/memory.pm index b73388912..30fdfcd09 100644 --- a/database/firebird/mode/memory.pm +++ b/database/firebird/mode/memory.pm @@ -33,7 +33,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'used', set => { + { label => 'used', nlabel => 'database.usage.bytes', set => { key_values => [ { name => 'database_used' }, { name => 'database_allocated' } ], closure_custom_calc => $self->can('custom_unit_calc'), closure_custom_calc_extra_options => { label_ref => 'database' }, closure_custom_output => $self->can('custom_used_output'), @@ -41,7 +41,7 @@ sub set_counters { closure_custom_perfdata => $self->can('custom_used_perfdata'), } }, - { label => 'attachment', set => { + { label => 'attachment', nlabel => 'attachment.usage.bytes', set => { key_values => [ { name => 'attachment_used' }, { name => 'database_allocated' } ], closure_custom_calc => $self->can('custom_unit_calc'), closure_custom_calc_extra_options => { label_ref => 'attachment' }, closure_custom_output => $self->can('custom_unit_output'), @@ -49,7 +49,7 @@ sub set_counters { closure_custom_perfdata => $self->can('custom_unit_perfdata'), } }, - { label => 'transaction', set => { + { label => 'transaction', nlabel => 'transaction.usage.bytes', set => { key_values => [ { name => 'transaction_used' }, { name => 'database_allocated' } ], closure_custom_calc => $self->can('custom_unit_calc'), closure_custom_calc_extra_options => { label_ref => 'transaction' }, closure_custom_output => $self->can('custom_unit_output'), @@ -57,7 +57,7 @@ sub set_counters { closure_custom_perfdata => $self->can('custom_unit_perfdata'), } }, - { label => 'statement', set => { + { label => 'statement', nlabel => 'statement.usage.bytes', set => { key_values => [ { name => 'statement_used' }, { name => 'database_allocated' } ], closure_custom_calc => $self->can('custom_unit_calc'), closure_custom_calc_extra_options => { label_ref => 'statement' }, closure_custom_output => $self->can('custom_unit_output'), @@ -65,7 +65,7 @@ sub set_counters { closure_custom_perfdata => $self->can('custom_unit_perfdata'), } }, - { label => 'call', set => { + { label => 'call', nlabel => 'call.usage.bytes', set => { key_values => [ { name => 'call_used' }, { name => 'database_allocated' } ], closure_custom_calc => $self->can('custom_unit_calc'), closure_custom_calc_extra_options => { label_ref => 'call' }, closure_custom_output => $self->can('custom_unit_output'), @@ -93,21 +93,27 @@ sub custom_used_output { sub custom_used_perfdata { my ($self, %options) = @_; - $self->{output}->perfdata_add(label => 'used', unit => 'B', - value => $self->{result_values}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'used', unit => 'B', + nlabel => $self->{nlabel}, + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total} + ); } sub custom_unit_perfdata { my ($self, %options) = @_; - $self->{output}->perfdata_add(label => $self->{result_values}->{label}, unit => 'B', - value => $self->{result_values}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => $self->{result_values}->{label}, unit => 'B', + nlabel => $self->{nlabel}, + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total} + ); } sub custom_unit_output { @@ -147,9 +153,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => {}); return $self; } diff --git a/database/firebird/mode/pages.pm b/database/firebird/mode/pages.pm index f51d5b9bc..76724f6f1 100644 --- a/database/firebird/mode/pages.pm +++ b/database/firebird/mode/pages.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'reads', set => { + { label => 'reads', nlabel => 'pages.reads.persecond', set => { key_values => [ { name => 'reads', diff => 1 } ], per_second => 1, output_template => 'Reads : %.2f', @@ -44,7 +44,7 @@ sub set_counters { ], } }, - { label => 'writes', set => { + { label => 'writes', nlabel => 'pages.writes.persecond', set => { key_values => [ { name => 'writes', diff => 1 } ], per_second => 1, output_template => 'Writes : %.2f', @@ -54,7 +54,7 @@ sub set_counters { ], } }, - { label => 'fetches', set => { + { label => 'fetches', nlabel => 'pages.fetches.persecond', set => { key_values => [ { name => 'fetches', diff => 1 } ], per_second => 1, output_template => 'Fetches : %.2f', @@ -64,7 +64,7 @@ sub set_counters { ], } }, - { label => 'marks', set => { + { label => 'marks', nlabel => 'pages.marks.persecond', set => { key_values => [ { name => 'marks', diff => 1 } ], per_second => 1, output_template => 'Marks : %.2f', @@ -89,9 +89,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => {}); return $self; } diff --git a/database/firebird/mode/queries.pm b/database/firebird/mode/queries.pm index 2a4363f8f..a1523de21 100644 --- a/database/firebird/mode/queries.pm +++ b/database/firebird/mode/queries.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total', set => { + { label => 'total', nlabel => 'queries.total.persecond', set => { key_values => [ { name => 'total', diff => 1 } ], per_second => 1, output_template => 'Total : %d', @@ -44,7 +44,7 @@ sub set_counters { ], } }, - { label => 'seq-reads', set => { + { label => 'seq-reads', nlabel => 'queries.sequentialreads.persecond', set => { key_values => [ { name => 'seq_reads', diff => 1 } ], per_second => 1, output_template => 'Seq Reads : %d', @@ -54,7 +54,7 @@ sub set_counters { ], } }, - { label => 'inserts', set => { + { label => 'inserts', nlabel => 'queries.insert.persecond', set => { key_values => [ { name => 'inserts', diff => 1 } ], per_second => 1, output_template => 'Inserts : %d', @@ -64,7 +64,7 @@ sub set_counters { ], } }, - { label => 'updates', set => { + { label => 'updates', nlabel => 'queries.updates.persecond', set => { key_values => [ { name => 'updates', diff => 1 } ], per_second => 1, output_template => 'Updates : %d', @@ -74,7 +74,7 @@ sub set_counters { ], } }, - { label => 'deletes', set => { + { label => 'deletes', nlabel => 'queries.deletes.persecond', set => { key_values => [ { name => 'deletes', diff => 1 } ], per_second => 1, output_template => 'Deletes : %d', @@ -84,7 +84,7 @@ sub set_counters { ], } }, - { label => 'backouts', set => { + { label => 'backouts', nlabel => 'queries.backout.persecond', set => { key_values => [ { name => 'backouts', diff => 1 } ], per_second => 1, output_template => 'Backouts : %d', @@ -94,7 +94,7 @@ sub set_counters { ], } }, - { label => 'purges', set => { + { label => 'purges', nlabel => 'queries.purges.persecond', set => { key_values => [ { name => 'purges', diff => 1 } ], per_second => 1, output_template => 'Purges : %d', @@ -104,7 +104,7 @@ sub set_counters { ], } }, - { label => 'expunges', set => { + { label => 'expunges', nlabel => 'queries.expunges.persecond', set => { key_values => [ { name => 'expunges', diff => 1 } ], per_second => 1, output_template => 'Expunges : %d', @@ -129,9 +129,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => {}); return $self; } diff --git a/database/firebird/mode/users.pm b/database/firebird/mode/users.pm index 07028e362..4a4190e1d 100644 --- a/database/firebird/mode/users.pm +++ b/database/firebird/mode/users.pm @@ -76,6 +76,7 @@ sub run { $self->{output}->output_add(severity => $exit_code, short_msg => $msg); $self->{output}->perfdata_add(label => 'users', value => $result, + nlabel => 'users.count', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/database/sap/hana/mode/blockedtransactions.pm b/database/sap/hana/mode/blockedtransactions.pm index 2078834a3..9078ef59b 100644 --- a/database/sap/hana/mode/blockedtransactions.pm +++ b/database/sap/hana/mode/blockedtransactions.pm @@ -32,7 +32,7 @@ sub set_counters { { name => 'global', type => 0 }, ]; $self->{maps_counters}->{global} = [ - { label => 'blocked-transactions', set => { + { label => 'blocked-transactions', nlabel => 'transactions.blocked.count', set => { key_values => [ { name => 'total' } ], output_template => 'Current Total Blocked Transactions : %s', perfdatas => [ diff --git a/database/sap/hana/mode/connectedusers.pm b/database/sap/hana/mode/connectedusers.pm index 9a4a29427..a5061eb70 100644 --- a/database/sap/hana/mode/connectedusers.pm +++ b/database/sap/hana/mode/connectedusers.pm @@ -32,7 +32,7 @@ sub set_counters { { name => 'host', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All connected users are ok' }, ]; $self->{maps_counters}->{host} = [ - { label => 'users', set => { + { label => 'users', nlabel => 'users.count', set => { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'Connected Users : %s', perfdatas => [ diff --git a/database/sap/hana/mode/diskusage.pm b/database/sap/hana/mode/diskusage.pm index f90226b36..099211c03 100644 --- a/database/sap/hana/mode/diskusage.pm +++ b/database/sap/hana/mode/diskusage.pm @@ -33,7 +33,7 @@ sub set_counters { ]; $self->{maps_counters}->{disk} = [ - { label => 'usage', set => { + { label => 'usage', nlabel => 'disk.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'total' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), @@ -47,10 +47,10 @@ sub set_counters { sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = 'used_' . $self->{result_values}->{display}; + my ($label, $nlabel) = ('used', $self->{nlabel}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - $label = 'free_' . $self->{result_values}->{display}; + ($label, $nlabel) = ('free', 'disk.usage.free.bytes'); $value_perf = $self->{result_values}->{free}; } @@ -62,6 +62,7 @@ sub custom_usage_perfdata { $self->{output}->perfdata_add( label => $label, unit => 'B', + nlabel => $self->{nlabel}, instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $value_perf, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), diff --git a/database/sap/hana/mode/hostcpu.pm b/database/sap/hana/mode/hostcpu.pm index 7d10d925c..420af0800 100644 --- a/database/sap/hana/mode/hostcpu.pm +++ b/database/sap/hana/mode/hostcpu.pm @@ -33,7 +33,7 @@ sub set_counters { { name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All cpu usages are ok' }, ]; $self->{maps_counters}->{cpu} = [ - { label => 'user', set => { + { label => 'user', nlabel => 'host.cpu.user.utilization.percentage', set => { key_values => [ { name => 'total', diff => 1 }, { name => 'user', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'user' }, output_template => 'User %.2f %%', output_use => 'user_prct', threshold_use => 'user_prct', @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'sys', set => { + { label => 'sys', nlabel => 'host.cpu.system.utilization.percentage', set => { key_values => [ { name => 'total', diff => 1 }, { name => 'sys', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'sys' }, output_template => 'System %.2f %%', output_use => 'sys_prct', threshold_use => 'sys_prct', @@ -53,7 +53,7 @@ sub set_counters { ], } }, - { label => 'wait', set => { + { label => 'wait', nlabel => 'host.cpu.wait.utilization.percentage', set => { key_values => [ { name => 'total', diff => 1 }, { name => 'wait', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'wait' }, output_template => 'Wait %.2f %%', output_use => 'wait_prct', threshold_use => 'wait_prct', @@ -63,7 +63,7 @@ sub set_counters { ], } }, - { label => 'idle', set => { + { label => 'idle', nlabel => 'host.cpu.idle.utilization.percentage', set => { key_values => [ { name => 'total', diff => 1 }, { name => 'idle', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_data_calc'), closure_custom_calc_extra_options => { label_ref => 'idle' }, output_template => 'Idle %.2f %%', output_use => 'idle_prct', threshold_use => 'idle_prct', @@ -102,9 +102,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => {}); return $self; } diff --git a/database/sap/hana/mode/hostmemory.pm b/database/sap/hana/mode/hostmemory.pm index df427f627..d79ce2aff 100644 --- a/database/sap/hana/mode/hostmemory.pm +++ b/database/sap/hana/mode/hostmemory.pm @@ -29,7 +29,8 @@ sub custom_usage_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - label => $self->{result_values}->{label} . '_used', unit => 'B', + label => 'used', unit => 'B', + nlabel => $self->{nlabel}, instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $self->{result_values}->{used}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), @@ -80,7 +81,7 @@ sub set_counters { ]; $self->{maps_counters}->{memory} = [ - { label => 'physical-usage', set => { + { label => 'physical-usage', nlabel => 'host.memory.usage.bytes', set => { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'physical' }, closure_custom_output => $self->can('custom_usage_output'), @@ -90,7 +91,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{swap} = [ - { label => 'swap-usage', set => { + { label => 'swap-usage', nlabel => 'host.swap.usage.bytes', set => { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'swap' }, closure_custom_output => $self->can('custom_usage_output'), diff --git a/database/sap/hana/mode/volumeusage.pm b/database/sap/hana/mode/volumeusage.pm index 6c599deab..c463cb05d 100644 --- a/database/sap/hana/mode/volumeusage.pm +++ b/database/sap/hana/mode/volumeusage.pm @@ -33,7 +33,7 @@ sub set_counters { ]; $self->{maps_counters}->{volume} = [ - { label => 'usage', set => { + { label => 'usage', nlabel => 'volume.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'total' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), @@ -47,10 +47,10 @@ sub set_counters { sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = 'used_' . $self->{result_values}->{display}; + my ($label, $nlabel) = ('used', $self->{nlabel}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - $label = 'free_' . $self->{result_values}->{display}; + ($label, $nlabel) = ('free', 'volume.free.usage.bytes'); $value_perf = $self->{result_values}->{free}; } @@ -62,6 +62,7 @@ sub custom_usage_perfdata { $self->{output}->perfdata_add( label => $label, unit => 'B', + nlabel => $self->{nlabel}, instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => $value_perf, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), diff --git a/os/windows/snmp/mode/memory.pm b/os/windows/snmp/mode/memory.pm index 50bb4bfd6..3ee9449d6 100644 --- a/os/windows/snmp/mode/memory.pm +++ b/os/windows/snmp/mode/memory.pm @@ -28,10 +28,10 @@ use warnings; sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = 'used'; + my ($label, $nlabel) = ('used', $self->{nlabel}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - $label = 'free'; + ($label, $nlabel) = 'memory.free.bytes'; $value_perf = $self->{result_values}->{free}; } @@ -42,6 +42,7 @@ sub custom_usage_perfdata { } $self->{output}->perfdata_add(label => $label, + nlabel => $self->{nlabel}, value => $value_perf, unit => 'B', warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), @@ -92,7 +93,7 @@ sub set_counters { ]; $self->{maps_counters}->{memory} = [ - { label => 'memory', set => { + { label => 'memory', nlabel => 'memory.usage.bytes' set => { key_values => [ { name => 'used' }, { name => 'total' } ], closure_custom_calc => \&custom_usage_calc, closure_custom_output => \&custom_usage_output, diff --git a/os/windows/snmp/mode/swap.pm b/os/windows/snmp/mode/swap.pm index b713b606b..f074bf3fd 100644 --- a/os/windows/snmp/mode/swap.pm +++ b/os/windows/snmp/mode/swap.pm @@ -123,6 +123,7 @@ sub run { $swap_free_value . " " . $swap_free_unit, 100 - $prct_used)); $self->{output}->perfdata_add(label => "used", unit => 'B', + nlabel => 'swap.usage.bytes', value => $swap_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),