Ben Stienstra

Linux, Unix, network, radio and more...

User Tools

Site Tools


alix_voyage_linux_ntp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
alix_voyage_linux_ntp [2015/06/01 13:58]
admin [Compile NTP]
— (current)
Line 1: Line 1:
-{{tag>[hardware alix ntp]}} 
-~~TOC~~ 
  
-=====PC Engines Alix 1E - Hopf NTP Server===== 
- 
-====Create device symlinks==== 
-===Hopf=== 
-<code> 
-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" 
-</code> 
- 
-===GPS / PPS=== 
-<code> 
-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" 
-</code> 
- 
-====Compile NTP==== 
-<code> 
-(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 
-</code>   
- 
-====Configuration==== 
-  * Allow write to drift file, edit **/etc/default/voyage-util**. <code>VOYAGE_SYNC_DIRS="var/lib/ntp"</code> 
-  * Set hwclock, edit **/etc/default/hwclock**. <code>HCTOSYS_DEVICE=rtc</code> 
-  * Load module rtc. <code>#vi /etc/modules 
-rtc</code> 
-  * Configure locale. <code>apt-get install locales 
-dpkg-reconfigure locales</code> 
-  * Run the ntpd at the highest priority. <code>vi /etc/default/ntp 
- 
-NTPD_OPTS='-g -N'</code> 
- 
-====Hopf DCF /etc/ntp.conf==== 
-<code>#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</code> 
- 
-====Nagios Hopf 7001 check==== 
-<code>#!/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</code> 
-====Handy ntp commands==== 
-  * Show peer status: <code>ntpq -p</code> 
-  * Show timecode from receiver: <code>ntpq -c 'cv 0 timecode'</code> 
-  * Show client list (max. 600): <code>ntpdc -n -c monlist 
- 
-## ntp 2.4.7 removed monlist in favour of ntpq's mrulist 
-ntpq -c "mrulist"</code> 
alix_voyage_linux_ntp.1433159926.txt.gz ยท Last modified: 2015/06/01 13:58 by admin