+ refactoring metrics step 2 (#1489)
* + refactoring metrics step 2 * s/newlabel/nlabel/
This commit is contained in:
parent
7c123811d0
commit
535eacc4b8
|
@ -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 => [
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 => [
|
||||
|
|
|
@ -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' },
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 => [
|
||||
|
|
|
@ -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 => [
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue