move kubernetes perfdata

This commit is contained in:
Colin Gagnaire 2019-06-07 17:59:52 +02:00
parent 6ccfd0104e
commit cb99fa1a2f
4 changed files with 92 additions and 53 deletions

View File

@ -29,23 +29,42 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
$self->{output}->perfdata_add(label => 'desired' . $extra_label,
value => $self->{result_values}->{desired});
$self->{output}->perfdata_add(label => 'current' . $extra_label,
value => $self->{result_values}->{current});
$self->{output}->perfdata_add(label => 'available' . $extra_label,
value => $self->{result_values}->{available});
$self->{output}->perfdata_add(label => 'up_to_date' . $extra_label,
value => $self->{result_values}->{up_to_date});
$self->{output}->perfdata_add(label => 'ready' . $extra_label,
value => $self->{result_values}->{ready});
$self->{output}->perfdata_add(label => 'misscheduled' . $extra_label,
value => $self->{result_values}->{misscheduled});
$self->{output}->perfdata_add(
label => 'desired',
nlabel => 'daemonset.pods.desired.count',
value => $self->{result_values}->{desired},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'current',
nlabel => 'daemonset.pods.current.count',
value => $self->{result_values}->{current},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'available',
nlabel => 'daemonset.pods.available.count',
value => $self->{result_values}->{available},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'up_to_date',
nlabel => 'daemonset.pods.uptodate.count',
value => $self->{result_values}->{up_to_date},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'ready',
nlabel => 'daemonset.pods.ready.count',
value => $self->{result_values}->{ready},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'misscheduled',
nlabel => 'daemonset.pods.misscheduled.count',
value => $self->{result_values}->{misscheduled},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
}
sub custom_status_output {

View File

@ -29,21 +29,36 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
$self->{output}->perfdata_add(label => 'desired' . $extra_label,
value => $self->{result_values}->{desired});
$self->{output}->perfdata_add(label => 'current' . $extra_label,
value => $self->{result_values}->{current});
$self->{output}->perfdata_add(label => 'available' . $extra_label,
value => $self->{result_values}->{available});
$self->{output}->perfdata_add(label => 'ready' . $extra_label,
value => $self->{result_values}->{ready});
$self->{output}->perfdata_add(label => 'up_to_date' . $extra_label,
value => $self->{result_values}->{up_to_date});
$self->{output}->perfdata_add(
label => 'desired',
nlabel => 'deployment.replicas.desired.count',
value => $self->{result_values}->{desired},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'current',
nlabel => 'deployment.replicas.current.count',
value => $self->{result_values}->{current},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'available',
nlabel => 'deployment.replicas.available.count',
value => $self->{result_values}->{available},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'ready',
nlabel => 'deployment.replicas.ready.count',
value => $self->{result_values}->{ready},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
$self->{output}->perfdata_add(
label => 'up_to_date',
nlabel => 'deployment.replicas.uptodate.count',
value => $self->{result_values}->{up_to_date},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
}
sub custom_status_output {

View File

@ -31,8 +31,7 @@ sub custom_usage_perfdata {
my $label = 'allocated_pods';
my $value_perf = $self->{result_values}->{allocated};
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{allocatable};
@ -40,11 +39,13 @@ sub custom_usage_perfdata {
}
$self->{output}->perfdata_add(
label => $label . $extra_label,
label => $label,
nlabel => 'pods.allocated.count',
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),
min => 0, max => $self->{result_values}->{allocatable}
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $self->{result_values}->{allocatable},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
}
@ -57,8 +58,8 @@ sub custom_usage_threshold {
$threshold_value = $self->{result_values}->{prct_allocated};
}
$exit = $self->{perfdata}->threshold_check(
value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]
value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]
);
return $exit;
}
@ -120,8 +121,8 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' },
"filter-name:s" => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' },
});
return $self;

View File

@ -64,19 +64,21 @@ sub custom_ready_perfdata {
my ($self, %options) = @_;
my $value_perf = $self->{result_values}->{ready};
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($self->{result_values}->{total} > 0 && $self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(label => 'containers_ready' . $extra_label,
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),
min => 0, max => $total_options{total});
$self->{output}->perfdata_add(
label => 'containers_ready',
nlabel => 'containers.ready.count',
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $total_options{total},
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
);
}
sub custom_ready_threshold {
@ -87,8 +89,10 @@ sub custom_ready_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_ready};
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
$exit = $self->{perfdata}->threshold_check(
value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]
);
return $exit;
}
@ -147,7 +151,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'total-restarts-count', set => {
{ label => 'total-restarts-count', nlabel => 'restarts.total.count', set => {
key_values => [ { name => 'restarts_total' }, { name => 'display' } ],
output_template => 'Restarts: %d',
perfdatas => [
@ -166,7 +170,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'restarts-count', set => {
{ label => 'restarts-count', nlabel => 'containers.restarts.count', set => {
key_values => [ { name => 'restarts' }, { name => 'perf' } ],
output_template => 'Restarts: %d',
perfdatas => [