[Git][NTPsec/ntpsec][master] Debugging cleanups for ntpmon
Hal Murray
gitlab at mg.gitlab.com
Fri Dec 16 07:52:07 UTC 2016
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
217c7c9e by Hal Murray at 2016-12-15T23:51:45-08:00
Debugging cleanups for ntpmon
- - - - -
3 changed files:
- ntpclients/ntpmon
- pylib/packet.py
- pylib/util.py
Changes:
=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -117,6 +117,13 @@ if __name__ == '__main__':
mru_report = ntp.util.MRUSummary(showhostnames)
try:
session = ntp.packet.ControlSession()
+ if 0: # debugging hacks, UI is $EDITOR
+ session.logfp = open("ntpmon.log", "a")
+ session.debug = 4
+ peer_report.logfp = session.logfp
+ peer_report.debug = session.debug
+ mru_report.logfp = session.logfp
+ mru_report.debug = session.debug
session.openhost(arguments[0] if arguments else "localhost")
sysvars = session.readvar()
with OutputContext() as ctx:
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -844,7 +844,7 @@ class ControlSession:
while len(xdata) % 4:
xdata += b"\x00"
if self.debug >= 3:
- print("Sending %d octets" % len(xdata))
+ self.logfp.write("Sending %d octets" % len(xdata))
try:
self.sock.sendall(polybytes(xdata))
except socket.error:
@@ -853,7 +853,7 @@ class ControlSession:
return -1
if self.debug >= 4:
self.logfp.write("Request packet:\n")
- dump_hex_printable(xdata)
+ dump_hex_printable(xdata, self.logfp)
return 0
def sendrequest(self, opcode, associd, qdata, auth=False):
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -267,10 +267,10 @@ class PeerSummary:
elif self.showhostnames:
try:
if self.debug:
- sys.stderr.write("DNS lookup begins...\n")
+ self.logfp.write("DNS lookup begins...\n")
clock_name = canonicalize_dns(srcadr)
if self.debug:
- sys.stderr.write("DNS lookup ends.\n")
+ self.logfp.write("DNS lookup ends.\n")
except TypeError:
return ''
else:
@@ -318,6 +318,8 @@ class MRUSummary:
def __init__(self, showhostnames):
self.showhostnames = showhostnames # If false, display numeric IPs
self.now = time.time()
+ self.logfp = sys.stderr
+ self.debug = 0
header = " lstint avgint rstr r m v count rport remote address"
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/217c7c9e9becedeb85cff3e55aa9b7d3d220a046
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161216/4f39fbb8/attachment.html>
More information about the vc
mailing list