fix(plugin): cadvisor undefined array when no stats available (#2866)

This commit is contained in:
Simon Bomm 2021-06-15 08:31:15 +02:00 committed by GitHub
parent 43efe5f014
commit e82f1d0bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 28 deletions

View File

@ -112,7 +112,7 @@ sub manage_selection {
my $read_io = {};
my $write_io = {};
if (keys $first_stat->{diskio}) {
$self->{containers}->{$container_id} = {
node_name => $result->{$container_id}->{NodeName},
display => defined($self->{option_results}->{use_name}) ? $name : $container_id,
@ -141,9 +141,10 @@ sub manage_selection {
};
}
}
}
if (scalar(keys %{$self->{containers}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No containers found.");
$self->{output}->add_option_msg(short_msg => "No containers found or no data available for diskio metrics.");
$self->{output}->option_exit();
}