health status compat connector 3.3.0

This commit is contained in:
garnier-quentin 2019-02-06 14:15:50 +01:00
parent 7cfa80302b
commit ea78f2178a
1 changed files with 15 additions and 13 deletions

View File

@ -211,20 +211,22 @@ sub manage_selection {
my $i = 0; my $i = 0;
foreach (('memory_info', 'cpu_info', 'sensor_info', 'storage_info')) { foreach (('memory_info', 'cpu_info', 'sensor_info', 'storage_info')) {
if (defined($response->{data}->{$host_id}->{$_})) { if (defined($response->{data}->{$host_id}->{$_})) {
$self->{host}->{$host_name}->{global_problems}->{ok} += $response->{data}->{$host_id}->{$_}->{ok}; foreach my $entry (@{$response->{data}->{$host_id}->{$_}}) {
$self->{host}->{$host_name}->{global_problems}->{red} += $response->{data}->{$host_id}->{$_}->{red}; my $status = 'ok';
$self->{host}->{$host_name}->{global_problems}->{yellow} += $response->{data}->{$host_id}->{$_}->{yellow}; $status = lc($1) if ($entry->{status} =~ /(yellow|red)/i);
$self->{host}->{$host_name}->{global_problems}->{total_problems} += $self->{host}->{$host_name}->{global_problems}->{$status}++;
$self->{host}->{$host_name}->{global_problems}->{red} + $self->{host}->{$host_name}->{global_problems}->{yellow}; $self->{host}->{$host_name}->{global_problems}->{total}++;
$self->{host}->{$host_name}->{global_problems}->{total} += if ($status eq 'ok') {
$response->{data}->{$host_id}->{$_}->{ok} + $response->{data}->{$host_id}->{$_}->{red} + $response->{data}->{$host_id}->{$_}->{yellow}; $self->{host}->{$host_name}->{global_problems}->{total_problems}++
foreach (@{$response->{data}->{$host_id}->{$_}->{summary_yellow}}, @{$response->{data}->{$host_id}->{$_}->{summary_red}}) { } else {
$self->{host}->{$host_name}->{global_summary}->{$i} = { $self->{host}->{$host_name}->{global_summary}->{$i} = {
type => defined($_->{type}) ? $_->{type} : '', type => defined($entry->{type}) ? $entry->{type} : '',
name => $_->{name}, name => $entry->{name},
summary => $_->{summary}, summary => $entry->{summary},
}; };
}
} }
$i++; $i++;
} }
} }