ntpd interview questions
Top ntpd frequently asked interview questions
I have raspberry pi with raspbian. I would like to execute a script right after time gets synced with ntpd, my script needs correct datetime. How can i do that?
Source: (StackOverflow)
I have an application that depends on gpsd and ntpd to accurately set the system time on a linux machine.
gpsd is fed NMEA + PPS
The application is punping ~25MB per second over the network and I think the loading on the system is causing jitter in the time somehow. (loaded PCI express bus causing irregular interrupt latency)
I have another machine that is not loaded at all that I could setup to read the GPS and act as an NTP server for the loaded machine. (the loaded machine would be getting startum 1 ???)
How accurate can I expect the time to be from a stratum 0 NTP server on the same subnet on Ethernet?
I hope this is not too off topic, I am sure sometime someone else will be happy the answer is documented here. ;-)
Source: (StackOverflow)
I've just hooked up an old VP Oncore to a Raspberry PI (using a PPS kernel) and have the following...
root@ntpi:/var/log# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*GPS_ONCORE(0) .GPS. 0 l 6 16 377 0.000 0.004 0.003
+ptbtime1.ptb.de .PTB. 1 u 40 64 377 32.704 -0.295 0.585
-smn.pecs.hpc.ni 185.219.2.214 2 u 35 64 377 47.220 0.136 0.267
-pool.ntp.connec 192.36.144.22 2 u 43 64 377 74.129 -0.308 3.224
+stratum2-2.NTP. 129.70.130.70 2 u 25 64 377 31.977 0.078 2.104
-service0-eth4.d 193.171.23.163 2 u 30 64 377 48.827 -0.899 0.780
root@ntpi:/var/log#
Is this correct? i.e. would I expect the terminal state to be "*" i.e. System rather than "o" PPS?
Thanks in advance
Nivag
Source: (StackOverflow)
When i execute timeout ntpd -gq on ntp client machine, i got exit code 124.
I executed using strace also
strace timeout 30 ntpd -gq
it is getting stucked at below point.
only few lines:-
ioctl(4, SIOCGIFNETMASK, {ifr_name="eth0", ifr_netmask={AF_INET, inet_addr("255.255.255.0")}}) = 0 close(4) = 0 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4 connect(4, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("xxxxxxxxserver_ip")}, 16) = 0 getsockname(4, {sa_family=AF_INET, sin_port=htons(39382), sin_addr=inet_addr("xxxxxxxxclient_ip")}, [16]) = 0
From install logs
i got :-
ntpd exiting on signal 15 ntpd exiting on signal 2
both on server and client.
On server
netstat -tulpn | grep ntp
udp 0 0 :::123 :::* 8441/ntpd
ntp ntpd
Source: (StackOverflow)
I've received these 3 boards as a gift.
STM32F407 HIGH PERF DISCOVERY BOARD
http://www2.mouser.com/Search/ProductDetail.aspx?R=STM32F4DISCOVERYvirtualkey51120000virtualkey511-STM32F4DISCOVERY
STMicroelectronics STM32F411 Nucleo board
http://www2.mouser.com/Search/ProductDetail.aspx?R=NUCLEO-F411REvirtualkey51120000virtualkey511-NUCLEO-F411RE
STM32F429 Discovery Kit Board
http://www2.mouser.com/Search/ProductDetail.aspx?R=STM32F429I-DISCOvirtualkey51120000virtualkey511-STM32F429I-DISCO
They have these CPUs:
STM32F407 @ 168 MHz
STM32F411 @ 100 MHz
STM32F429 @ 180 MHz
I also have a good GPS module with serial and PPS output.
I'm wondering if a small Linux version exists for one of these CPU/boards, allowing me to configure the NTPd service to get the internal clock in sync with the GPS like seen on other boards like the Raspberry PI.
It is my understanding that usually the NTPd also uses the network interface for connection with other time servers or publishing of the information on the network. These boards do not have network chips/connectors and actually I'm not interested in connecting them with the external world. I would use the synced clock only on the choosen board itself.
As an alternative to a small linux edition, would this be something feasible with a different embedded or real time OS ?
or with a NTPd only port ?
thank you
Added text:
I would like to find the best approach to re-use any existing code to get time from gps, write to rtc AND sync to PPS.
i know that reading GPS received time via serial and writing to rtc is easy but i need to use also the sync logic to the PPS signal to get the lowest possible jitter within my budget constraints.
i need to save money and cannot buy off-the-shelf devices. if i can avoid the use of an os and stick to something smaller like an RTOS or embedded or custom code... well i would be happy :-)
i mentioned NTPd because is the only thing i know (my limitation) that allows these things (plus others).
did somebody else already "strip away" the PPS sync related portions of code ? or are them actually the core of NTPd and PPS is just a plugged in additional source like the network servers could be ?
please note that i'm a total newbie to the inner working of NTPd. I just configured gps-pps-ntpd sync on a raspberry pi following web available instructions to test the concept, but that does not make me ... an expert of NTPd :-)
Source: (StackOverflow)
Ehilà everybody!
I've this problem:
I'm serving ntp (On my Laptop for now ) with GPSD, using an old GPS-Sirf/NMEA module of the company I work for.
Let's forget about Ntpd.. as soon as I start gpsd, although date and time are correct in gpsmon, if I run an ntpshmmon I have a negative time ( about -69 years in seconds ) in the column tagged as "Real" which I assume to be the clock information of my SHM ( While de column "Clock" is actually the received information )
If I change module and use an U-blox everything it's ok and the SHM clock return to be +46 years.
Is there a way to manage the GPS exchange of information with NTP? Or to configure GPS without knowing exactly what GPS module is?
Sorry if my question is some kind of airy-fairy... I hope somebody have had my same problem and can detect the clue...
Thx! :)
FL
Source: (StackOverflow)
I use a raspberry pi with a Bluetooth dongle to simulate a beacon. I want to measure the time needed for a mobile app to detect the UUID of a beacon when I change it in the raspberry. With this code I found out the server used by the smartphone to synchronize the tile
final Resources res = this.getResources();
final int id = Resources.getSystem().getIdentifier(
"config_ntpServer", "string","android");
final String defaultServer = res.getString(id);
Than I synchronized the time in the raspberry pi with
sudo ntpdate -u 2.android.pool.ntp.org
Before I change the id of the beacon I print the time
timestamp() {
date +"%T,%3N"
}
timestamp # print timestamp
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1.....
Then I compare the time when I changed the UUID and the time in the logcat when the UUID was seen for the first time and the result is alwayse negative
UUID changed at 15:33:03,276 and detected at 15:33:02.301.
Is this a synchronization problem? Is there a better way to do this?
Source: (StackOverflow)
If I am running ntp (via ntp.conf) heavily restricted, I cannot use a pool for a server. Why? Because the call to restrict (to allow access for the pool) seems to be another DNS Lookup, which returns another IP value than what was used to originally call the server. Please show me that I am wrong/being stupid about this.
Crude Example (portion of ntp.conf):
server 0.debian.pool.ntp.org iburst
restrict default ignore
restrict -6 default ignore
restrict 0.debian.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
This does not work (I think) because DNS calls to 0.debian.pool.ntp.org return different IP addresses and thus the wrong IP address is allowed via the (poorly named) restrict.
Source: (StackOverflow)
I am working with two PCs: PC1 (server) and PC2 (client) and I am trying to synchronize their time with NTP. PC1 is not configured to get synchronized with any external time source. I just want whatever time is there on the PC1, PC2 should be synchronized in accordance to that. I've done following changes-:
In PC1 (server)-:
#vi /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 1
restrict 127.0.0.1
restrict 192.168.50.0 mask 255.255.255.0 nomodify notrap
driftfile /var/lib/ntp/drift
:wq!
#vi /etc/ntp/step-tickers
# List of servers used for initial synchronization.
127.127.1.0
:wq!
#vi /etc/init/rc.conf
ntpd_enable=\"YES\"
:wq!
In PC2 (client)-:
#vi /etc/ntp.conf
server 192.168.50.201
fudge 127.127.1.0 stratum 2
restrict 127.0.0.1
driftfile /var/lib/ntp/drift
restrict 192.168.50.201 mask 255.255.255.255 notrap nomodify
:wq!
#vi /etc/ntp/step-tickers
192.168.50.201
:wq!
#crontab -e
1 * * * * ntpdate -s -b -u 192.168.50.201
:wq!
#vi /etc/init/rc.conf
ntpd_enable=\"YES\"
:wq!
I've also changed the firewall settings at both sides by adding these lines-:
#vi /etc/sysconfig/iptables
-I INPUT -p udp --dport 123 -j ACCEPT
-I OUTPUT -p udp --sport 123 -j ACCEPT
:wq!
However, I am not able to synchronize PC2 date with PC1 date i.e. when I change date in PC1, changes are not immediately reflected in PC2. I am using RHEL 6.2 .
Can anyone tell me where I am going wrong??
Source: (StackOverflow)
I want monitor my ntpd services and ntpd service is used udp protocol。nagios have a method that is named check_udp,As follows:
[root@localhost]# ./check_udp -H 127.0.0.1 -p 123
With UDP checks, a send/expect string must be specified.
I want to know how to use check_udp...
Source: (StackOverflow)
I wish to run ntp service (ntpd and ntpq as per ntp.org sources) on Windows Embedded Compact 2013. Is this even possible? If yes, can anyone guide me how to build the NTP sources/code for the above mentioned platform?
Thanks in advance. :)
Source: (StackOverflow)
We are having a problem with a virtual machine that's running our frontend website. Once it's running everything is fine, but after a reboot memcached is going bonkers. What happens is that we put items in there set to expire in 15 to 30 seconds, but they don't expire for about an hour! So after a while all data we're serving is highly outdated.
We've been investigating the issue for a bit and found that during startup ntp is changing the clock a lot, putting it almost an hour forward.
We found that memcached doesn't use the system clock but has it's own clock, so once the system clock changes and sets the expiry in it's time, memcache is an hour behind and will keep the item for an hour.
We've already swapped the boot order of ntpd (now S58) and memcached (now S59), but that hasn't resolved the issue.
Restarting memcached manually after a reboot is not really option because our host reboots the server regularly after patches and we're not always there after that's happened.
Does anyone have any idea on how to resolve this? We've googled high and low, but can't find anyone with the same problem. Surely we're not the first to have this problem?
virt-what
is reporting the VPS is running in VMWare.
Source: (StackOverflow)
The Raspberry Pi has no real clock to keep track of time. Instead it uses the NTP daemon to keep date and time as accurate as possible. This should work, I guess, but in my case it doesn't for some reason.
Without going into too much detail, I use my Raspberry Pi in a way where it's always plugged in but doesn't always have an Internet connection. Sometimes the CPU has allot to do. Sometimes it doesn't. This results in the Rpi losing track of time. I would think that once it gets back on the Internet, it would sync the clock using the NTP servers to get back on track. However, it doesn't. From what I understand, if the offset is too big, the system doesn't sync the time.
Is there any way to force NTPD to sync the time no matter how big the offset is compared to the NTP servers? Or will I have to set up a cronjob say every hour running:
ntpd -g"
Source: (StackOverflow)
I configured ntpd on my system like so:
~$ cat /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
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
server 0.de.pool.ntp.org
server 1.de.pool.ntp.org
server 2.de.pool.ntp.org
server 3.de.pool.ntp.org
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1
server 127.127.8.0 mode 2 # standard time string with 9600, 7E2
# gpsd
server 127.127.28.0
fudge 127.127.28.0 refid GPSa
server 127.127.28.1
fudge 127.127.28.1 refid GPSp
ntpq tells me that ntpd gets the time from gps as desired:
~$ ntpq -c peers
remote refid st t when poll reach delay offset jitter
==============================================================================
-ns2.bvc-cloud.d 192.53.103.104 2 u 64 64 177 14.959 155.440 113.066
+mail.danzuck.eu 192.53.103.104 2 u - 64 377 10.176 -54.295 129.782
-ntp01.cc-netzwe 240.67.35.84 3 u 65 64 177 13.674 63.774 64.264
-server2.as2.ch 131.188.3.223 2 u 59 64 177 14.758 87.117 67.824
*GENERIC(0) .DCFa. 0 l 2 64 3 0.000 -65.610 0.733
+SHM(0) .GPSa. 0 l 323 64 140 0.000 -18.353 12.003
SHM(1) .GPSp. 0 l - 64 0 0.000 0.000 0.000
So obivously gpsd must be running. However ntpd does not get the pps signal. Is this to be expected for an USB GPS? That is: should I remove the configuration for GPSp? If not so: how can I find out why it fails?
Source: (StackOverflow)
I'm using a Raspberry Pi, and upon startup it's sending an e-mail with the time and an IP address. The problem is that the time is not correct, it's the time from last time the system was shut down. When I log in through ssh and do a date command, I get the correct time. In other words, the e-mail is sent before the system has updated its time.
I was thinking of automatically running ntpdate on boot, but after reading up on it it seems like a bad idea due to the many risks of error.
So, can I somehow wait until the time has been uppdated before continuing in a script?
Source: (StackOverflow)