]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: print invalid intervals as dash
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 2 Dec 2015 17:21:07 +0000 (18:21 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 3 Dec 2015 10:43:06 +0000 (11:43 +0100)
Instead of printing some large arbitrary values use dash in the LastRx
column of the sources output and the Last/Int columns in the clients
output when no sample or hit is recorded.

client.c

index f8f2ecfd9568bcb0faa0202930b7ecc2a1bfe154..25d7c7adec7ab69af17eb0f0a46cd88020486e3e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1544,7 +1544,10 @@ static void
 print_seconds(unsigned long s)
 {
   unsigned long d;
-  if (s <= 1024) {
+
+  if (s == (uint32_t)-1) {
+    printf("   -");
+  } else if (s <= 1024) {
     printf("%4ld", s);
   } else if (s < 36000) {
     printf("%3ldm", s / 60);
@@ -1644,6 +1647,18 @@ print_signed_freq_ppm(double f)
 
 /* ================================================== */
 
+static void
+print_clientlog_interval(int rate)
+{
+  if (rate >= 127) {
+    printf(" -");
+  } else {
+    printf("%2d", rate);
+  }
+}
+
+/* ================================================== */
+
 static int
 check_for_verbose_flag(char *line)
 {
@@ -2084,13 +2099,17 @@ process_cmd_clients(char *line)
         DNS_IPAddress2Name(&ip, hostname, sizeof (hostname));
 
       printf("%-25s", hostname);
-      printf("  %6"PRIu32"  %5"PRIu16"  %2d  %2d  ",
-             ntohl(client->ntp_hits), ntohs(client->ntp_drops),
-             client->ntp_interval, client->ntp_timeout_interval);
+      printf("  %6"PRIu32"  %5"PRIu16"  ",
+             ntohl(client->ntp_hits), ntohs(client->ntp_drops));
+      print_clientlog_interval(client->ntp_interval);
+      printf("  ");
+      print_clientlog_interval(client->ntp_timeout_interval);
+      printf("  ");
       print_seconds(ntohl(client->last_ntp_hit_ago));
-      printf("  %6"PRIu32"  %5"PRIu16"  %2d  ",
-             ntohl(client->cmd_hits), ntohs(client->cmd_drops),
-             client->cmd_interval);
+      printf("  %6"PRIu32"  %5"PRIu16"  ",
+             ntohl(client->cmd_hits), ntohs(client->cmd_drops));
+      print_clientlog_interval(client->cmd_interval);
+      printf("  ");
       print_seconds(ntohl(client->last_cmd_hit_ago));
       printf("\n");
     }