[Git][NTPsec/ntpsec][master] More progress on pyntpq status commands.
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Oct 16 21:39:23 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
7dfc1fc4 by Eric S. Raymond at 2016-10-16T17:39:10-04:00
More progress on pyntpq status commands.
The commands sysinfo, kerninfo, sysstats, monstats, authinfo, iostats,
and timerstats are now entirely wrking except for two data-display
issues flagged by FIXME comments.
- - - - -
1 changed file:
- ntpq/pyntpq
Changes:
=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -181,6 +181,14 @@ tstflagnames = (
"peer_unreach" # BOGON13
)
+def statustoa(_is_sys, n):
+ # FIXME: see libntp/statestr.c
+ return n
+
+def prettydate(d):
+ # FIXME: we need to unpack this date.
+ return d[2:]
+
class ntpq_interpreter(cmd.Cmd):
"ntpq command interpreter"
@@ -239,11 +247,21 @@ usage: timeout [ msec ]
if type(msg) == str:
print(msg)
return
+ if decodestatus:
+ sys.stdout.write("associd=%u status=%04x %s,\n" %
+ (associd,
+ self.session.rstatus,
+ statustoa(associd == 0, self.session.rstatus)))
for (name, legend, fmt) in variables:
- if fmt == NTP_STR:
- sys.stdout.write("%s '%s'\n" % (legend, msg[name]))
+ value = msg[name]
+ if fmt in (NTP_STR, NTP_UINT, NTP_INT, NTP_ADD, NTP_ADP):
+ sys.stdout.write("%s %s\n" % (legend, value))
+ elif fmt == NTP_LFP:
+ sys.stdout.write("%s %s\n" % (legend, prettydate(value)))
+ elif fmt in (NTP_2BIT, NTP_MODE):
+ sys.stdout.write("%s %s\n" % (legend, bin(value)[2:]))
else:
- sys.stderr.write("Unknown data type code %s for %s\n" % (fmt, name))
+ sys.stderr.write("unxpected vc type %s for %s, value %s\n" % (fmt, name, value))
def do_delay(self, line):
"set the delay added to encryption time stamps"
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/7dfc1fc46dd2b01e5a90d22f179f5cea6c4b32a6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161016/5b87ebed/attachment.html>
More information about the vc
mailing list