]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add leap status to selectdata report
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 09:05:37 +0000 (11:05 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 16:56:37 +0000 (18:56 +0200)
candm.h
client.c
cmdmon.c
doc/chronyc.adoc
reports.h
sources.c
test/system/007-cmdmon

diff --git a/candm.h b/candm.h
index 2390302abdfcb03da339989ffaa081a0aef01b84..7c367797be95d8393c274ddd2328c6f424de1e21 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -764,7 +764,8 @@ typedef struct {
   IPAddr ip_addr;
   uint8_t state_char;
   uint8_t authentication;
-  uint8_t pad[2];
+  uint8_t leap;
+  uint8_t pad;
   uint16_t conf_options;
   uint16_t eff_options;
   uint32_t last_sample_ago;
index ec5f354ecf5624deab855ec3e6ef45bc1696682d..e136181e2cdbca58351b7dd64b8c7f5077aa0afe 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1863,19 +1863,19 @@ print_report(const char *format, ...)
         integer = va_arg(ap, int);
         switch (integer) {
           case LEAP_Normal:
-            string = "Normal";
+            string = width != 1 ? "Normal" : "N";
             break;
           case LEAP_InsertSecond:
-            string = "Insert second";
+            string = width != 1 ? "Insert second" : "+";
             break;
           case LEAP_DeleteSecond:
-            string = "Delete second";
+            string = width != 1 ? "Delete second" : "-";
             break;
           case LEAP_Unsynchronised:
-            string = "Not synchronised";
+            string = width != 1 ? "Not synchronised" : "?";
             break;
           default:
-            string = "Invalid";
+            string = width != 1 ? "Invalid" : "?";
             break;
         }
         printf("%s", string);
@@ -2557,9 +2557,9 @@ process_cmd_selectdata(char *line)
     printf(    "|                        |    |     |                       |\n");
   }
 
-  print_header("S Name/IP Address        Auth COpts EOpts Last Score     Interval   ");
+  print_header("S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap");
 
-  /*           "S NNNNNNNNNNNNNNNNNNNNNNNNN A OOOO- OOOO- LLLL SSSSS LLLLLLL LLLLLLL" */
+  /*           "S NNNNNNNNNNNNNNNNNNNNNNNNN A OOOO- OOOO- LLLL SSSSS IIIIIII IIIIIII  L" */
 
   for (i = 0; i < n_sources; i++) {
     request.command = htons(REQ_SELECT_DATA);
@@ -2577,7 +2577,7 @@ process_cmd_selectdata(char *line)
     conf_options = ntohs(reply.data.select_data.conf_options);
     eff_options = ntohs(reply.data.select_data.eff_options);
 
-    print_report("%c %-25s %c %c%c%c%c%c %c%c%c%c%c %I %5.1f %+S %+S\n",
+    print_report("%c %-25s %c %c%c%c%c%c %c%c%c%c%c %I %5.1f %+S %+S  %1L\n",
                  reply.data.select_data.state_char,
                  name,
                  reply.data.select_data.authentication ? 'Y' : 'N',
@@ -2595,6 +2595,7 @@ process_cmd_selectdata(char *line)
                  UTI_FloatNetworkToHost(reply.data.select_data.score),
                  UTI_FloatNetworkToHost(reply.data.select_data.lo_limit),
                  UTI_FloatNetworkToHost(reply.data.select_data.hi_limit),
+                 reply.data.select_data.leap,
                  REPORT_END);
   }
 
index c17db0cbdee6f4d609650ec1a888293dffb4d062..b8224dee943903c0c8aa64682e31a40dad723deb 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1327,6 +1327,7 @@ handle_select_data(CMD_Request *rx_message, CMD_Reply *tx_message)
   UTI_IPHostToNetwork(&report.ip_addr, &tx_message->data.select_data.ip_addr);
   tx_message->data.select_data.state_char = report.state_char;
   tx_message->data.select_data.authentication = report.authentication;
+  tx_message->data.select_data.leap = report.leap;
   tx_message->data.select_data.conf_options = htons(convert_select_options(report.conf_options));
   tx_message->data.select_data.eff_options = htons(convert_select_options(report.eff_options));
   tx_message->data.select_data.last_sample_ago = htonl(report.last_sample_ago);
index e41694506cead60a8d536a47fe876c9c47859326..d12d6b3e1092f993eecca723c0411c0ca73e006f 100644 (file)
@@ -432,11 +432,11 @@ lines are shown as a reminder of the meanings of the columns.
 An example of the output is shown below.
 +
 ----
-S Name/IP Address        Auth COpts EOpts Last Score     Interval   
-====================================================================
-D foo.example.net           Y ----- --TR-    4   1.0   -61ms   +62ms
-* bar.example.net           N ----- -----    0   1.0 -6846us +7305us
-+ baz.example.net           N ----- -----   10   1.0 -7381us +7355us
+S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
+=======================================================================
+D foo.example.net           Y ----- --TR-    4   1.0   -61ms   +62ms  N
+* bar.example.net           N ----- -----    0   1.0 -6846us +7305us  N
++ baz.example.net           N ----- -----   10   1.0 -7381us +7355us  N
 ----
 +
 The columns are as follows:
@@ -508,6 +508,12 @@ be reselected and the scores will be reset to 1.
 This column displays the lower and upper endpoint of the interval which was
 expected to contain the true offset of the local clock considering the root
 distance at the time of the selection.
+*Leap*:::
+This column displays the current leap status of the source.
+* _N_ indicates the normal status (no leap second).
+* _+_ indicates that a leap second will be inserted at the end of the month.
+* _-_ indicates that a leap second will be deleted at the end of the month.
+* _?_ indicates the unknown status (i.e. no valid measurement was made).
 
 [[reselect]]*reselect*::
 To avoid excessive switching between sources, *chronyd* can stay synchronised
index 9776974f56b90dbeb46ee403f9c61e387aeea300..4508e8f3a6185d31e1d73b4a4a7bba280921c9ba 100644 (file)
--- a/reports.h
+++ b/reports.h
@@ -190,6 +190,7 @@ typedef struct {
   IPAddr ip_addr;
   char state_char;
   int authentication;
+  NTP_Leap leap;
   int conf_options;
   int eff_options;
   uint32_t last_sample_ago;
index 260cd8553e3ea5703cbf0630c0e79371e04d9b8a..67bc5d87e79148d1dab81235d114775cbfcbd5f3 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -1610,6 +1610,7 @@ SRC_GetSelectReport(int index, RPT_SelectReport *report)
     report->ip_addr.family = IPADDR_UNSPEC;
   report->state_char = get_status_char(inst->status);
   report->authentication = inst->authenticated;
+  report->leap = inst->leap;
   report->conf_options = inst->conf_sel_options;
   report->eff_options = inst->sel_options;
   report->last_sample_ago = inst->sel_info.last_sample_ago;
index c0e108eda7da0cb52d4cdb2c2188bb982c86ce8d..37a1d349a9e336b781d5a64d55671a9ac61a4240 100755 (executable)
@@ -96,9 +96,9 @@ Total RX        : [0-9]+
 Total valid RX  : [0-9]+$" || test_fail
 
 run_chronyc "selectdata" || test_fail
-check_chronyc_output "^S Name/IP Address        Auth COpts EOpts Last Score     Interval +
-====================================================================
-M 127\.0\.0\.1                 N ----- -----    0   1\.0    \+0ns    \+0ns$" || test_fail
+check_chronyc_output "^S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
+=======================================================================
+M 127\.0\.0\.1                 N ----- -----    0   1\.0    \+0ns    \+0ns  \?$" || test_fail
 
 run_chronyc "serverstats" || test_fail
 check_chronyc_output "^NTP packets received       : [0-9]+