From: Peter Palfrader Date: Mon, 23 Jan 2017 12:40:07 +0000 (+0100) Subject: dsa-check-timedatectl: Work when the local timezone is not UTC X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-nagios.git;a=commitdiff_plain;h=c5cd42b42dc70334f6065771fb43aa486f189394 dsa-check-timedatectl: Work when the local timezone is not UTC --- diff --git a/dsa-nagios-checks/checks/dsa-check-timedatectl b/dsa-nagios-checks/checks/dsa-check-timedatectl index 700d857..b3bc554 100755 --- a/dsa-nagios-checks/checks/dsa-check-timedatectl +++ b/dsa-nagios-checks/checks/dsa-check-timedatectl @@ -34,8 +34,8 @@ timedatectl > "$temp" ut=$(sed '/Universal time:/ { s/^[^:]*: *//; p}; d' "$temp") rtc=$(sed '/RTC time:/ { s/^[^:]*: *//; p}; d' "$temp") -uts=$(date -d "$ut" +%s) -rtcs=$(date -d "$rtc" +%s) +uts=$(TZ=UTC date -d "$ut" +%s) +rtcs=$(TZ=UTC date -d "$rtc" +%s) d=$((uts - rtcs))