X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-timedatectl;fp=dsa-nagios-checks%2Fchecks%2Fdsa-check-timedatectl;h=700d857881e4ded29d43fc910205bbdcdc0640cf;hb=5d26f2556230c5ea797b1598bc6ade9cd4e5eac8;hp=88c1771809cb51ccfda3401125eb332062dfe559;hpb=d8fef204d9e3099a9b04e77fb430c6b88f4c2e1c;p=mirror%2Fdsa-nagios.git 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