]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats.
authorDave Hart <hart@ntp.org>
Sat, 27 Aug 2011 04:19:04 +0000 (04:19 +0000)
committerDave Hart <hart@ntp.org>
Sat, 27 Aug 2011 04:19:04 +0000 (04:19 +0000)
bk: 4e587038wWyvG-yVJ0kRla_z6BZbPA

ChangeLog
ntpd/ntp_control.c
ntpq/ntpq-subs.c

index 12717a8ffc5e34cbcfddfeb4c1223a46667bcc88..653d52195a7cd4e5fe1bb2724123db45b8a6525b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats.
 (4.2.7p208) 2011/08/24 Released by Harlan Stenn <stenn@ntp.org>
 * Fix the CLOCK_MONOTONIC TRACE() message.
 (4.2.7p207) 2011/08/22 Released by Harlan Stenn <stenn@ntp.org>
index 4214dde01543bbb9929707acb7d008a09b22bd86..2deb91ac5f3a5767622b78b02947934636317fef 100644 (file)
@@ -209,7 +209,10 @@ static const struct ctl_proc control_codes[] = {
 #define        CS_IO_SENDFAILED        82
 #define        CS_IO_WAKEUPS           83
 #define        CS_IO_GOODWAKEUPS       84
-#define        CS_MAX_NOAUTOKEY        CS_IO_GOODWAKEUPS
+#define        CS_TIMERSTATS_RESET     85
+#define        CS_TIMER_OVERRUNS       86
+#define        CS_TIMER_XMTS           87
+#define        CS_MAX_NOAUTOKEY        CS_TIMER_XMTS
 #ifdef AUTOKEY
 #define        CS_FLAGS                (1 + CS_MAX_NOAUTOKEY)
 #define        CS_HOST                 (2 + CS_MAX_NOAUTOKEY)
@@ -400,6 +403,9 @@ static const struct ctl_var sys_var[] = {
        { CS_IO_SENDFAILED,     RO, "io_sendfailed" },  /* 82 */
        { CS_IO_WAKEUPS,        RO, "io_wakeups" },     /* 83 */
        { CS_IO_GOODWAKEUPS,    RO, "io_goodwakeups" }, /* 84 */
+       { CS_TIMERSTATS_RESET,  RO, "timerstats_reset" },/* 85 */
+       { CS_TIMER_OVERRUNS,    RO, "timer_overruns" }, /* 86 */
+       { CS_TIMER_XMTS,        RO, "timer_xmts" },     /* 87 */
 #ifdef AUTOKEY
        { CS_FLAGS,     RO, "flags" },          /* 1 + CS_MAX_NOAUTOKEY */
        { CS_HOST,      RO, "host" },           /* 2 + CS_MAX_NOAUTOKEY */
@@ -410,7 +416,7 @@ static const struct ctl_var sys_var[] = {
        { CS_IDENT,     RO, "ident" },          /* 7 + CS_MAX_NOAUTOKEY */
        { CS_DIGEST,    RO, "digest" },         /* 8 + CS_MAX_NOAUTOKEY */
 #endif /* AUTOKEY */
-       { 0,            EOV, "" }               /* 57/65 */
+       { 0,            EOV, "" }               /* 87/95 */
 };
 
 static struct ctl_var *ext_sys_var = NULL;
@@ -2188,6 +2194,19 @@ ctl_putsys(
        case CS_IO_GOODWAKEUPS:
                ctl_putuint(sys_var[varid].text, handler_pkts);
                break;
+
+       case CS_TIMERSTATS_RESET:
+               ctl_putuint(sys_var[varid].text,
+                           current_time - timer_timereset);
+               break;
+
+       case CS_TIMER_OVERRUNS:
+               ctl_putuint(sys_var[varid].text, alarm_overflow);
+               break;
+
+       case CS_TIMER_XMTS:
+               ctl_putuint(sys_var[varid].text, timer_xmtcalls);
+               break;
 #ifdef AUTOKEY
        case CS_FLAGS:
                if (crypto_flags)
index 405b193adec4f97b21fb193cdb160819be30712a..1bc8b13e1ecfa0cdf0671f6261bee81ac9bfdbad 100644 (file)
@@ -74,6 +74,7 @@ static        void    sysinfo         (struct parse *, FILE *);
 static void    kerninfo        (struct parse *, FILE *);
 static void    monstats        (struct parse *, FILE *);
 static void    iostats         (struct parse *, FILE *);
+static void    timerstats      (struct parse *, FILE *);
 
 /*
  * Commands we understand.     Ntpdc imports this.
@@ -193,6 +194,9 @@ struct xcmd opcmds[] = {
        { "iostats", iostats, { NO, NO, NO, NO },
          { "", "", "", "" },
          "display network input and output counters" },
+       { "timerstats", timerstats, { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display interval timer counters" },
        { 0,            0,              { NO, NO, NO, NO },
          { "-4|-6", "", "", "" }, "" }
 };
@@ -3453,13 +3457,33 @@ iostats(
        { "io_sendfailed",      "packet send failures: ", NTP_STR },
        { "io_wakeups",         "input wakeups:        ", NTP_STR },
        { "io_goodwakeups",     "useful input wakeups: ", NTP_STR },
-       { NULL,                 NULL,                   0       }
+       { NULL,                 NULL,                     0       }
     };
 
        collect_display_vdc(0, iostats_vdc, FALSE, fp);
 }
 
 
+/*
+ * timerstats - ntpq -c timerstats - interval timer counters
+ */
+static void
+timerstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+    static vdc timerstats_vdc[] = {
+       { "timerstats_reset",   "time since reset:  ", NTP_STR },
+       { "timer_overruns",     "timer overruns:    ", NTP_STR },
+       { "timer_xmts",         "calls to transmit: ", NTP_STR },
+       { NULL,                 NULL,                  0       }
+    };
+
+       collect_display_vdc(0, timerstats_vdc, FALSE, fp);
+}
+
+
 /*
  * authinfo - implements ntpq -c authinfo
  */