[Git][NTPsec/ntpsec][master] 2 commits: Add comments to unit strings
Gary E. Miller
gitlab at mg.gitlab.com
Tue Aug 8 22:16:25 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
491ffdf8 by Gary E. Miller at 2017-08-08T15:16:07-07:00
Add comments to unit strings
- - - - -
8f408587 by Gary E. Miller at 2017-08-08T15:16:07-07:00
Add wideremote to MRUSummary, like PEERSummary.
This is to stop overflowing the 'remote address' field.
- - - - -
3 changed files:
- ntpclients/ntpmon
- ntpclients/ntpq
- pylib/util.py
Changes:
=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -210,7 +210,8 @@ if __name__ == '__main__':
showunits=showunits,
termwidth=80,
debug=0)
- mru_report = ntp.util.MRUSummary(showhostnames)
+ mru_report = ntp.util.MRUSummary(showhostnames,
+ wideremote=wideremote)
try:
session = ntp.packet.ControlSession()
session.openhost(arguments[0] if arguments else "localhost")
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -1305,7 +1305,8 @@ usage: config_from_file <configuration filename>
else:
mruhook = None
try:
- formatter = ntp.util.MRUSummary(interpreter.showhostnames)
+ formatter = ntp.util.MRUSummary(interpreter.showhostnames,
+ wideremote=True)
if self.directmode:
formatter.now = None
self.formatter = formatter
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -33,11 +33,11 @@ OLD_CTL_PST_SEL_SYSPEER = 3
# Units for formatting
-UNIT_NS = "ns"
-UNIT_US = u"µs"
-UNIT_MS = "ms"
-UNIT_S = "s"
-UNIT_KS = "ks"
+UNIT_NS = "ns" # nano second
+UNIT_US = u"µs" # micro second
+UNIT_MS = "ms" # milli second
+UNIT_S = "s" # second
+UNIT_KS = "ks" # kilo seconds
UNITS_SEC = (UNIT_NS, UNIT_US, UNIT_MS, UNIT_S, UNIT_KS)
UNIT_PPT = u"‰" # parts per thousand
UNIT_PPB = "ppb" # parts per billion
@@ -1010,11 +1010,12 @@ class PeerSummary:
class MRUSummary:
"Reusable class for MRU entry summary generation."
- def __init__(self, showhostnames):
- self.showhostnames = showhostnames # If false, display numeric IPs
- self.now = None
- self.logfp = sys.stderr
+ def __init__(self, showhostnames, wideremote=False):
self.debug = 0
+ self.logfp = sys.stderr
+ self.now = None
+ self.showhostnames = showhostnames # If false, display numeric IPs
+ self.wideremote = wideremote
header = " lstint avgint rstr r m v count rport remote address"
@@ -1055,6 +1056,9 @@ class MRUSummary:
try:
if self.showhostnames:
dns = canonicalize_dns(dns)
+ if not self.wideremote:
+ # truncate for narrow display
+ dns = dns[:40]
stats += " %4hx %c %d %d %6d %5s %s" % \
(entry.rs, rscode,
ntp.magic.PKT_MODE(entry.mv),
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b43ab72e3c8e7fec4d20275d8f46492a2290ef22...8f4085873f807816c570a55dcce331d7676580c9
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b43ab72e3c8e7fec4d20275d8f46492a2290ef22...8f4085873f807816c570a55dcce331d7676580c9
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170808/0f878e40/attachment.html>
More information about the vc
mailing list