[Git][NTPsec/ntpsec][master] With commands in place, ntpmon options can be abolished.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Dec 13 15:58:12 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a6eb6bd6 by Eric S. Raymond at 2016-12-13T10:57:22-05:00
With commands in place, ntpmon options can be abolished.

- - - - -


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
@@ -4,7 +4,7 @@
 
 == Synopsis ==
 
-+ntpmon+ [-a | --all] [-n | --numeric] [-w | --wide] [hostname]
++ntpmon+ [hostname]
 
 == Description ==
 
@@ -23,20 +23,6 @@ watched and the (local) time at which it was last updated).
 
 ^C cleanly terminates the program.
 
-== Options ==
-
-Command line options are described following.
-
-+-a+, +--all+::
-  Show all hosts, not just reachable ones.
-+-n+, +--numeric+::
-  Output all host addresses in numeric format rather than
-  converting to the canonical host names.
-+-w+, +--wide+::
-  Wide mode: if the host name or IP Address doesn't fit, write the
-  full name/address and indent the next line so columns line up.
-  The default truncates the name or address.
-
 If no hostname is specified on the command line, localhost is monitored.
 
 == Commands ==
@@ -53,6 +39,8 @@ p:: Change peer display to default mode, showing refid
 
 q:: Cleanly terminate the program.
 
+s:: Show all hosts, not just reachable ones.
+
 w:: Toggle wide mode.
 
 x:: Cleanly terminate the program.


=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -62,34 +62,13 @@ class OutputContext:
         curses.endwin()
 
 usage = '''
-USAGE: ntpmon [-anw] [--all] [--numeric] [--wide] [host]
-  Flg Arg Option-Name    Description
-   -a no  all            Show all hosts, not just reachable ones.
-   -n no  numeric        numeric host addresses
-   -w no  wide           enable wide display of addresses
+USAGE: ntpmon [host]
 '''
 
 if __name__ == '__main__':
-    try:
-        (options, arguments) = getopt.getopt(sys.argv[1:],
-                                             "anw", ["all", "numeric", "wide"])
-    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 ("-a", "--all"):
-            showall = True
-        elif switch in ("-n", "--numeric"):
-            showhostnames = False
-        elif switch in ("-w", "--wide"):
-            wideremote = True
-
     poll_interval = 1
     peer_report = ntp.util.PeerSummary(displaymode="peers",
                                        pktversion=ntp.magic.NTP_VERSION,
@@ -100,7 +79,7 @@ if __name__ == '__main__':
     mru_report = ntp.util.MRUSummary(showhostnames)
     try:
         session = ntp.packet.ControlSession()
-        session.openhost(arguments[0] if arguments else "localhost")
+        session.openhost(sys.argv[1] if len(sys.argv) > 1 else "localhost")
         sysvars = session.readvar()
         with OutputContext() as ctx:
             while True:
@@ -162,15 +141,17 @@ if __name__ == '__main__':
                         raise SystemExit(0)
                     elif key == 'a':
                         peer_report.displaymode = 'apeers'
+                    elif key == 'n':
+                        peer_report.showhostnames = not peer_report.showhostnames
+                        mru_report.showhostnames = not mru_report.showhostnames
                     elif key == 'o':
                         peer_report.displaymode = 'opeers'
                     elif key == 'p':
                         peer_report.displaymode = 'peers'
+                    elif key == 's':
+                        showall = not showall
                     elif key == 'w':
                         peer_report.wideremote = not peer_report.wideremote
-                    elif key == 'n':
-                        peer_report.showhostnames = not peer_report.showhostnames
-                        mru_report.showhostnames = not mru_report.showhostnames
                 except curses.error:
                     pass
     except KeyboardInterrupt:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a6eb6bd6c015627b1455aacab48d8d53f45fa056
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161213/2cbfcfed/attachment.html>


More information about the vc mailing list