last_seen might not be defined in check_unifi

This commit is contained in:
Daniel Berteaud 2022-03-21 11:29:41 +01:00
parent e0be2c506f
commit 221a0afe5d
1 changed files with 2 additions and 2 deletions

View File

@ -136,7 +136,7 @@ if ($unifi){
$json->{$_} = $obj->{$_} if (defined $obj->{$_});
}
# Convert last seen into a relative time
$json->{last_seen} = time - $obj->{last_seen};
$json->{last_seen} = (defined $obj->{last_seen}) ? time - $obj->{last_seen} : time;
# Add some more info in sys_stats
$json->{sys_stats}->{$_} = $obj->{'system-stats'}->{$_} foreach (qw/cpu mem uptime/);
@ -199,7 +199,7 @@ if ($unifi){
$json->{$_} = $obj->{$_} || 0;
}
# Convert last_seen to relative
$json->{last_seen} = time - $json->{last_seen};
$json->{last_seen} = (defined $obj->{last_seen}) ? time - $obj->{last_seen} : time;
# For wireless stations, we gather some more info
if ($obj->{is_wired} == JSON::false){