fix(java/awa): agent mode - show agents having empty date in LastCheck (#3180)

This commit is contained in:
llange 2021-10-13 10:11:14 +02:00 committed by GitHub
parent d8809fc7f4
commit c68e99c224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 15 deletions

View File

@ -118,25 +118,31 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
next;
}
next if ($result->{$mbean}->{LastCheck} !~ /^\s*(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)/);
my $dt = DateTime->new(
year => $1,
month => $2,
day => $3,
hour => $4,
minute => $5,
second => $6,
%$tz
);
$self->{agent}->{$display} = {
my $agent_infos = {
display => $display,
ipaddress => $result->{$mbean}->{IpAddress},
active => $result->{$mbean}->{Active} ? 'yes' : 'no',
since => time() - $dt->epoch,
};
if ($result->{$mbean}->{LastCheck} =~ /^\s*(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)/) {
my $dt = DateTime->new(
year => $1,
month => $2,
day => $3,
hour => $4,
minute => $5,
second => $6,
%$tz
);
$agent_infos->{since} = time() - $dt->epoch;
} elsif ($result->{$mbean}->{LastCheck} =~ /^\s*00:00:00/) {
$agent_infos->{since} = 0;
} else {
next;
}
$self->{agent}->{$display} = $agent_infos;
}
if (scalar(keys %{$self->{agent}}) <= 0) {