Monitoring a GPS NTP Server

Beyond monitoring Linux OS and basic NTP statistics of your stratum 1 GPS NTP server, you can get some more values from the GPS receiver itself, namely the number of satellites (active & in view) as well as the GPS fix and dilution of precision aka DOP. This brings a few more graphs and details. Nice. Let’s go:

This article is one of many blogposts within this NTP series. Please have a look!

NMEA 0183

The GPS-based NTP server consists of two inputs: The NMEA sentences to get the date and time (along with much other information as the position, which is the primary usage of GPS) and the PPS pulse per second ticks. In order to get some live stats about the satellites and the precision of the GPS signal, we leverage some of the NMEA sentences. Since the gpsd daemon is already running on the Raspberry Pi, we can easily use another tool called “gas pipe” which simply lists all incoming NMEA data. Sample usage of gpspipe -r:

Piping this output into grep XY -m 1 to stop after the first output, and piping it again into awk -F ',' '{print $X}' to have the comma as separator as well as printing only the X-th position, we can use the following NMEA messages to gather this information:

  • satellites in view: GPGSV at the fourth position
  • satellites being active: GPGGA after the seventh comma = position 8
  • GPS fix (0 = no fix, 1 = 2D fix, 3= 3D fix which is the best): GPGSA at position 3
  • positional dilution of precision aka PDOP (should be under 10 for a good position, but irrelevant for our NTP timing): GPGSA again, normally at position 15, but for whatever reason on my output it is at position 54.

A sample run with these four values is:

That’s it from the NTP server’s side of view. Now we have to bring those values into the monitoring server:


I am still using my fairly outdated MRTG with Routers2 and RRD installation. Please consider using some other tools such as Zabbix, Icinga 2, or PRTG for monitoring purposes. However, the following procedures in getting the raw values from the NTP server into some kind of SNMP monitoring system are the same.

I am using the “EXTENDING THE AGENT” section within the snmpd.conf in order to be able to poll these values through SNMP. That is:  sudo nano /etc/snmp/snmpd.conf adding the following lines at the EXTENDING THE AGENT section:

Followed by a sudo service snmpd restart.

Using snmpwalk on the MRTG server to find the relevant OIDs, such as:

Note that some of those used NMEA sentences only appear every few seconds, in my case of GPGSV only every 10 seconds. Since the default timeout for SNMP is much lower you might run into some timeouts. Use the “-t 11” option for snmpwalk, while appending “::11:5::2” at the end of each MRTG target to do the same with an additional retry count of 5 to overcome this issue.

In the end my two MRTG targets for all four values (that is: 2x graphs) are as follows:

This gives the following graphs. Note the daily period for the satellites, depending on the position of the GPS antenna. Satellites graph (in the weekly view):

And the GPS fix and PDOP graph (in the weekly view as well):

Two more graphs, both in the yearly view, that show my change from a small GPS antenna to a bigger one at the beginning of February 2018. While the average number of active satellites increased from about 5 to almost 8, the daily peak for the PDOP decreased from about 33 to under 10. Very good!

That’s it. Have a nice day. :D

Featured image “Cockpit” by Roger Schultz is licensed under CC BY 2.0.

Leave a Reply

Your email address will not be published. Required fields are marked *