X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-timedatectl;h=3711fc149ee34af25c5411eea1271ef4614ebbcb;hb=cea5e8bf3275a6077d24d146b0aa4fb729af0538;hp=4294ed87a6fc4ddd6bb549fa64aaf9d69f474dfe;hpb=d4369abd75ff02178c07fb9ce706791bfc95fa91;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-timedatectl b/dsa-nagios-checks/checks/dsa-check-timedatectl index 4294ed8..3711fc1 100755 --- a/dsa-nagios-checks/checks/dsa-check-timedatectl +++ b/dsa-nagios-checks/checks/dsa-check-timedatectl @@ -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"