[Git][NTPsec/ntpsec][master] Address GitLab issue #205: ntpmon should support -V argument
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Dec 15 02:27:15 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
3200e1d0 by Eric S. Raymond at 2016-12-14T21:26:34-05:00
Address GitLab issue #205: ntpmon should support -V argument
- - - - -
2 changed files:
- docs/includes/ntpmon-body.txt
- ntpclients/ntpmon
Changes:
=====================================
docs/includes/ntpmon-body.txt
=====================================
--- a/docs/includes/ntpmon-body.txt
+++ b/docs/includes/ntpmon-body.txt
@@ -49,6 +49,10 @@ x:: Cleanly terminate the program.
?:: List these commands.
+== Options ==
+
+-V:: Display version and exit.
+
== Known Bugs ==
+ntpmon+ will appear to hang when monitoring hosts with extremely long
=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -84,13 +84,28 @@ class OutputContext:
curses.endwin()
usage = '''
-USAGE: ntpmon [host]
+USAGE: ntpmon [-V] [host]
'''
if __name__ == '__main__':
+ try:
+ (options, arguments) = getopt.getopt(sys.argv[1:],
+ "V", ["version"])
+ except getopt.GetoptError as e:
+ sys.stderr.write("%s\n" % e)
+ sys.stderr.write(usage)
+ raise SystemExit(1)
+ progname = sys.argv[0]
+
showhostnames = True
wideremote = False
showall = False
+
+ for (switch, val) in options:
+ if switch in ("-V", "--version"):
+ print("ntpmon %s" % ntp.util.stdversion())
+ raise SystemExit(0)
+
poll_interval = 1
helpmode = False
peer_report = ntp.util.PeerSummary(displaymode="peers",
@@ -102,7 +117,7 @@ if __name__ == '__main__':
mru_report = ntp.util.MRUSummary(showhostnames)
try:
session = ntp.packet.ControlSession()
- session.openhost(sys.argv[1] if len(sys.argv) > 1 else "localhost")
+ session.openhost(arguments[0] if arguments else "localhost")
sysvars = session.readvar()
with OutputContext() as ctx:
while True:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3200e1d0a62d19d1474707d560b8629cc3945ab4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161215/5e1e6d26/attachment.html>
More information about the vc
mailing list