chiark / gitweb /
check, rcheck: Propagate exit status better; capture lines more precisely.
[rcheck] / check.d / ntp
CommitLineData
3e7a8d27
MW
1#! /bin/sh -e
2
042f27fe
MW
3if [ ! -x /usr/sbin/ntpc ]; then exit 0; fi
4
3e7a8d27
MW
5ntpdc -c peers | {
6 any=nil
7 while read remote local st poll reach delay offset disp; do
8 case "$remote" in
9 \**) ;;
10 *) continue ;;
11 esac
12 awk -v off="$offset" 'BEGIN {
13 if (off < 0) off = -off;
14 if (off >= 0.1) printf "W: absolute time offset %gs worrying\n", off;
15 else if (off >= 0.01) printf "I: absolute time offset %gs concerning\n", off;
16 }'
17 any=t
18 done
19 case $any in
20 nil) echo "W: not sychronized to any peer" ;;
21 esac
22}