From: Peter Palfrader Date: Fri, 9 Dec 2016 10:31:26 +0000 (+0100) Subject: also check if NTP is enabled X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-nagios.git;a=commitdiff_plain;h=5d26f2556230c5ea797b1598bc6ade9cd4e5eac8 also check if NTP is enabled --- diff --git a/dsa-nagios-checks/checks/dsa-check-timedatectl b/dsa-nagios-checks/checks/dsa-check-timedatectl index 88c1771..700d857 100755 --- a/dsa-nagios-checks/checks/dsa-check-timedatectl +++ b/dsa-nagios-checks/checks/dsa-check-timedatectl @@ -31,8 +31,8 @@ temp="$(mktemp)" trap "rm -f '$temp'" EXIT timedatectl > "$temp" -ut=$(sed '/Universal time:/ { s/^[^:]*: *//; p}; d' t) -rtc=$(sed '/RTC time:/ { s/^[^:]*: *//; p}; d' t) +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) @@ -46,8 +46,14 @@ if [ "$d" -lt "-$MAX" ] || fi -sced=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' t) -if [ "$sced" != "yes" ]; then +bool=$(sed '/NTP enabled:/ { s/^[^:]*: *//; p}; d' "$temp") +if [ "$bool" != "yes" ]; then + echo "Warning: NTP not enabled!" + exit 1 +fi + +bool=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' "$temp") +if [ "$bool" != "yes" ]; then echo "Warning: not synced with NTP (but clock is OK for now)." exit 1 fi