[Git][NTPsec/ntpsec][master] 2 commits: Add MRU-list-only mode to ntpmon.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Dec 19 11:30:07 UTC 2016


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


Commits:
ed0e247a by Eric S. Raymond at 2016-12-19T06:04:19-05:00
Add MRU-list-only mode to ntpmon.

- - - - -
9ecd5e43 by Eric S. Raymond at 2016-12-19T06:29:53-05:00
Belt-and-suspenders patch to ntpmon.

- - - - -


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
@@ -45,6 +45,8 @@ j:: Select next peer (in select mode); arrow down also works.
 
 k:: Select previous peer (in select mode); arrow up also works.
 
+m:: Toggle MRUlist-only mode; suppresses peer display when on.
+
 n:: Toggle display of hostnames (vs. IP addresses).
 
 o:: Change peer display to opeers mode, showing destination address.


=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -7,6 +7,7 @@ Any keystroke causes a poll and update. Keystroke commands:
 'd': Toggle detail mode (some peer will be reverse-video highlighted when on).
 'j': Select next peer (in select mode); arrow down also works.
 'k': Select previous peer (in select mode); arrow up also works.
+'m': Disable peers display, showing only MRU list
 'n': Toggle display of hostnames (vs. IP addresses).
 'o': Change peer display to opeers mode, showing destination address.
 'p': Change peer display to default mode, showing refid.
@@ -127,6 +128,8 @@ if __name__ == '__main__':
     showhostnames = True
     wideremote = False
     showall = True
+    showpeers = True
+    nyquist = 1
 
     for (switch, val) in options:
         if switch in ("-V", "--version"):
@@ -147,7 +150,6 @@ if __name__ == '__main__':
         session = ntp.packet.ControlSession()
         session.openhost(arguments[0] if arguments else "localhost")
         sysvars = session.readvar()
-        nyquist = 12 ##### FIXME (undefined below)
         with OutputContext() as ctx:
             while True:
                 stdscr.clear()
@@ -158,14 +160,18 @@ if __name__ == '__main__':
                     stdscr.refresh()
                     stdscr.timeout(-1)
                 else:
-                    try:
-                        peers = session.readstat()
-                    except ntp.packet.ControlException as e:
-                        raise Fatal(e.message)
-                    except IOError as e:
-                        raise Fatal(e.strerror)
-                    stdscr.addstr(peer_report.header() + "\n", curses.A_BOLD)
-                    if len(peers) == 0:
+                    if showpeers:
+                        try:
+                            peers = session.readstat()
+                        except ntp.packet.ControlException as e:
+                            raise Fatal(e.message)
+                        except IOError as e:
+                            raise Fatal(e.strerror)
+                        stdscr.addstr(peer_report.header() + "\n", curses.A_BOLD)
+                    else:
+                        peer_report.polls = [1]	# Kluge!
+                        peers = []
+                    if showpeers and len(peers) == 0:
                         raise Fatal("no peers reported")
                     try:
                         for (i, peer) in enumerate(peers):
@@ -245,6 +251,8 @@ if __name__ == '__main__':
                             selected = 0
                         selectmode = not selectmode
                         detailmode = not detailmode
+                    elif key == 'm':
+                        showpeers = not showpeers
                     elif key == 'n':
                         peer_report.showhostnames = not peer_report.showhostnames
                         mru_report.showhostnames = not mru_report.showhostnames



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/62d689253e3a62f4b06ada30692ede57338fdfa0...9ecd5e433469e9da4dc24d426b6f53df91bd150c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161219/d642e6f7/attachment.html>


More information about the vc mailing list