From 221a0afe5deee6c2a3f62d06a5d6859fbb02b1ee Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 21 Mar 2022 11:29:41 +0100 Subject: [PATCH] last_seen might not be defined in check_unifi --- zabbix_scripts/check_unifi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zabbix_scripts/check_unifi b/zabbix_scripts/check_unifi index ed6c4f0..a049b7b 100755 --- a/zabbix_scripts/check_unifi +++ b/zabbix_scripts/check_unifi @@ -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){