From: Dave Hart Date: Sat, 27 Aug 2011 04:19:04 +0000 (+0000) Subject: [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats. X-Git-Tag: NTP_4_2_7P209~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57e1e18b7e33e8eb28a4f20fac658fd924c50cf9;p=thirdparty%2Fntp.git [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats. bk: 4e587038wWyvG-yVJ0kRla_z6BZbPA --- diff --git a/ChangeLog b/ChangeLog index 12717a8ff..653d52195 100644 --- 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 * Fix the CLOCK_MONOTONIC TRACE() message. (4.2.7p207) 2011/08/22 Released by Harlan Stenn diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 4214dde01..2deb91ac5 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -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) diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index 405b193ad..1bc8b13e1 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -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 */