Script Archive: GPS Check

!/bin/sh
 Build Header
 /bin/echo "" > /var/log/gps.log
 /bin/echo "Node: "/bin/hostname -f >> /var/log/gps.log
 /bin/echo "OS:   "/bin/uname -sr >> /var/log/gps.log
 /bin/echo "Date: "/bin/date >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 /bin/ls -l /var/log/ntpstats/clockstats >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 /bin/echo "Checking for GPS errors …" >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 myGPSV=/usr/bin/grep ",V," /var/log/ntpstats/clockstats | /usr/bin/wc -l
 echo $myGPSV >> /var/log/gps.log
 /bin/echo "Found $myGPSV errors in the current clockstats file." >> /var/log/gps.log
 echo "" >> /var/log/gps.log
 /usr/bin/ntpq -p | /usr/bin/grep "*" >> /var/log/gps.log
 myGPSOK=/usr/local/bin/ntpq -p | /bin/grep -c "^MyBadConditionTest"
 myGPSOK=/usr/local/bin/ntpq -p | /bin/grep -c "^oGPS_NMEA"
 if [ "$myGPSOK" -ne "1" ]; then
 /bin/echo "!!! GPS CLOCK FAILURE !!!" >> /var/log/gps.log
 echo "" >> /var/log/gps.log
 /usr/local/bin/ntpq -p >> /var/log/gps.log
 /bin/cat /var/log/gps.log | /usr/bin/mailx -s "!!! GPS FAILURE !!! on hostname" root
 fi