[Git][NTPsec/ntpsec][master] In pyntpq, upper-level machinery for ifstats and reslist.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Nov 3 11:05:51 UTC 2016


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


Commits:
49a55502 by Eric S. Raymond at 2016-11-03T07:05:06-04:00
In pyntpq, upper-level machinery for ifstats and reslist.

- - - - -


4 changed files:

- docs/mode6.txt
- include/ntp.h
- ntpq/pyntpq
- pylib/packet.py


Changes:

=====================================
docs/mode6.txt
=====================================
--- a/docs/mode6.txt
+++ b/docs/mode6.txt
@@ -481,7 +481,7 @@ First, the password entered to use the signing key, then the request
 header fields, then the payload.
 
 The cryptographic hash is normally MD5, but if ntpd is built with
-OpenSSL support it is possible to use and generare SHA1 keys as well.
+OpenSSL support it is possible to use and generate SHA1 keys as well.
 
 '''''
 


=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -195,7 +195,8 @@ typedef struct __endpt {
 } endpt;
 
 /*
- * Flags for interfaces
+ * Flags for interfaces. Do not change these casually as they will be visible
+ * in Mode 6 ifstats reports. 
  */
 #define INT_UP		0x001	/* Interface is up */
 #define	INT_PPP		0x002	/* Point-to-point interface */


=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -1205,11 +1205,11 @@ usage: config_from_file <configuration filename>
         try:
             span = self.session.mrulist(mruhook)
             if not self.rawmode:
-                oracle = MRUSummary(interpreter.showhostnames)
+                formatter = MRUSummary(interpreter.showhostnames)
                 self.say(MRUSummary.header + "\n")
                 self.say(("=" * MRUSummary.width) + "\n")
                 for entry in span.entries:
-                    self.say(oracle.summary(entry) + "\n")
+                    self.say(formatter.summary(entry) + "\n")
         except Mode6Exception as e:
             # Giving up after 8 restarts from the beginning.
             # With high-traffic NTP servers, this can occur if the
@@ -1227,6 +1227,12 @@ usage: mrulist [ tag=value ] [ tag=value ] [ tag=value ] [ tag=value ]
         "show statistics for each local address ntpd is using"
         try:
             self.session.password()
+            entries = self.session.ifstat()
+            formatter = IfstatSummary()
+            self.say(IfstatSummary.header)
+            self.say(("=" * IfstatSummary.width) + "\n")
+            for entry in entries:
+                self.say(formatter.summary(entry) + "\n")
         except Mode6Exception as e:
             self.warn(e.message + "\n")
             return
@@ -1242,7 +1248,12 @@ usage: ifstats
         "show ntpd access control list"
         try:
             self.session.password()
-            self.session.reslist()
+            entries = self.session.reslist()
+            formatter = ReslistSummary()
+            self.say(ReslistSummary.header)
+            self.say(("=" * ReslistSummary.width) + "\n")
+            for entry in entries:
+                self.say(formatter.summary(entry) + "\n")
         except Mode6Exception as e:
             self.warn(e.message + "\n")
             return


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -954,9 +954,17 @@ class Mode6Session:
 
         return span
 
+    def __ordlist(self, listtype):
+        "Retrieve ordered-list data."
+        self.doquery(opcode=CTL_OP_READ_ORDLIST_A, qdata=listtype, auth=True)
+        return self.response
+
     def reslist(self):
         "Retrieve reslist data."
-        self.doquery(opcode=CTL_OP_READ_ORDLIST_A,
-                     qdata="addr_restrictions", auth=True)
-        print(self.response)
+        print(self.ordlist("addr_restrictions"))
+
+    def ifstats(self):
+        "Retrieve ifstats data."
+        print(self.ordlist("ifstats"))
+
 # end



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/49a55502eb4522af1cdd44820476cc20f2332af0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161103/7cfc40ec/attachment.html>


More information about the vc mailing list