enh(netbackup): metrics v2 (#3271)

This commit is contained in:
itoussies 2021-11-22 18:33:38 +01:00 committed by GitHub
parent 55f4dacc8c
commit fb483ebe69
5 changed files with 29 additions and 26 deletions

View File

@ -63,9 +63,9 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'usage', set => {
{ label => 'usage', nlabel => 'disk_pool.deduplication.usage.percentage', set => {
key_values => [ { name => 'usage' }, { name => 'watermark' }, { name => 'display' } ],
output_template => 'Use: %s %%',
output_template => 'use: %s %%',
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
perfdatas => [
{ label => 'used', template => '%s',

View File

@ -33,7 +33,7 @@ sub set_counters {
];
$self->{maps_counters}->{drive} = [
{ label => 'cleaning', set => {
{ label => 'cleaning', nlabel => 'drives.unclean.count', set => {
key_values => [ { name => 'num_cleaning' }, { name => 'total' } ],
output_template => '%d drives needs a reset mount time',
perfdatas => [

View File

@ -88,6 +88,24 @@ sub custom_frozen_calc {
return 0;
}
sub policy_long_output {
my ($self, %options) = @_;
return "Checking policy '" . $options{instance_value}->{display} . "'";
}
sub prefix_policy_output {
my ($self, %options) = @_;
return "Policy '" . $options{instance_value}->{display} . "' ";
}
sub prefix_job_output {
my ($self, %options) = @_;
return "Job '" . $options{instance_value}->{display} . "' [Type: " . $options{instance_value}->{type} . "] [State: " . $options{instance_value}->{state} . "] " ;
}
sub set_counters {
my ($self, %options) = @_;
@ -100,9 +118,9 @@ sub set_counters {
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
{ label => 'total', nlabel = 'jobs.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total Jobs : %s',
output_template => 'total jobs : %s',
perfdatas => [
{ label => 'total', value => 'total', template => '%s', min => 0 }
]
@ -172,24 +190,6 @@ sub check_options {
$self->change_macros(macros => ['ok_status', 'warning_status', 'critical_status']);
}
sub policy_long_output {
my ($self, %options) = @_;
return "Checking policy '" . $options{instance_value}->{display} . "'";
}
sub prefix_policy_output {
my ($self, %options) = @_;
return "Policy '" . $options{instance_value}->{display} . "' ";
}
sub prefix_job_output {
my ($self, %options) = @_;
return "Job '" . $options{instance_value}->{display} . "' [Type: " . $options{instance_value}->{type} . "] [State: " . $options{instance_value}->{state} . "] " ;
}
my %job_type = (
0 => 'backup', 1 => 'archive', 2 => 'restore', 3 => 'verify', 4 => 'duplicate', 5 => 'phase 1 or phase 2 import',
6 => 'catalog backup', 7 => 'vault duplicate', 8 => 'label tape', 9 => 'erase tape',

View File

@ -29,9 +29,11 @@ sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used';
my $nlabel = $self->{option_results}->{units} eq '%' ? 'tape.usage.percentage' : 'tape.usage.bytes';
my $value_perf = $self->{result_values}->{used};
if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free';
$nlabel = $self->{option_results}->{units} eq '%' ? 'tape.free.usage.percentage' : 'tape.free.usage.bytes';
$value_perf = $self->{result_values}->{free};
}
@ -43,6 +45,7 @@ sub custom_usage_perfdata {
$self->{output}->perfdata_add(
label => $label,
nlabel => $nlabel,
value => $value_perf,
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),
@ -68,7 +71,7 @@ sub custom_usage_output {
my ($self, %options) = @_;
return sprintf(
"Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
"total: %s used: %s (%.2f%%) free: %s (%.2f%%)",
$self->{result_values}->{total},
$self->{result_values}->{used}, $self->{result_values}->{prct_used},
$self->{result_values}->{free}, $self->{result_values}->{prct_free}

View File

@ -30,14 +30,14 @@ sub new {
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
$self->{modes} = {
'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus',
'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning',
'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus',
'job-status' => 'apps::backup::netbackup::local::mode::jobstatus',
'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies',
'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage'
);
};
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';