Adapt timedatectl check for buster
authorMoritz Muehlenhoff <jmm@debian.org>
Wed, 13 Feb 2019 16:14:29 +0000 (17:14 +0100)
committerPeter Palfrader <peter@palfrader.org>
Mon, 18 Feb 2019 13:40:34 +0000 (14:40 +0100)
In the systemd version in buster, the output format of timedatectl changed:
- "Network time on: yes" became "NTP service: active"
- "NTP synchronized: yes" became "System clock synchronized: yes"

Signed-off-by: Peter Palfrader <peter@palfrader.org>
dsa-nagios-checks/checks/dsa-check-timedatectl

index 1c61cf3..4bb6247 100755 (executable)
@@ -64,8 +64,8 @@ trap "rm -f '$temp'" EXIT
 LC_ALL=C timedatectl > "$temp"
 ut=$(sed '/Universal time:/ { s/^[^:]*: *//; p}; d' "$temp")
 rtc=$(sed '/RTC time:/ { s/^[^:]*: *//; p}; d' "$temp")
-ntpenabled=$(sed '/\(NTP enabled\|Network time on\):/ { s/^[^:]*: *//; p}; d' "$temp")
-ntpsynced=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' "$temp")
+ntpenabled=$(sed '/\(NTP enabled\|Network time on\|NTP service\):/ { s/^[^:]*: *//; p}; d' "$temp")
+ntpsynced=$(sed '/\(NTP synchronized\|System clock synchronized\):/ { s/^[^:]*: *//; p}; d' "$temp")
 
 uts=$(TZ=UTC date -d "$ut" +%s)
 rtcs=$(TZ=UTC date -d "$rtc" +%s 2>/dev/null || echo "N/A")
@@ -90,7 +90,7 @@ else
                exit 1
        fi
 
-       if [ "$ntpenabled" != "yes" ]; then
+       if [ "$ntpenabled" != "yes" -a "$ntpenabled" != "active"  ]; then
                echo "Warning: NTP not enabled!"
                exit 1
        fi