alix_voyage_linux_ntp
This is an old revision of the document!
Table of Contents
~~TOC~~
PC Engines Alix 1E - Hopf NTP Server
Create device symlinks
Hopf
cd /etc/udev/rules.d/ cat hopf.rules KERNEL=="ttyS0", SYMLINK+="hopfclock0" KERNEL=="ttyS0", RUN+="/bin/setserial -v /dev/%k low_latency" KERNEL=="rtc", OWNER="root", GROUP="tty", MODE="0664"
GPS / PPS
cat pps.rules KERNEL=="ttyS0", SYMLINK+="gps0" KERNEL=="ttyS0", RUN+="/bin/setserial -v /dev/%k low_latency" KERNEL=="ttyS0", RUN+="/usr/sbin/ldattach pps /dev/%k" KERNEL=="pps0", OWNER="root", GROUP="tty", MODE="0660", SYMLINK+="gpspps0" KERNEL=="rtc", OWNER="root", GROUP="tty", MODE="0664"
Compile NTP
(apt-get remove ntp) cd /root apt-get install dpkg-dev dialog devscripts fakeroot pps-tools apt-get source ntp && apt-get build-dep ntp cd ntp<directory> debuild -us -uc dpkg --install ntp....deb
Configuration
- Allow write to drift file, edit /etc/default/voyage-util.
VOYAGE_SYNC_DIRS="var/lib/ntp"
- Set hwclock, edit /etc/default/hwclock.
HCTOSYS_DEVICE=rtc
- Load module rtc.
#vi /etc/modules rtc
- Configure locale.
apt-get install locales dpkg-reconfigure locales
- Run the ntpd at the highest priority.
vi /etc/default/ntp NTPD_OPTS='-g -N'
Hopf DCF /etc/ntp.conf
#Stratum level when no ref source available tos orphan 12 # Hopf DCF clock server 127.127.8.0 mode 12 minpoll 4 maxpoll 4 fudge 127.127.8.0 time1 0.001200 # calibration fudge 127.127.8.0 flag1 1 # Time2 = Trust time fudge 127.127.8.0 time2 3600 # Trust time leapfile /etc/leap_second restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery restrict 127.0.0.1 restrict ::1 statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable driftfile /var/lib/ntp/ntp.drift
Nagios Hopf 7001 check
#!/bin/bash # # Tested with Hopf 7001 DCF Base station with 7245 serial interface boards # Datastring 7001/6021 # # Ben Stienstra, 2013/05 ntpq="/usr/bin/ntpq" # get timecode variable, received from the clock eval `$ntpq -c 'cv 0 timecode'` function quit { case "$2" in 0) echo "OK: $1" exit 0 ;; 1) echo "Warning: $1" exit 1 ;; 2) echo "Critical: $1" exit 2 ;; 3) echo "Unknown: $1" exit 3 ;; esac } function clockstat { # Status nibble from hex hex0=0000 hex1=0001 hex2=0010 hex3=0011 hex4=0100 hex5=0101 hex6=0110 hex7=0111 hex8=1000 hex9=1001 hexA=1010 hexB=1011 hexC=1100 hexD=1101 hexE=1110 hexF=1111 eval statnibble='hex$1' snibble=${!statnibble} case ${snibble:0:2} in 00) textstatus="time/date invalid" exitcode=2 ;; 01) textstatus="crystal operation" exitcode=1 ;; 10) textstatus="radio operation" exitcode=0 ;; 11) textstatus="radio operation (high accuracy)" exitcode=0 ;; esac case ${snibble:2:1} in 0) dss="standard time" ;; 1) dss="daylight saving time" ;; esac case ${snibble:3:1} in 0) ann="no announcement hour" ;; 1) ann="announcement (ds-st-ds)" ;; esac quit "status hex=\"$1\", bin=\"$snibble\": $textstatus, $dss, $ann" $exitcode } # check for complete string, for example: \x028D194223310513\x0a\x0d\x03 # This is from the Hopf 7245 serial interface board # # x20 = Space # x0D = CR (carriage return) # x0A = LF (line feed) # x02 = STX (start of text) # x03 = ETX (end of text) # if [[ $timecode == \\x02*\\x0a\\x0d\\x03 ]]; then clockstat ${timecode:4:1} else quit "Timecode not complete" 3 # return Unkown status fi
Handy ntp commands
- Show peer status:
ntpq -p
- Show timecode from receiver:
ntpq -c 'cv 0 timecode'
- Show client list (max. 600):
ntpdc -n -c monlist ## ntp 2.4.7 removed monlist in favour of ntpq's mrulist ntpq -c "mrulist"
alix_voyage_linux_ntp.1433159926.txt.gz ยท Last modified: 2015/06/01 11:58 by admin