]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix ISC-Bugs 45340: Statschannel XSL for zones, Traffic
authorTimothe Litt <litt@acm.org>
Tue, 14 May 2019 20:06:01 +0000 (16:06 -0400)
committerMark Andrews <marka@isc.org>
Thu, 27 Jun 2019 03:25:01 +0000 (13:25 +1000)
In ISC-Bugs 45340, I wrote:

The Statistics channel offers links to Zones and Traffic.
Both produce valid data, but display as blank pages with
a web browser.

Zones never had XSL (I provided the original
implementation, but punted on the XSL).

Traffic has XSL, but it wasn't updated to reflect the
split between IPv4 and IPv6 data.

I've picked up enough XSL to fix my original omission,
and as penance for my sloth, fixed the Traffic bug as well.

(cherry picked from commit 96f0bbd4d51e543881989a6811a82258127a05b5)

bin/named/bind9.xsl

index 8668482915a77467412919fc88205c95db761520..863995311f5e8efb3ec3ff18230c27508d2d66f7 100644 (file)
   <xsl:template match="statistics[@version=&quot;3.8&quot;]">
     <html>
       <head>
+        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
+        <script type="text/javascript">
+          $(function($) {
+              var wid=0;
+              $('table.zones').each(function(i) { if( $(this).width() > wid ) wid = $(this).width(); return true; });
+              $('table.zones').css('min-width', wid );
+          });
+        </script>
+
         <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
           <!-- Non Mozilla specific markup -->
           <script type="text/javascript" src="https://www.google.com/jsapi"/>
       background-color: rgb(1,169,206);
       color: #ffffff;
      }
+     table.zones {
+       border: 1px solid grey;
+     }
+     table.zones td {
+       text-align: right;
+       font-family: monospace;
+     }
+     table.zones td:nth-child(2) {
+       text-align: center;
+     }
+     table.zones td:nth-child(3) {
+       text-align: left;
+     }
+     table.zones tr:hover{
+      background-color: #99ddff;
+     }
 
      td, th {
       padding-right: 5px;
           </tr>
         </table>
         <br/>
+        <xsl:if test="views/view/zones/zone">
+          <h2>Configured zones</h2>
+          <xsl:for-each select="views/view">
+            <h3>View <xsl:value-of select="@name"/></h3>
+            <table class="zones">
+              <thead><tr><th>Zone</th><th>Class</th><th>Type</th><th>Serial</th></tr></thead>
+              <tbody>
+                <xsl:for-each select="zones/zone">
+                  <xsl:variable name="css-class15">
+                    <xsl:choose>
+                      <xsl:when test="position() mod 2 = 0">even</xsl:when>
+                      <xsl:otherwise>odd</xsl:otherwise>
+                    </xsl:choose>
+                  </xsl:variable>
+                  <tr class="{$css-class15}">
+                      <td><xsl:value-of select="@name"/></td>
+                      <td><xsl:value-of select="@rdataclass"/></td>
+                      <td><xsl:value-of select="type"/></td>
+                      <td><xsl:value-of select="serial"/></td></tr>
+                </xsl:for-each>
+              </tbody>
+            </table>
+          </xsl:for-each>
+        </xsl:if>
         <xsl:if test="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0]">
           <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
             <h2>Incoming Requests by DNS Opcode</h2>
             <br/>
           </xsl:if>
         </xsl:for-each>
-        <xsl:if test="traffic/udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0] or traffic/udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0] or traffic/tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0] or traffic/tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
+        <xsl:if test="traffic//udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0] or traffic//udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0] or traffic//tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0] or traffic//tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
           <h2>Traffic Size Statistics</h2>
         </xsl:if>
-        <xsl:if test="traffic/udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
+        <xsl:if test="traffic//udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
           <h4>UDP Requests Received</h4>
           <table class="counters">
-            <xsl:for-each select="traffic/udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
+            <xsl:for-each select="traffic//udp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
               <xsl:variable name="css-class7">
                 <xsl:choose>
                   <xsl:when test="position() mod 2 = 0">even</xsl:when>
                 </xsl:choose>
               </xsl:variable>
               <tr class="{$css-class7}">
+                <th><xsl:value-of select="local-name(../../..)"/></th>
                 <th>
                   <xsl:value-of select="@name"/>
                 </th>
           </table>
           <br/>
         </xsl:if>
-        <xsl:if test="traffic/udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
+        <xsl:if test="traffic//udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
           <h4>UDP Responses Sent</h4>
           <table class="counters">
-            <xsl:for-each select="traffic/udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
+            <xsl:for-each select="traffic//udp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
               <xsl:variable name="css-class7">
                 <xsl:choose>
                   <xsl:when test="position() mod 2 = 0">even</xsl:when>
                 </xsl:choose>
               </xsl:variable>
               <tr class="{$css-class7}">
+                <th><xsl:value-of select="local-name(../../..)"/></th>
                 <th>
                   <xsl:value-of select="@name"/>
                 </th>
           </table>
           <br/>
         </xsl:if>
-        <xsl:if test="traffic/tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
+        <xsl:if test="traffic//tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
           <h4>TCP Requests Received</h4>
           <table class="counters">
-            <xsl:for-each select="traffic/tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
+            <xsl:for-each select="traffic//tcp/counters[@type=&quot;request-size&quot;]/counter[.&gt;0]">
               <xsl:variable name="css-class7">
                 <xsl:choose>
                   <xsl:when test="position() mod 2 = 0">even</xsl:when>
                 </xsl:choose>
               </xsl:variable>
               <tr class="{$css-class7}">
+                <th><xsl:value-of select="local-name(../../..)"/></th>
                 <th>
                   <xsl:value-of select="@name"/>
                 </th>
           </table>
           <br/>
         </xsl:if>
-        <xsl:if test="traffic/tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
+        <xsl:if test="traffic//tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
           <h4>TCP Responses Sent</h4>
           <table class="counters">
-            <xsl:for-each select="traffic/tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
+            <xsl:for-each select="traffic//tcp/counters[@type=&quot;response-size&quot;]/counter[.&gt;0]">
               <xsl:variable name="css-class7">
                 <xsl:choose>
                   <xsl:when test="position() mod 2 = 0">even</xsl:when>
                 </xsl:choose>
               </xsl:variable>
               <tr class="{$css-class7}">
+                <th><xsl:value-of select="local-name(../../..)"/></th>
                 <th>
                   <xsl:value-of select="@name"/>
                 </th>