dsa-check-timedatectl: handle n/a in timedatectl output for RTC.
authorPeter Palfrader <peter@palfrader.org>
Mon, 23 Jan 2017 13:14:37 +0000 (14:14 +0100)
committerPeter Palfrader <peter@palfrader.org>
Mon, 23 Jan 2017 13:14:37 +0000 (14:14 +0100)
dsa-nagios-checks/checks/dsa-check-timedatectl
dsa-nagios-checks/debian/changelog

index 4294ed8..3711fc1 100755 (executable)
@@ -68,8 +68,10 @@ ntpenabled=$(sed '/\(NTP enabled\|Network time on\):/ { s/^[^:]*: *//; p}; d' "$
 ntpsynced=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' "$temp")
 
 uts=$(TZ=UTC date -d "$ut" +%s)
-rtcs=$(TZ=UTC date -d "$rtc" +%s)
-delta=$((uts - rtcs))
+rtcs=$(TZ=UTC date -d "$rtc" +%s 2>/dev/null || echo "N/A")
+if [ "$rtcs" != "N/A" ]; then
+       delta=$((uts - rtcs))
+fi
 
 if [ "$SYNSTATUSONLY" -ge 1 ]; then
        if [ "$ntpsynced" != "yes" ]; then
@@ -77,6 +79,11 @@ if [ "$SYNSTATUSONLY" -ge 1 ]; then
                exit 1
        fi
 else
+       if [ "$rtcs" = "N/A" ]; then
+               echo "Warning: Cannot parse RTC $rtc."
+               exit 1
+       fi
+
        if [ "$delta" -lt "-$MAX" ] ||
           [ "$delta" -gt "$MAX" ]; then
                echo "Warning: time desync $delta: RTC vs. system time: $rtc vs. $ut"
index c2bbbb5..ce5abd2 100644 (file)
@@ -1,3 +1,9 @@
+dsa-nagios-checks (110) UNRELEASED; urgency=medium
+
+  * dsa-check-timedatectl: handle n/a in timedatectl output for RTC.
+
+ -- Peter Palfrader <weasel@debian.org>  Mon, 23 Jan 2017 14:14:06 +0100
+
 dsa-nagios-checks (109) unstable; urgency=medium
 
   [ Peter PalfraderĀ ]