summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ntpmon.c13
-rw-r--r--ntpmon.xml25
-rw-r--r--ntpshm.h4
-rw-r--r--ntpshmread.c5
4 files changed, 27 insertions, 20 deletions
diff --git a/ntpmon.c b/ntpmon.c
index d0f75ad5..fc852970 100644
--- a/ntpmon.c
+++ b/ntpmon.c
@@ -16,7 +16,7 @@
#define NTPSEGMENTS 256 /* NTPx for x any byte */
static struct shmTime *segments[NTPSEGMENTS + 1];
-static int tick[NTPSEGMENTS + 1];
+static struct timespec tick[NTPSEGMENTS + 1];
static int shm_startup(int count)
/* open a specified number of segments */
@@ -86,13 +86,14 @@ int main(int argc, char **argv)
switch(status)
{
case OK:
- if (shm_stat.now >= tick[i]) {
- printf("sample %s %ld %ld %ld %ld %ld %d\n",
- shm_name(i), shm_stat.now,
+ if (shm_stat.tvc.tv_sec >= tick[i].tv_sec || shm_stat.tvc.tv_sec >= tick[i].tv_nsec) {
+ printf("sample %s %ld %ld %ld %ld %ld %ld %d %d\n",
+ shm_name(i),
+ shm_stat.tvc.tv_sec, shm_stat.tvc.tv_nsec,
shm_stat.tvr.tv_sec, shm_stat.tvr.tv_nsec,
shm_stat.tvt.tv_sec, shm_stat.tvt.tv_nsec,
- shm_stat.leap);
- tick[i] = shm_stat.now;
+ shm_stat.leap, shm_stat.precision);
+ tick[i] = shm_stat.tvc;
}
break;
case NOT_READY:
diff --git a/ntpmon.xml b/ntpmon.xml
index 6ca39f96..218df9de 100644
--- a/ntpmon.xml
+++ b/ntpmon.xml
@@ -45,17 +45,18 @@ interfering with ntpd's normal operation.</para>
sample reports to standard output once per second. Each line
consists of whitespace-separated textual fields.</para>
-<para>Here is an example of thge beginning of a report file:
+<para>Here is an example of the beginning of a report file:
<literallayout>
ntpmon version 1
units 4
%
-sample NTP2 1424862537 1424862537 126617938 1424862537 0 0
-sample NTP3 1424862537 1424862537 1691342 1424862537 0 0
+sample NTP2 1424865634 779678109 1424865634 109814469 1424865634 0 0 -1
+sample NTP3 1424865634 779693823 1424865633 999315444 1424865634 0 0 -20
+%
+sample NTP2 1424865635 779902553 1424865635 113981778 1424865635 0 0 -1
+sample NTP3 1424865635 779916521 1424865634 999344705 1424865635 0 0 -20
%
-sample NTP2 1424862538 1424862538 123625917 1424862538 0 0
-sample NTP3 1424862538 1424862538 1687817 1424862538 0 0
</literallayout></para>
<para>The output always begins with a header line expressing the
@@ -76,7 +77,9 @@ containing the single field "%%". Each stanza consists of sample lines.</para>
<listitem><para>The NTP unit from which it was collected.</para></listitem>
-<listitem><para>Time of collection, seconds Unix UTC.</para></listitem>
+<listitem><para>Collection time of day, seconds.</para></listitem>
+
+<listitem><para>Collection time of day, nanoseconds.</para></listitem>
<listitem><para>Receiver time of day, seconds.</para></listitem>
@@ -87,14 +90,16 @@ containing the single field "%%". Each stanza consists of sample lines.</para>
<listitem><para>Clock time of day, nanoseconds</para></listitem>
<listitem><para>Leap-second offset.</para></listitem>
+
+<listitem><para>Source precision.</para></listitem>
</orderedlist>
</para>
<para>In these fields, "clock time" is the high-precision time
-measured by the source and "receiver time" is Unix UTC time at
-the receiver. It is normal for the seconds part of receiver
-time to coincide with collection time and for the nanoseconds
-part of receiver time to be zero.</para>
+measured by the source and "receiver time" is Unix UTC time at the
+receiver. It is normal for the seconds part of receiver time to
+coincide with the seconds part ofcollection time and for the
+nanoseconds part of receiver time to be zero.</para>
<variablelist>
<varlistentry>
diff --git a/ntpshm.h b/ntpshm.h
index 5e7103a0..07a02a8d 100644
--- a/ntpshm.h
+++ b/ntpshm.h
@@ -53,8 +53,8 @@ enum segstat_t {
struct shm_stat_t {
int mode;
- struct timespec tvr, tvt;
- time_t now;
+ struct timespec tvc, tvr, tvt;
+ int precision;
int leap;
};
diff --git a/ntpshmread.c b/ntpshmread.c
index c6fc06fc..5854df64 100644
--- a/ntpshmread.c
+++ b/ntpshmread.c
@@ -66,8 +66,8 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat)
unsigned int cns_new, rns_new;
int cnt;
- shm_stat->now = 0;
- time(&shm_stat->now);
+ shm_stat->tvc.tv_sec = shm_stat->tvc.tv_nsec = 0;
+ clock_gettime(CLOCK_REALTIME, &shm_stat->tvc);
if (shm == NULL) {
shm_stat->mode = NO_SEGMENT;
@@ -145,6 +145,7 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat)
shm->valid = 0;
shm_stat->leap = shm->leap;
+ shm_stat->precision = shm->precision;
shm_stat->mode = OK;
return OK;
}