[Git][NTPsec/ntpsec][master] 2 commits: Improve the ntpmon status line.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Dec 10 04:38:01 UTC 2016


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


Commits:
acd0d5ab by Eric S. Raymond at 2016-12-09T22:29:30-05:00
Improve the ntpmon status line.

- - - - -
0014d865 by Eric S. Raymond at 2016-12-09T23:37:44-05:00
In ntpmon, show the server version in the status line.

- - - - -


1 changed file:

- ntpclients/ntpmon


Changes:

=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -28,9 +28,18 @@ except ImportError as e:
 
 stdscr = None
 
+def iso8601(t):
+    "ISO8601 string from Unix time, including fractional second."
+    return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(time.time()))
+
+
 def statline(_peerlist, _mrulist):
     "Generate a status line"
-    return ntp.util.stdversion()
+    # We don't use stdversion here because the presence of a date is confusing
+    leader = sysvars['version']
+    trailer = "Last update: %s" % iso8601(span.entries[0].last)
+    spacer = (peer_report.termwidth - len(leader) - len(trailer)) * " "
+    return leader + spacer + trailer
 
 class Fatal(Exception):
     "Unrecoverable error."
@@ -89,6 +98,7 @@ if __name__ == '__main__':
     try:
         session = ntp.packet.ControlSession()
         session.openhost(arguments[0] if arguments else "localhost")
+        sysvars = session.readvar()
         with OutputContext() as ctx:
             while True:
                 try:
@@ -122,13 +132,14 @@ if __name__ == '__main__':
                             continue
                         stdscr.addstr(peer_report.summary(session.rstatus,
                                                 variables, peer.associd))
-                    # The status line
-                    sl = statline(peer_report, mru_report)
-                    stdscr.addstr(sl + ((peer_report.termwidth - len(sl)) * " ") + "\n",
-                                  curses.A_REVERSE|curses.A_DIM)
+
                     # Now the MRU report
                     span = session.mrulist()
                     mru_report.now = time.time()
+
+                    # The status line
+                    sl = statline(peer_report, mru_report)
+                    stdscr.addstr(sl + "\n", curses.A_REVERSE|curses.A_DIM)
                     if span.entries:
                         stdscr.addstr(ntp.util.MRUSummary.header + "\n",
                                       curses.A_BOLD)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/f105623eab3da44008c78d5e6e9ecb5eccc00c90...0014d865229f47cd568052478418788c2b1f42b1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161210/390a726c/attachment.html>


More information about the vc mailing list