[v9_9] stats improvements (newstats only)

3699.  [bug]           Improvements to statistics channel XSL stylesheet:
                       the stylesheet can now be cached by the browser;
                       section headers are omitted from the stats display
                       when there is no data in those sections to be
                       displayed; counters are now right-justified for
                       easier readability. [RT #35117]
This commit is contained in:
Evan Hunt
2014-01-09 18:41:21 -08:00
parent d1a389bdac
commit 712839e4d2
9 changed files with 981 additions and 641 deletions
+8
View File
@@ -1,3 +1,11 @@
3699. [bug] Improvements to statistics channel XSL stylesheet:
the stylesheet can now be cached by the browser;
section headers are omitted from the stats display
when there is no data in those sections to be
displayed; counters are now right-justified for
easier readability. (Only available with
configure --enable-newstats.) [RT #35117]
3698. [cleanup] Replaced all uses of memcpy() with memmove().
[RT #35120]
+622 -504
View File
File diff suppressed because it is too large Load Diff
+183 -62
View File
@@ -5,7 +5,7 @@
static char xslmsg[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!--\n"
" - Copyright (C) 2006-2009 Internet Systems Consortium, Inc. (\"ISC\")\n"
" - Copyright (C) 2012, 2013 Internet Systems Consortium, Inc. (\"ISC\")\n"
" -\n"
" - Permission to use, copy, modify, and/or distribute this software for any\n"
" - purpose with or without fee is hereby granted, provided that the above\n"
@@ -19,63 +19,67 @@ static char xslmsg[] =
" - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n"
" - PERFORMANCE OF THIS SOFTWARE.\n"
"-->\n"
"\n"
"<!-- $Id$ -->\n"
"\n"
"<!-- \045Id: bind9.xsl,v 1.21 2009/01/27 23:47:54 tbox Exp \045 -->\n"
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns=\"http://www.w3.org/1999/xhtml\" version=\"1.0\">\n"
" <xsl:output method=\"html\" indent=\"yes\" version=\"4.0\"/>\n"
" <xsl:template match=\"statistics[@version=&quot;3.0&quot;]\">\n"
" <xsl:template match=\"statistics[@version=&quot;3.3&quot;]\">\n"
" <html>\n"
" <head>\n"
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
" <!-- Non Mozilla specific markup -->\n"
" <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"/>\n"
" <script type=\"text/javascript\">\n"
" \n"
"\n"
" google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});\n"
" google.setOnLoadCallback(loadGraphs);\n"
"\n"
" var graphs=[];\n"
" \n"
" function drawChart(chart_title,target,data) {\n"
"\n"
" function drawChart(chart_title,target,style,data) {\n"
" var data = google.visualization.arrayToDataTable(data);\n"
"\n"
" var options = {\n"
" title: chart_title\n"
" };\n"
" \n"
" var chart = new google.visualization.BarChart(document.getElementById(target));\n"
"\n"
" var chart;\n"
" if (style == \"barchart\") {\n"
" chart = new google.visualization.BarChart(document.getElementById(target));\n"
" chart.draw(data, options);\n"
" } else if (style == \"piechart\") {\n"
" chart = new google.visualization.PieChart(document.getElementById(target));\n"
" chart.draw(data, options);\n"
" }\n"
" \n"
" }\n"
"\n"
" function loadGraphs(){\n"
" //alert(\"here we are!\");\n"
" var g;\n"
" \n"
" // Server Incoming query Types\n"
"\n"
" while(g = graphs.shift()){\n"
" // alert(\"going for: \" + g.target);\n"
" if(g.data.length > 1){\n"
" drawChart(g.title,g.target,g.data);\n"
" drawChart(g.title,g.target,g.style,g.data);\n"
" }\n"
" }\n"
" }\n"
" \n"
" // Server Incoming Queries Types \n"
"\n"
" // Server Incoming Query Types \n"
" graphs.push({\n"
" 'title' : \"Server Incoming Query Types\",\n"
" 'target': 'chart_incoming_qtypes',\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;qtype&quot;]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
"\n"
"\n"
" // Server Incoming Requests \n"
" // Server Incoming Requests by opcode\n"
" graphs.push({\n"
" 'title' : \"Server Incoming Requests\",\n"
" 'target': 'chart_incoming_requests',\n"
" 'data': [['Requests','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;opcode&quot;]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]});\n"
" \n"
" \n"
" \n"
" \n"
" 'title' : \"Server Incoming Requests by DNS Opcode\",\n"
" 'target': 'chart_incoming_opcodes',\n"
" 'style': 'barchart',\n"
" 'data': [['Opcode','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0 or substring(@name,1,3) != 'RES']\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]});\n"
" </script>\n"
" </xsl:if>\n"
" <style type=\"text/css\">\n"
@@ -85,15 +89,15 @@ static char xslmsg[] =
" color: #000000;\n"
" font-size: 10pt;\n"
" }\n"
" \n"
"\n"
" .odd{\n"
" background-color: #f0f0f0;\n"
" }\n"
" \n"
"\n"
" .even{\n"
" background-color: #ffffff;\n"
" }\n"
" \n"
"\n"
" p.footer{\n"
" font-style:italic;\n"
" color: grey;\n"
@@ -108,21 +112,101 @@ static char xslmsg[] =
" border: 1px solid grey;\n"
" width: 500px;\n"
" }\n"
" \n"
" table.counters th {\n"
" text-align: center;\n"
" text-align: right;\n"
" border: 1px solid grey;\n"
" width: 120px;\n"
" width: 150px;\n"
" }\n"
" table.counters td{\n"
" text-align:center;\n"
" \n"
" table.counters td {\n"
" text-align: right;\n"
" font-family: monospace;\n"
" }\n"
" \n"
" table.counters tr:hover{\n"
" background-color: #99ddff;\n"
" }\n"
" \n"
"\n"
" table.info {\n"
" border: 1px solid grey;\n"
" width: 500px;\n"
" }\n"
" table.info th {\n"
" text-align: center;\n"
" border: 1px solid grey;\n"
" width: 150px;\n"
" }\n"
" table.info td {\n"
" text-align: center;\n"
" }\n"
" table.info tr:hover{\n"
" background-color: #99ddff;\n"
" }\n"
"\n"
" table.tasks {\n"
" border: 1px solid grey;\n"
" width: 500px;\n"
" }\n"
" table.tasks th {\n"
" text-align: center;\n"
" border: 1px solid grey;\n"
" width: 150px;\n"
" }\n"
" table.tasks td {\n"
" text-align: right;\n"
" font-family: monospace;\n"
" }\n"
" table.tasks td:nth-child(2) {\n"
" text-align: center;\n"
" }\n"
" table.tasks td:nth-child(4) {\n"
" text-align: center;\n"
" }\n"
" table.tasks tr:hover{\n"
" background-color: #99ddff;\n"
" }\n"
"\n"
" table.netstat {\n"
" border: 1px solid grey;\n"
" width: 500px;\n"
" }\n"
" table.netstat th {\n"
" text-align: center;\n"
" border: 1px solid grey;\n"
" width: 150px;\n"
" }\n"
" table.netstat td {\n"
" text-align: center;\n"
" }\n"
" table.netstat td:nth-child(4) {\n"
" text-align: right;\n"
" font-family: monospace;\n"
" }\n"
" table.netstat td:nth-child(7) {\n"
" text-align: left;\n"
" }\n"
" table.netstat tr:hover{\n"
" background-color: #99ddff;\n"
" }\n"
"\n"
" table.mctx {\n"
" border: 1px solid grey;\n"
" width: 500px;\n"
" }\n"
" table.mctx th {\n"
" text-align: center;\n"
" border: 1px solid grey;\n"
" }\n"
" table.mctx td {\n"
" text-align: right;\n"
" font-family: monospace;\n"
" }\n"
" table.mctx td:nth-child(-n+2) {\n"
" text-align: left;\n"
" width: 100px;\n"
" }\n"
" table.mctx tr:hover{\n"
" background-color: #99ddff;\n"
" }\n"
"\n"
" .totals {\n"
" background-color: rgb(1,169,206);\n"
" color: #ffffff;\n"
@@ -162,20 +246,18 @@ static char xslmsg[] =
" width:500px;\n"
" text-align:center;\n"
" }\n"
" \n"
"\n"
" h3 {\n"
" color: #444444;\n"
" font-size: 12pt;\n"
" width:500px;\n"
" text-align:center;\n"
" \n"
" }\n"
" h4 {\n"
" color: rgb(1,169,206);\n"
" font-size: 10pt;\n"
" width:500px;\n"
" text-align:center;\n"
" \n"
" }\n"
"\n"
" .pie {\n"
@@ -192,7 +274,7 @@ static char xslmsg[] =
" </div>\n"
" <hr/>\n"
" <h2>Server Times</h2>\n"
" <table class=\"counters\">\n"
" <table class=\"info\">\n"
" <tr>\n"
" <th>Boot time:</th>\n"
" <td>\n"
@@ -200,20 +282,23 @@ static char xslmsg[] =
" </td>\n"
" </tr>\n"
" <tr>\n"
" <th>Sample time:</th>\n"
" <th>Current time:</th>\n"
" <td>\n"
" <xsl:value-of select=\"server/current-time\"/>\n"
" </td>\n"
" </tr>\n"
" </table>\n"
" <br/>\n"
" <h2>Incoming Requests</h2>\n"
" <xsl:if test=\"server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0]\">\n"
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
" <h2>Incoming Requests by DNS Opcode</h2>\n"
" <!-- Non Mozilla specific markup -->\n"
" <div class=\"pie\" id=\"chart_incoming_requests\">[graph incoming requests]</div>\n"
" <div class=\"pie\" id=\"chart_incoming_opcodes\">\n"
" [cannot display chart]\n"
" </div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;opcode&quot;]/counter\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0 or substring(@name,1,3) != 'RES']\">\n"
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
" <tr>\n"
" <th>\n"
@@ -232,10 +317,14 @@ static char xslmsg[] =
" </tr>\n"
" </table>\n"
" <br/>\n"
" <h3>Incoming Queries by Type</h3>\n"
" </xsl:if>\n"
" <xsl:if test=\"server/counters[@type=&quot;qtype&quot;]/counter\">\n"
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
" <!-- Non Mozilla specific markup -->\n"
" <div class=\"pie\" id=\"chart_incoming_qtypes\">[graph incoming qtypes]</div>\n"
" <h3>Incoming Queries by Query Type</h3>\n"
" <div class=\"pie\" id=\"chart_incoming_qtypes\">\n"
" [cannot display chart]\n"
" </div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;qtype&quot;]/counter\">\n"
@@ -263,6 +352,8 @@ static char xslmsg[] =
" </tr>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"views/view[count(counters[@type=&quot;resqtype&quot;]/counter) &gt; 0]\">\n"
" <h2>Outgoing Queries per view</h2>\n"
" <xsl:for-each select=\"views/view[count(counters[@type=&quot;resqtype&quot;]/counter) &gt; 0]\">\n"
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
@@ -270,16 +361,16 @@ static char xslmsg[] =
" <!-- Non Mozilla specific markup -->\n"
" <script type=\"text/javascript\">\n"
" graphs.push({\n"
" 'title': \"Outgoing queries for view: <xsl:value-of select=\"@name\"/>\",\n"
" 'title': \"Outgoing Queries for view: <xsl:value-of select=\"@name\"/>\",\n"
" 'target': 'chart_outgoing_queries_view_<xsl:value-of select=\"@name\"/>',\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type=&quot;resqtype&quot;]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
" \n"
" </script>\n"
" <xsl:variable name=\"target\">\n"
" <xsl:value-of select=\"@name\"/>\n"
" </xsl:variable>\n"
" <div class=\"pie\" id=\"chart_outgoing_queries_view_{$target}\"/>\n"
" <div class=\"pie\" id=\"chart_outgoing_queries_view_{$target}\">[no data to display]</div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"counters[@type=&quot;resqtype&quot;]/counter\">\n"
@@ -302,18 +393,20 @@ static char xslmsg[] =
" </table>\n"
" <br/>\n"
" </xsl:for-each>\n"
" </xsl:if>\n"
" <xsl:if test=\"server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]\">\n"
" <h2>Server Statistics</h2>\n"
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
" <!-- Non Mozilla specific markup -->\n"
" <script type=\"text/javascript\">\n"
" graphs.push({\n"
" 'title' : \"Server Response Types\",\n"
" 'title' : \"Server Counters\",\n"
" 'target': 'chart_server_nsstat_restype',\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
" \n"
" </script>\n"
" <div class=\"pie\" id=\"chart_server_nsstat_restype\"/>\n"
" <div class=\"pie\" id=\"chart_server_nsstat_restype\">[no data to display]</div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]\">\n"
@@ -335,18 +428,20 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" <h2>Zone Maintenance Statistics</h2>\n"
" </xsl:if>\n"
" <xsl:if test=\"server/counters[@type=&quot;zonestat&quot;]/counter[.&gt;0]\">\n"
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
" <h2>Zone Maintenance Statistics</h2>\n"
" <script type=\"text/javascript\">\n"
" graphs.push({\n"
" 'title' : \"Zone Maintenance Stats\",\n"
" 'target': 'chart_server_zone_maint',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;zonestat&quot;]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type=&quot;zonestat&quot;]/counter[.&gt;0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
"\n"
" </script>\n"
" <!-- Non Mozilla specific markup -->\n"
" <div class=\"pie\" id=\"chart_server_zone_maint\"/>\n"
" <div class=\"pie\" id=\"chart_server_zone_maint\">[no data to display]</div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;zonestat&quot;]/counter\">\n"
@@ -367,9 +462,11 @@ static char xslmsg[] =
" </tr>\n"
" </xsl:for-each>\n"
" </table>\n"
" </xsl:if>\n"
" <xsl:if test=\"server/counters[@type=&quot;resstat&quot;]/counter[.&gt;0]\">\n"
" <h2>Resolver Statistics (Common)</h2>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;restat&quot;]/counter\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;resstat&quot;]/counter\">\n"
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
" <xsl:variable name=\"css-class4\">\n"
" <xsl:choose>\n"
@@ -387,7 +484,9 @@ static char xslmsg[] =
" </tr>\n"
" </xsl:for-each>\n"
" </table>\n"
" </xsl:if>\n"
" <xsl:for-each select=\"views/view\">\n"
" <xsl:if test=\"counters[@type=&quot;resstats&quot;]/counter[.&gt;0]\">\n"
" <h3>Resolver Statistics for View <xsl:value-of select=\"@name\"/></h3>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"counters[@type=&quot;resstats&quot;]/counter[.&gt;0]\">\n"
@@ -408,9 +507,12 @@ static char xslmsg[] =
" </tr>\n"
" </xsl:for-each>\n"
" </table>\n"
" </xsl:if>\n"
" </xsl:for-each>\n"
" <h3>Cache DB RRsets for View <xsl:value-of select=\"@name\"/></h3>\n"
"\n"
" <xsl:for-each select=\"views/view\">\n"
" <xsl:if test=\"cache/rrset\">\n"
" <h3>Cache DB RRsets for View <xsl:value-of select=\"@name\"/></h3>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"cache/rrset\">\n"
" <xsl:variable name=\"css-class6\">\n"
@@ -430,7 +532,10 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" </xsl:for-each>\n"
"\n"
" <xsl:if test=\"server/counters[@type=&quot;sockstat&quot;]/counter[.&gt;0]\">\n"
" <h2>Socket I/O Statistics</h2>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"server/counters[@type=&quot;sockstat&quot;]/counter[.&gt;0]\">\n"
@@ -451,7 +556,8 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"views/view[zones/zone/counters[@type=&quot;rcode&quot;]/counter &gt;0]\">\n"
" <h2>Response Codes per view/zone</h2>\n"
" <xsl:for-each select=\"views/view[zones/zone/counters[@type=&quot;rcode&quot;]/counter &gt;0]\">\n"
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
@@ -467,6 +573,7 @@ static char xslmsg[] =
" graphs.push({\n"
" 'title': \"Response Codes for zone <xsl:value-of select=\"@name\"/>\",\n"
" 'target': 'chart_rescode_<xsl:value-of select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type=&quot;rcode&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
"\n"
@@ -474,7 +581,7 @@ static char xslmsg[] =
" <xsl:variable name=\"target\">\n"
" <xsl:value-of select=\"@name\"/>\n"
" </xsl:variable>\n"
" <div class=\"pie\" id=\"chart_rescode_{$thisview}_{$target}\"/>\n"
" <div class=\"pie\" id=\"chart_rescode_{$thisview}_{$target}\">[no data to display]</div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"counters[@type=&quot;rcode&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]\">\n"
@@ -498,6 +605,8 @@ static char xslmsg[] =
" </xsl:if>\n"
" </xsl:for-each>\n"
" </xsl:for-each>\n"
" </xsl:if>\n"
" <xsl:if test=\"views/view[zones/zone/counters[@type=&quot;qtype&quot;]/counter &gt;0]\">\n"
" <h2>Received QTYPES per view/zone</h2>\n"
" <xsl:for-each select=\"views/view[zones/zone/counters[@type=&quot;qtype&quot;]/counter &gt;0]\">\n"
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
@@ -513,6 +622,7 @@ static char xslmsg[] =
" graphs.push({\n"
" 'title': \"Query Types for zone <xsl:value-of select=\"@name\"/>\",\n"
" 'target': 'chart_qtype_<xsl:value-of select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
" 'style': 'barchart',\n"
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type=&quot;qtype&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
" });\n"
"\n"
@@ -520,7 +630,7 @@ static char xslmsg[] =
" <xsl:variable name=\"target\">\n"
" <xsl:value-of select=\"@name\"/>\n"
" </xsl:variable>\n"
" <div class=\"pie\" id=\"chart_qtype_{$thisview2}_{$target}\"/>\n"
" <div class=\"pie\" id=\"chart_qtype_{$thisview2}_{$target}\">[no data to display]</div>\n"
" </xsl:if>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"counters[@type=&quot;qtype&quot;]/counter\">\n"
@@ -544,8 +654,10 @@ static char xslmsg[] =
" </xsl:if>\n"
" </xsl:for-each>\n"
" </xsl:for-each>\n"
" </xsl:if>\n"
" <xsl:if test=\"socketmgr/sockets/socket\">\n"
" <h2>Network Status</h2>\n"
" <table class=\"counters\">\n"
" <table class=\"netstat\">\n"
" <tr>\n"
" <th>ID</th>\n"
" <th>Name</th>\n"
@@ -591,6 +703,8 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"taskmgr/thread-model/type\">\n"
" <h2>Task Manager Configuration</h2>\n"
" <table class=\"counters\">\n"
" <tr>\n"
@@ -619,8 +733,10 @@ static char xslmsg[] =
" </tr>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"taskmgr/tasks/task\">\n"
" <h2>Tasks</h2>\n"
" <table class=\"counters\">\n"
" <table class=\"tasks\">\n"
" <tr>\n"
" <th>ID</th>\n"
" <th>Name</th>\n"
@@ -656,6 +772,8 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"memory/summary\">\n"
" <h2>Memory Usage Summary</h2>\n"
" <table class=\"counters\">\n"
" <xsl:for-each select=\"memory/summary/*\">\n"
@@ -676,8 +794,10 @@ static char xslmsg[] =
" </xsl:for-each>\n"
" </table>\n"
" <br/>\n"
" </xsl:if>\n"
" <xsl:if test=\"memory/contexts/context\">\n"
" <h2>Memory Contexts</h2>\n"
" <table class=\"counters\">\n"
" <table class=\"mctx\">\n"
" <tr>\n"
" <th>ID</th>\n"
" <th>Name</th>\n"
@@ -732,6 +852,7 @@ static char xslmsg[] =
" </tr>\n"
" </xsl:for-each>\n"
" </table>\n"
" </xsl:if>\n"
" <hr/>\n"
" <p class=\"footer\">Internet Systems Consortium Inc.<br/><a href=\"http://www.isc.org\">http://www.isc.org</a></p>\n"
" </body>\n"
+54 -17
View File
@@ -1057,7 +1057,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
ISC_XMLCHAR "type=\"text/xsl\" href=\"/bind9.ver3.xsl\""));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "statistics"));
TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "version",
ISC_XMLCHAR "3.0"));
ISC_XMLCHAR "3.3"));
/* Set common fields for statistics dump */
dumparg.type = statsformat_xml;
@@ -1093,9 +1093,9 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
if (dumparg.result != ISC_R_SUCCESS)
goto error;
}
else fprintf(stderr, "WTF WHERE'S RESQUERYRSTATS\n");
TRY0(xmlTextWriterEndElement(writer));
/* <resstats> */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
ISC_XMLCHAR "resstats"));
@@ -1109,7 +1109,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
if (result != ISC_R_SUCCESS)
goto error;
}
TRY0(xmlTextWriterEndElement(writer)); /* </resstats> */
TRY0(xmlTextWriterEndElement(writer));
cacherrstats = dns_db_getrrsetstats(view->cachedb);
if (cacherrstats != NULL) {
@@ -1155,8 +1155,8 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
ISC_XMLCHAR "opcode"));
dns_opcodestats_dump(server->opcodestats, opcodestat_dump, &dumparg,
0);
dns_opcodestats_dump(server->opcodestats, opcodestat_dump, &dumparg,
ISC_STATSDUMP_VERBOSE);
if (dumparg.result != ISC_R_SUCCESS)
goto error;
@@ -1370,10 +1370,10 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "server"));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "boot-time"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR boottime));
TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterEndElement(writer)); /* boot-time */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "current-time"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR nowstr));
TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterEndElement(writer)); /* current-time */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "requests"));
dumparg.result = ISC_R_SUCCESS;
@@ -1461,7 +1461,8 @@ wrap_xmlfree(isc_buffer_t *buffer, void *arg) {
}
static isc_result_t
render_index(const char *url, const char *querystring, void *arg,
render_index(const char *url, isc_httpdurl_t *urlinfo,
const char *querystring, const char *headers, void *arg,
unsigned int *retcode, const char **retmsg, const char **mimetype,
isc_buffer_t *b, isc_httpdfree_t **freecb,
void **freecb_args)
@@ -1472,7 +1473,9 @@ render_index(const char *url, const char *querystring, void *arg,
isc_result_t result;
UNUSED(url);
UNUSED(urlinfo);
UNUSED(querystring);
UNUSED(headers);
result = generatexml(server, &msglen, &msg);
@@ -1495,22 +1498,56 @@ render_index(const char *url, const char *querystring, void *arg,
#endif /* HAVE_LIBXML2 */
static isc_result_t
render_xsl(const char *url, const char *querystring, void *args,
unsigned int *retcode, const char **retmsg, const char **mimetype,
isc_buffer_t *b, isc_httpdfree_t **freecb,
void **freecb_args)
render_xsl(const char *url, isc_httpdurl_t *urlinfo,
const char *querystring, const char *headers,
void *args, unsigned int *retcode, const char **retmsg,
const char **mimetype, isc_buffer_t *b,
isc_httpdfree_t **freecb, void **freecb_args)
{
isc_result_t result;
UNUSED(url);
UNUSED(querystring);
UNUSED(args);
*retcode = 200;
*retmsg = "OK";
*mimetype = "text/xslt+xml";
isc_buffer_reinit(b, xslmsg, strlen(xslmsg));
isc_buffer_add(b, strlen(xslmsg));
*freecb = NULL;
*freecb_args = NULL;
*mimetype = "text/xslt+xml";
if (urlinfo->isstatic) {
isc_time_t when;
char *p = strcasestr(headers, "If-Modified-Since: ");
if (p != NULL) {
time_t t1, t2;
p += strlen("If-Modified-Since: ");
result = isc_time_parsehttptimestamp(p, &when);
if (result != ISC_R_SUCCESS)
goto send;
result = isc_time_secondsastimet(&when, &t1);
if (result != ISC_R_SUCCESS)
goto send;
result = isc_time_secondsastimet(&urlinfo->loadtime,
&t2);
if (result != ISC_R_SUCCESS)
goto send;
if (t1 < t2)
goto send;
*retcode = 304;
*retmsg = "Not modified";
return (ISC_R_SUCCESS);
}
}
send:
*retcode = 200;
*retmsg = "OK";
isc_buffer_reinit(b, xslmsg, strlen(xslmsg));
isc_buffer_add(b, strlen(xslmsg));
return (ISC_R_SUCCESS);
}
+62 -58
View File
@@ -26,6 +26,7 @@
#include <isc/socket.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
#include <isc/util.h>
#include <string.h>
@@ -58,20 +59,6 @@
#define HTTP_SENDGROW 1024
#define HTTP_SEND_MAXLEN 10240
/*%
* HTTP urls. These are the URLs we manage, and the function to call to
* provide the data for it. We pass in the base url (so the same function
* can handle multiple requests), and a structure to fill in to return a
* result to the client. We also pass in a pointer to be filled in for
* the data cleanup function.
*/
struct isc_httpdurl {
char *url;
isc_httpdaction_t *action;
void *action_arg;
ISC_LINK(isc_httpdurl_t) link;
};
#define HTTPD_CLOSE 0x0001 /* Got a Connection: close header */
#define HTTPD_FOUNDHOST 0x0002 /* Got a Host: header */
@@ -87,6 +74,7 @@ struct isc_httpd {
*/
char recvbuf[HTTP_RECVLEN]; /*%< receive buffer */
isc_uint32_t recvlen; /*%< length recv'd */
char *headers; /*%< set in process_request() */
unsigned int method;
char *url;
char *querystring;
@@ -217,20 +205,12 @@ static isc_result_t process_request(isc_httpd_t *, int);
static void httpdmgr_destroy(isc_httpdmgr_t *);
static isc_result_t grow_headerspace(isc_httpd_t *);
static void reset_client(isc_httpd_t *httpd);
static isc_result_t render_404(const char *, const char *,
void *,
unsigned int *, const char **,
const char **, isc_buffer_t *,
isc_httpdfree_t **, void **);
static isc_result_t render_500(const char *, const char *,
void *,
unsigned int *, const char **,
const char **, isc_buffer_t *,
isc_httpdfree_t **, void **);
static isc_httpdaction_t render_404;
static isc_httpdaction_t render_500;
static void
destroy_client(isc_httpd_t **httpdp)
{
destroy_client(isc_httpd_t **httpdp) {
isc_httpd_t *httpd = *httpdp;
isc_httpdmgr_t *httpdmgr = httpd->mgr;
@@ -321,8 +301,7 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
}
static void
httpdmgr_destroy(isc_httpdmgr_t *httpdmgr)
{
httpdmgr_destroy(isc_httpdmgr_t *httpdmgr) {
isc_mem_t *mctx;
isc_httpdurl_t *url;
@@ -379,8 +358,7 @@ httpdmgr_destroy(isc_httpdmgr_t *httpdmgr)
#define BUFLENOK(s) (httpd->recvbuf - (s) < HTTP_RECVLEN)
static isc_result_t
process_request(isc_httpd_t *httpd, int length)
{
process_request(isc_httpd_t *httpd, int length) {
char *s;
char *p;
int delim;
@@ -390,6 +368,7 @@ process_request(isc_httpd_t *httpd, int length)
httpd->recvlen += length;
httpd->recvbuf[httpd->recvlen] = 0;
httpd->headers = NULL;
/*
* If we don't find a blank line in our buffer, return that we need
@@ -494,6 +473,8 @@ process_request(isc_httpd_t *httpd, int length)
p = s + 1;
s = p;
httpd->headers = s;
if (strstr(s, "Connection: close") != NULL)
httpd->flags |= HTTPD_CLOSE;
@@ -513,8 +494,7 @@ process_request(isc_httpd_t *httpd, int length)
}
static void
isc_httpd_accept(isc_task_t *task, isc_event_t *ev)
{
isc_httpd_accept(isc_task_t *task, isc_event_t *ev) {
isc_result_t result;
isc_httpdmgr_t *httpdmgr = ev->ev_arg;
isc_httpd_t *httpd;
@@ -609,8 +589,8 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev)
}
static isc_result_t
render_404(const char *url, const char *querystring,
void *arg,
render_404(const char *url, isc_httpdurl_t *urlinfo,
const char *querystring, const char *headers, void *arg,
unsigned int *retcode, const char **retmsg,
const char **mimetype, isc_buffer_t *b,
isc_httpdfree_t **freecb, void **freecb_args)
@@ -618,7 +598,9 @@ render_404(const char *url, const char *querystring,
static char msg[] = "No such URL.";
UNUSED(url);
UNUSED(urlinfo);
UNUSED(querystring);
UNUSED(headers);
UNUSED(arg);
*retcode = 404;
@@ -633,8 +615,8 @@ render_404(const char *url, const char *querystring,
}
static isc_result_t
render_500(const char *url, const char *querystring,
void *arg,
render_500(const char *url, isc_httpdurl_t *urlinfo,
const char *querystring, const char *headers, void *arg,
unsigned int *retcode, const char **retmsg,
const char **mimetype, isc_buffer_t *b,
isc_httpdfree_t **freecb, void **freecb_args)
@@ -642,7 +624,9 @@ render_500(const char *url, const char *querystring,
static char msg[] = "Internal server failure.";
UNUSED(url);
UNUSED(urlinfo);
UNUSED(querystring);
UNUSED(headers);
UNUSED(arg);
*retcode = 500;
@@ -657,8 +641,7 @@ render_500(const char *url, const char *querystring,
}
static void
isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
{
isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) {
isc_region_t r;
isc_result_t result;
isc_httpd_t *httpd = ev->ev_arg;
@@ -710,8 +693,9 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
url = ISC_LIST_NEXT(url, link);
}
if (url == NULL)
result = httpd->mgr->render_404(httpd->url, httpd->querystring,
NULL,
result = httpd->mgr->render_404(httpd->url, NULL,
httpd->querystring,
NULL, NULL,
&httpd->retcode,
&httpd->retmsg,
&httpd->mimetype,
@@ -719,14 +703,18 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
&httpd->freecb,
&httpd->freecb_arg);
else
result = url->action(httpd->url, httpd->querystring,
result = url->action(httpd->url, url,
httpd->querystring,
httpd->headers,
url->action_arg,
&httpd->retcode, &httpd->retmsg,
&httpd->mimetype, &httpd->bodybuffer,
&httpd->freecb, &httpd->freecb_arg);
if (result != ISC_R_SUCCESS) {
result = httpd->mgr->render_500(httpd->url, httpd->querystring,
NULL, &httpd->retcode,
result = httpd->mgr->render_500(httpd->url, url,
httpd->querystring,
NULL, NULL,
&httpd->retcode,
&httpd->retmsg,
&httpd->mimetype,
&httpd->bodybuffer,
@@ -739,9 +727,19 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
isc_httpd_addheader(httpd, "Content-Type", httpd->mimetype);
isc_httpd_addheader(httpd, "Date", datebuf);
isc_httpd_addheader(httpd, "Expires", datebuf);
isc_httpd_addheader(httpd, "Last-Modified", datebuf);
isc_httpd_addheader(httpd, "Pragma: no-cache", NULL);
isc_httpd_addheader(httpd, "Cache-Control: no-cache", NULL);
if (url != NULL && url->isstatic) {
char loadbuf[32];
isc_time_formathttptimestamp(&url->loadtime,
loadbuf, sizeof(loadbuf));
isc_httpd_addheader(httpd, "Last-Modified", loadbuf);
isc_httpd_addheader(httpd, "Cache-Control: public", NULL);
} else {
isc_httpd_addheader(httpd, "Last-Modified", datebuf);
isc_httpd_addheader(httpd, "Pragma: no-cache", NULL);
isc_httpd_addheader(httpd, "Cache-Control: no-cache", NULL);
}
isc_httpd_addheader(httpd, "Server: libisc", NULL);
isc_httpd_addheaderuint(httpd, "Content-Length",
isc_buffer_usedlength(&httpd->bodybuffer));
@@ -766,8 +764,7 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
}
void
isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp)
{
isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp) {
isc_httpdmgr_t *httpdmgr;
isc_httpd_t *httpd;
httpdmgr = *httpdmgrp;
@@ -794,8 +791,7 @@ isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp)
}
static isc_result_t
grow_headerspace(isc_httpd_t *httpd)
{
grow_headerspace(isc_httpd_t *httpd) {
char *newspace;
unsigned int newlen;
isc_region_t r;
@@ -816,8 +812,7 @@ grow_headerspace(isc_httpd_t *httpd)
}
isc_result_t
isc_httpd_response(isc_httpd_t *httpd)
{
isc_httpd_response(isc_httpd_t *httpd) {
isc_result_t result;
unsigned int needlen;
@@ -869,8 +864,7 @@ isc_httpd_addheader(isc_httpd_t *httpd, const char *name,
}
isc_result_t
isc_httpd_endheaders(isc_httpd_t *httpd)
{
isc_httpd_endheaders(isc_httpd_t *httpd) {
isc_result_t result;
while (isc_buffer_availablelength(&httpd->headerbuffer) < 2) {
@@ -912,8 +906,7 @@ isc_httpd_addheaderuint(isc_httpd_t *httpd, const char *name, int val) {
}
static void
isc_httpd_senddone(isc_task_t *task, isc_event_t *ev)
{
isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
isc_httpd_t *httpd = ev->ev_arg;
isc_region_t r;
isc_socketevent_t *sev = (isc_socketevent_t *)ev;
@@ -976,8 +969,7 @@ out:
}
static void
reset_client(isc_httpd_t *httpd)
{
reset_client(isc_httpd_t *httpd) {
/*
* Catch errors here. We MUST be in RECV mode, and we MUST NOT have
* any outstanding buffers. If we have buffers, we have a leak.
@@ -988,6 +980,7 @@ reset_client(isc_httpd_t *httpd)
httpd->recvbuf[0] = 0;
httpd->recvlen = 0;
httpd->headers = NULL;
httpd->method = ISC_HTTPD_METHODUNKNOWN;
httpd->url = NULL;
httpd->querystring = NULL;
@@ -1001,6 +994,14 @@ reset_client(isc_httpd_t *httpd)
isc_result_t
isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
isc_httpdaction_t *func, void *arg)
{
return (isc_httpdmgr_addurl2(httpdmgr, url, ISC_FALSE, func, arg));
}
isc_result_t
isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
isc_boolean_t isstatic,
isc_httpdaction_t *func, void *arg)
{
isc_httpdurl_t *item;
@@ -1021,6 +1022,9 @@ isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
item->action = func;
item->action_arg = arg;
item->isstatic = isstatic;
isc_time_now(&item->loadtime);
ISC_LINK_INIT(item, link);
ISC_LIST_APPEND(httpdmgr->urls, item, link);
+22
View File
@@ -26,6 +26,23 @@
#include <isc/types.h>
#include <isc/mutex.h>
#include <isc/task.h>
#include <isc/time.h>
/*%
* HTTP urls. These are the URLs we manage, and the function to call to
* provide the data for it. We pass in the base url (so the same function
* can handle multiple requests), and a structure to fill in to return a
* result to the client. We also pass in a pointer to be filled in for
* the data cleanup function.
*/
struct isc_httpdurl {
char *url;
isc_httpdaction_t *action;
void *action_arg;
isc_boolean_t isstatic;
isc_time_t loadtime;
ISC_LINK(isc_httpdurl_t) link;
};
#define HTTPD_EVENTCLASS ISC_EVENTCLASS(4300)
#define HTTPD_SHUTDOWN (HTTPD_EVENTCLASS + 0x0001)
@@ -49,6 +66,11 @@ isc_result_t
isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
isc_httpdaction_t *func, void *arg);
isc_result_t
isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
isc_boolean_t isstatic,
isc_httpdaction_t *func, void *arg);
isc_result_t
isc_httpd_response(isc_httpd_t *httpd);
+2
View File
@@ -103,7 +103,9 @@ typedef int (*isc_sockfdwatch_t)(isc_task_t *, isc_socket_t *, void *, int);
/* The following cannot be listed alphabetically due to forward reference */
typedef isc_result_t (isc_httpdaction_t)(const char *url,
isc_httpdurl_t *urlinfo,
const char *querystring,
const char *headers,
void *arg,
unsigned int *retcode,
const char **retmsg,
+10
View File
@@ -315,6 +315,16 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len);
*
*/
isc_result_t
isc_time_parsehttptimestamp(char *input, isc_time_t *t);
/*%<
* Parse the time in 'input' into the isc_time_t pointed to by 't',
* expecting a format like "Mon, 30 Aug 2000 04:06:47 GMT"
*
* Requires:
*\li 'buf' and 't' are not NULL.
*/
void
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len);
/*%<
+18
View File
@@ -407,6 +407,24 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
INSIST(flen < len);
}
isc_result_t
isc_time_parsehttptimestamp(char *buf, isc_time_t *t) {
struct tm t_tm;
time_t when;
char *p;
REQUIRE(buf != NULL);
REQUIRE(t != NULL);
p = strptime(buf, "%a, %d %b %Y %H:%M:%S %Z", &t_tm);
if (p == NULL)
return (ISC_R_UNEXPECTED);
when = timegm(&t_tm);
if (when == -1)
return (ISC_R_UNEXPECTED);
isc_time_set(t, when, 0);
return (ISC_R_SUCCESS);
}
void
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;