dsa-check-timedatectl: Work when the local timezone is not UTC
authorPeter Palfrader <peter@palfrader.org>
Mon, 23 Jan 2017 12:40:07 +0000 (13:40 +0100)
committerPeter Palfrader <peter@palfrader.org>
Mon, 23 Jan 2017 12:40:07 +0000 (13:40 +0100)
dsa-nagios-checks/checks/dsa-check-timedatectl

index 700d857..b3bc554 100755 (executable)
@@ -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))