Looking for a script to (1) check status of ntp and (2) if it is within +/- 1 second of a given time server (eg 123.456.789.10). (3) In addition, system time should be checked to see if the timezone is set correctly (eg PST)
Here's what I have so far, checking the status of ntp:
#!/bin/bash
if [[ ! -x /usr/bin/ntpstat ]]
then
echo "ntpstat is NOT installed: please install it"
exit 3
res=$(/usr/bin/ntpstat)
rc=$?
case $rc in
0 )
echo "clocks are synchronized"
;;
1 )
echo "WARNING: clocks are NOT synchronized"
;;
2 )
echo "CRITICAL: NTPD IS DOWN -- NO STATUS"
;;
esac