[Git][NTPsec/ntpsec][master] Multiserver operation for pyntpq.
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Oct 23 17:54:01 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
b8bceb21 by Eric S. Raymond at 2016-10-23T13:53:33-04:00
Multiserver operation for pyntpq.
- - - - -
1 changed file:
- ntpq/pyntpq
Changes:
=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -430,21 +430,15 @@ usage: help [ command ]
c = " x.-+#*o"[CTL_PEER_STATVAL(self.session.rstatus) & 0x7]
else:
c = " .+*"[CTL_PEER_STATVAL(self.session.rstatus) & 0x3]
- #if len(self.chosts) > 1:
- # if (header == peerheader or header == apeerheader) and have_dstadr:
- # serverlocal = nntohost_col(dstadr, True)
- # else:
- # if currenthostisnum:
- # serverlocal = currenthost[:maxhostlen]
- # else:
- # serverlocal = currenthost
- # sys.stdout.write("%-*s " % (maxhostlen, serverlocal))
+ if len(self.chosts) > 1:
+ maxhostlen = max([len(host) for (host, _af) in self.chosts])
+ sys.stdout.write("%-*s " % (maxhostlen, self.session.hostname))
def is_ipv6(addr): return ":" in addr and "." not in addr
if socket.AF_UNSPEC == af or af == (socket.AF_INET6 if is_ipv6(srcaddr) else socket.AF_INET):
# Source host or clockname
namewidth = 15
addrwidth = 15
- if displayname != None and showhostnames:
+ if displayname != None and self.showhostnames:
clock_name = displayname
elif srchost != None:
clock_name = srchost
@@ -506,14 +500,10 @@ usage: help [ command ]
if not self.__dogetassoc():
return
maxhostlen = 0
- #for host in self.chosts:
- # if getnetnum(chosts[u].hostname, &netnum, fullname, af):
- # name_or_num = nntohost(&netnum)
- # sl = len(name_or_num)
- # maxhostlen = max(maxhostlen, sl)
if len(self.chosts) > 1:
+ maxhostlen = max([len(host) for (host, _af) in self.chosts])
sys.stdout.write("%-*.*s " % \
- (maxhostlen, maxhostlen, "server (local)"))
+ (maxhostlen, maxhostlen, "server"))
sys.stdout.write(header)
sys.stdout.write(("=" * (maxhostlen + 78)) + "\n")
for peer in self.peers:
@@ -1486,6 +1476,9 @@ if __name__ == '__main__':
try:
if len(interpreter.ccmds) == 0:
+ if len(interpreter.chosts) > 1:
+ sys.stderr.write("ntpq can only work interactively on one host.")
+ interpreter.chosts = interpreter.chosts[:1]
session.openhost(*interpreter.chosts[0])
interpreter.cmdloop()
else:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b8bceb2185451a0607caa7fc92c6a6f48ab5f7d9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161023/2835ffce/attachment.html>
More information about the vc
mailing list