Commit 96ea7163 authored by Mark Andrews's avatar Mark Andrews

2134. [func] Additional statistics support. [RT #16666]

parent 149e7eac
2134. [func] Additional statistics support. [RT #16666]
2133. [port] powerpc: Support both IBM and MacOS Power PC
assembler syntaxes. [RT #16647]
......
......@@ -4,3 +4,4 @@ Makefile
*.lo
named
lwresd
bind9.xsl.h
......@@ -13,7 +13,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.90 2006/12/22 01:59:43 marka Exp $
# $Id: Makefile.in,v 1.91 2007/02/13 02:49:08 marka Exp $
srcdir = @srcdir@
VPATH = @srcdir@
......@@ -133,7 +133,7 @@ clean distclean maintainer-clean::
rm -f ${TARGETS} ${OBJS} ${GENERATED}
bind9.xsl.h: bind9.xsl convertxsl.pl
perl convertxsl.pl < ${srcdir}/bind9.xsl > bind9.xsl.h
${PERL} convertxsl.pl < ${srcdir}/bind9.xsl > bind9.xsl.h
server.@O@: bind9.xsl.h
......
......@@ -15,7 +15,7 @@
- PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id: bind9.xsl,v 1.11 2007/01/15 01:29:43 marka Exp $ -->
<!-- $Id: bind9.xsl,v 1.12 2007/02/13 02:49:08 marka Exp $ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
......@@ -108,28 +108,173 @@ tr.lrow {
</xsl:for-each>
</table>
<br />
<br/>
<xsl:for-each select="views/view">
<table>
<tr class="rowh">
<th colspan="4">Zones for View <xsl:value-of select="name" /></th>
</tr>
<tr class="rowh">
<xsl:for-each select="views/view">
<table>
<tr class="rowh">
<th colspan="11">Zones for View <xsl:value-of select="name"/></th>
</tr>
<tr class="rowh">
<th>Name</th>
<th>Class</th>
<th>Serial</th>
<th>Success</th>
<th>Referral</th>
<th>NXRRSET</th>
<th>NXDOMAIN</th>
<th>Recursion</th>
<th>Failure</th>
<th>Duplicate</th>
<th>Dropped</th>
</tr>
<xsl:for-each select="zones/zone">
<tr class="lrow">
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="rdataclass"/>
</td>
<td>
<xsl:value-of select="serial"/>
</td>
<td>
<xsl:value-of select="counters/success"/>
</td>
<td>
<xsl:value-of select="counters/referral"/>
</td>
<td>
<xsl:value-of select="counters/nxrrset"/>
</td>
<td>
<xsl:value-of select="counters/nxdomain"/>
</td>
<td>
<xsl:value-of select="counters/recursion"/>
</td>
<td>
<xsl:value-of select="counters/failure"/>
</td>
<td>
<xsl:value-of select="counters/duplicate"/>
</td>
<td>
<xsl:value-of select="counters/dropped"/>
</td>
</tr>
</xsl:for-each>
</table>
<br/>
</xsl:for-each>
<br/>
<table>
<tr class="rowh">
<th colspan="7">Network Status</th>
</tr>
<tr class="rowh">
<th>ID</th>
<th>Name</th>
<th>Class</th>
<th>Serial</th>
</tr>
<xsl:for-each select="zones/zone">
<tr class="lrow">
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="rdataclass"/></td>
<td><xsl:value-of select="serial"/></td>
</tr>
<th>Type</th>
<th>References</th>
<th>LocalAddress</th>
<th>PeerAddress</th>
<th>State</th>
</tr>
<xsl:for-each select="socketmgr/sockets/socket">
<tr class="lrow">
<td>
<xsl:value-of select="id"/>
</td>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="type"/>
</td>
<td>
<xsl:value-of select="references"/>
</td>
<td>
<xsl:value-of select="local-address"/>
</td>
<td>
<xsl:value-of select="peer-address"/>
</td>
<td>
<xsl:for-each select="states">
<xsl:value-of select="."/>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:for-each>
<br/>
<table>
<tr class="rowh">
<th colspan="2">Task Manager Configuration</th>
</tr>
<tr class="lrow">
<td>Thread-Model</td>
<td>
<xsl:value-of select="taskmgr/thread-model/type"/>
</td>
</tr>
<tr class="lrow">
<td>Worker Threads</td>
<td>
<xsl:value-of select="taskmgr/thread-model/worker-threads"/>
</td>
</tr>
<tr class="lrow">
<td>Default Quantum</td>
<td>
<xsl:value-of select="taskmgr/thread-model/default-quantum"/>
</td>
</tr>
<tr class="lrow">
<td>Tasks Running</td>
<td>
<xsl:value-of select="taskmgr/thread-model/tasks-running"/>
</td>
</tr>
</table>
<br/>
<table>
<tr class="rowh">
<th colspan="5">Tasks</th>
</tr>
<tr class="rowh">
<th>ID</th>
<th>Name</th>
<th>References</th>
<th>State</th>
<th>Quantum</th>
</tr>
<xsl:for-each select="taskmgr/tasks/task">
<tr class="lrow">
<td>
<xsl:value-of select="id"/>
</td>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="references"/>
</td>
<td>
<xsl:value-of select="state"/>
</td>
<td>
<xsl:value-of select="quantum"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.c,v 1.240 2006/12/04 01:52:45 marka Exp $ */
/* $Id: client.c,v 1.241 2007/02/13 02:49:08 marka Exp $ */
#include <config.h>
......@@ -2064,6 +2064,7 @@ client_newconn(isc_task_t *task, isc_event_t *event) {
*/
if (nevent->result == ISC_R_SUCCESS) {
client->tcpsocket = nevent->newsocket;
isc_socket_setname(client->tcpsocket, "client-tcp", NULL);
client->state = NS_CLIENTSTATE_READING;
INSIST(client->recursionquota == NULL);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: controlconf.c,v 1.51 2006/12/07 04:46:27 marka Exp $ */
/* $Id: controlconf.c,v 1.52 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -603,6 +603,7 @@ control_newconn(isc_task_t *task, isc_event_t *event) {
}
sock = nevent->newsocket;
isc_socket_setname(sock, "control", NULL);
(void)isc_socket_getpeername(sock, &peeraddr);
if (listener->type == isc_sockettype_tcp &&
!address_ok(&peeraddr, listener->acl)) {
......@@ -1149,6 +1150,8 @@ add_listener(ns_controls_t *cp, controllistener_t **listenerp,
result = isc_socket_create(ns_g_socketmgr,
isc_sockaddr_pf(&listener->address),
type, &listener->sock);
if (result == ISC_R_SUCCESS)
isc_socket_setname(listener->sock, "control", NULL);
if (result == ISC_R_SUCCESS)
result = isc_socket_bind(listener->sock,
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: interfacemgr.c,v 1.87 2007/02/06 00:01:23 marka Exp $ */
/* $Id: interfacemgr.c,v 1.88 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -304,6 +304,7 @@ ns_interface_accepttcp(ns_interface_t *ifp) {
isc_result_totext(result));
goto tcp_socket_failure;
}
isc_socket_setname(ifp->tcpsocket, "dispatcher", NULL);
#ifndef ISC_ALLOW_MAPPED
isc_socket_ipv6only(ifp->tcpsocket, ISC_TRUE);
#endif
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: lwdclient.c,v 1.19 2005/04/29 00:22:27 marka Exp $ */
/* $Id: lwdclient.c,v 1.20 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -102,6 +102,7 @@ ns_lwdclientmgr_create(ns_lwreslistener_t *listener, unsigned int nclients,
result = isc_task_create(taskmgr, 0, &cm->task);
if (result != ISC_R_SUCCESS)
goto errout;
isc_task_setname(cm->task, "lwdclient", NULL);
/*
* This MUST be last, since there is no way to cancel an onshutdown...
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.476 2007/02/02 02:18:05 marka Exp $ */
/* $Id: server.c,v 1.477 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -237,7 +237,7 @@ render_xsl(const char *url, const char *querystring, void *args,
void **freecb_args);
void
server_generatexml(ns_server_t *server, unsigned int *buflen, xmlChar **buf);
server_generatexml(ns_server_t *server, int *buflen, xmlChar **buf);
#endif /* HAVE_LIBXML2 */
......@@ -3663,11 +3663,13 @@ server_httpd_create(ns_server_t *server)
task = NULL;
result = isc_task_create(ns_g_taskmgr, 0, &task);
INSIST(result == ISC_R_SUCCESS);
isc_task_setname(task, "httpd", NULL);
sock = NULL;
result = isc_socket_create(ns_g_socketmgr, PF_INET,
isc_sockettype_tcp, &sock);
INSIST(result == ISC_R_SUCCESS);
isc_socket_setname(sock, "httpd", NULL);
result = isc_socket_bind(sock, &server->httpd_sockaddr);
INSIST(result == ISC_R_SUCCESS);
......@@ -5259,7 +5261,7 @@ ns_smf_add_message(isc_buffer_t *text) {
#define SPACES 3
void
server_generatexml(ns_server_t *server, unsigned int *buflen, xmlChar **buf)
server_generatexml(ns_server_t *server, int *buflen, xmlChar **buf)
{
char boottime[sizeof "yyyy-mm-ddThh:mm:ssZ"];
char nowstr[sizeof "yyyy-mm-ddThh:mm:ssZ"];
......@@ -5299,6 +5301,14 @@ server_generatexml(ns_server_t *server, unsigned int *buflen, xmlChar **buf)
}
TRY0(xmlTextWriterEndElement(writer)); /* views */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "socketmgr"));
isc_socketmgr_renderxml(ns_g_socketmgr, writer);
TRY0(xmlTextWriterEndElement(writer)); /* socketmgr */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "taskmgr"));
isc_taskmgr_renderxml(ns_g_taskmgr, writer);
TRY0(xmlTextWriterEndElement(writer)); /* taskmgr */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "server"));
xmlTextWriterStartElement(writer, ISC_XMLCHAR "boot-time");
xmlTextWriterWriteString(writer, ISC_XMLCHAR boottime);
......@@ -5318,6 +5328,10 @@ server_generatexml(ns_server_t *server, unsigned int *buflen, xmlChar **buf)
xmlTextWriterEndElement(writer); /* counters */
xmlTextWriterEndElement(writer); /* server */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "memory"));
isc_mem_renderxml(server->mctx, writer);
TRY0(xmlTextWriterEndElement(writer)); /* memory */
TRY0(xmlTextWriterEndElement(writer)); /* statistics */
TRY0(xmlTextWriterEndElement(writer)); /* bind */
TRY0(xmlTextWriterEndElement(writer)); /* isc */
......@@ -5345,7 +5359,7 @@ render_index(const char *url, const char *querystring, void *arg,
void **freecb_args)
{
unsigned char *msg;
unsigned int msglen;
int msglen;
ns_server_t *server = arg;
UNUSED(url);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dispatch.c,v 1.130 2007/02/07 05:40:50 marka Exp $ */
/* $Id: dispatch.c,v 1.131 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -1072,6 +1072,7 @@ create_socket(isc_socketmgr_t *mgr, isc_sockaddr_t *local,
isc_sockettype_udp, &sock);
if (result != ISC_R_SUCCESS)
return (result);
isc_socket_setname(sock, "dispatcher", NULL);
#ifndef ISC_ALLOW_MAPPED
isc_socket_ipv6only(sock, ISC_TRUE);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: xfrin.c,v 1.148 2006/12/18 23:58:13 marka Exp $ */
/* $Id: xfrin.c,v 1.149 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -856,6 +856,7 @@ xfrin_start(dns_xfrin_ctx_t *xfr) {
isc_sockaddr_pf(&xfr->sourceaddr),
isc_sockettype_tcp,
&xfr->socket));
isc_socket_setname(xfr->socket, "xfrin", NULL);
#ifndef BROKEN_TCP_BIND_BEFORE_CONNECT
CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr));
#endif
......
......@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: httpd.c,v 1.7 2006/12/22 04:20:52 marka Exp $ */
/* $Id: httpd.c,v 1.8 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -513,6 +513,7 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev)
ISC_LIST_APPEND(httpdmgr->running, httpd, link);
ISC_HTTPD_SETRECV(httpd);
httpd->sock = nev->newsocket;
isc_socket_setname(httpd->sock, "httpd", NULL);
httpd->flags = 0;
/*
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: mem.h,v 1.69 2006/12/22 01:45:00 marka Exp $ */
/* $Id: mem.h,v 1.70 2007/02/13 02:49:08 marka Exp $ */
#ifndef ISC_MEM_H
#define ISC_MEM_H 1
......@@ -28,6 +28,7 @@
#include <isc/mutex.h>
#include <isc/platform.h>
#include <isc/types.h>
#include <isc/xml.h>
ISC_LANG_BEGINDECLS
......@@ -538,6 +539,11 @@ isc__mempool_get(isc_mempool_t * _ISC_MEM_FLARG);
void
isc__mempool_put(isc_mempool_t *, void * _ISC_MEM_FLARG);
#ifdef HAVE_LIBXML2
void
isc_mem_renderxml(isc_mem_t *mgr, xmlTextWriterPtr writer);
#endif /* HAVE_LIBXML2 */
ISC_LANG_ENDDECLS
#endif /* ISC_MEM_H */
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.h,v 1.70 2007/01/12 00:14:51 marka Exp $ */
/* $Id: socket.h,v 1.71 2007/02/13 02:49:08 marka Exp $ */
#ifndef ISC_SOCKET_H
#define ISC_SOCKET_H 1
......@@ -64,6 +64,7 @@
#include <isc/time.h>
#include <isc/region.h>
#include <isc/sockaddr.h>
#include <isc/xml.h>
ISC_LANG_BEGINDECLS
......@@ -795,6 +796,33 @@ isc_socket_permunix(isc_sockaddr_t *sockaddr, isc_uint32_t perm,
* \li #ISC_R_FAILURE
*/
void isc_socket_setname(isc_socket_t *socket, const char *name, void *tag);
/*%<
* Set the name and optional tag for a socket. This allows tracking of the
* owner or purpose for this socket, and is useful for tracing and statistics
* reporting.
*/
const char *isc_socket_getname(isc_socket_t *socket);
/*%<
* Get the name associated with a socket, if any.
*/
void *isc_socket_gettag(isc_socket_t *socket);
/*%<
* Get the tag associated with a socket, if any.
*/
#ifdef HAVE_LIBXML2
void
isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer);
/*%<
* Render internal statistics and other state into the XML document.
*/
#endif /* HAVE_LIBXML2 */
ISC_LANG_ENDDECLS
#endif /* ISC_SOCKET_H */
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: task.h,v 1.59 2007/01/12 00:14:51 marka Exp $ */
/* $Id: task.h,v 1.60 2007/02/13 02:49:08 marka Exp $ */
#ifndef ISC_TASK_H
#define ISC_TASK_H 1
......@@ -84,6 +84,7 @@
#include <isc/lang.h>
#include <isc/stdtime.h>
#include <isc/types.h>
#include <isc/xml.h>
#define ISC_TASKEVENT_FIRSTEVENT (ISC_EVENTCLASS_TASK + 0)
#define ISC_TASKEVENT_SHUTDOWN (ISC_EVENTCLASS_TASK + 1)
......@@ -611,6 +612,13 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp);
* have been freed.
*/
#ifdef HAVE_LIBXML2
void
isc_taskmgr_renderxml(isc_taskmgr_t *mgr, xmlTextWriterPtr writer);
#endif
ISC_LANG_ENDDECLS
#endif /* ISC_TASK_H */
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: mem.c,v 1.128 2006/12/08 05:09:16 marka Exp $ */
/* $Id: mem.c,v 1.129 2007/02/13 02:49:08 marka Exp $ */
/*! \file */
......@@ -33,9 +33,9 @@
#include <isc/once.h>
#include <isc/ondestroy.h>
#include <isc/string.h>
#include <isc/mutex.h>
#include <isc/util.h>
#include <isc/xml.h>
#define MCTXLOCK(m, l) if (((m)->flags & ISC_MEMFLAG_NOLOCK) == 0) LOCK(l)
#define MCTXUNLOCK(m, l) if (((m)->flags & ISC_MEMFLAG_NOLOCK) == 0) UNLOCK(l)
......@@ -1952,3 +1952,118 @@ isc_mem_checkdestroyed(FILE *file) {
}
UNLOCK(&lock);
}
#ifdef HAVE_LIBXML2
void
isc_mem_renderxml(isc_mem_t *ctx, xmlTextWriterPtr writer)
{
size_t i;
const struct stats *s;
const isc_mempool_t *pool;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx, &ctx->lock);
xmlTextWriterStartElement(writer, ISC_XMLCHAR "references");
xmlTextWriterWriteFormatString(writer, "%d", ctx->references);
xmlTextWriterEndElement(writer);
xmlTextWriterStartElement(writer, ISC_XMLCHAR "buckets");
for (i = 0; i <= ctx->max_size; i++) {
s = &ctx->stats[i];
if (s->totalgets == 0U && s->gets == 0U)
continue;
xmlTextWriterStartElement(writer, ISC_XMLCHAR "bucket");
xmlTextWriterStartElement(writer, ISC_XMLCHAR "size");
xmlTextWriterWriteFormatString(writer, "%d", i);
xmlTextWriterEndElement(writer); /* size */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "totalgets");
xmlTextWriterWriteFormatString(writer, "%lu", s->totalgets);
xmlTextWriterEndElement(writer); /* totalgets */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "gets");
xmlTextWriterWriteFormatString(writer, "%lu", s->gets);
xmlTextWriterEndElement(writer); /* gets */
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0 &&
(s->blocks != 0U || s->freefrags != 0U)) {
xmlTextWriterStartElement(writer,
ISC_XMLCHAR "blocks");
xmlTextWriterWriteFormatString(writer, "%lu",
s->blocks);
xmlTextWriterEndElement(writer); /* blocks */
xmlTextWriterStartElement(writer,
ISC_XMLCHAR "freefrags");
xmlTextWriterWriteFormatString(writer, "%lu",
s->freefrags);
xmlTextWriterEndElement(writer); /* freefrags */
}
xmlTextWriterEndElement(writer); /* bucket */
}
xmlTextWriterEndElement(writer); /* buckets */
/*
* Note that since a pool can be locked now, these stats might be
* somewhat off if the pool is in active use at the time the stats
* are dumped. The link fields are protected by the isc_mem_t's
* lock, however, so walking this list and extracting integers from
* stats fields is always safe.
*/
xmlTextWriterStartElement(writer, ISC_XMLCHAR "pools");
pool = ISC_LIST_HEAD(ctx->pools);
while (pool != NULL) {
xmlTextWriterStartElement(writer, ISC_XMLCHAR "pool");
xmlTextWriterWriteElement(writer, ISC_XMLCHAR "name",
ISC_XMLCHAR pool->name);
xmlTextWriterStartElement(writer, ISC_XMLCHAR "size");
xmlTextWriterWriteFormatString(writer, "%d", pool->size);
xmlTextWriterEndElement(writer); /* size */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "maxalloc");
xmlTextWriterWriteFormatString(writer, "%u", pool->maxalloc);
xmlTextWriterEndElement(writer); /* maxalloc */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "allocated");
xmlTextWriterWriteFormatString(writer, "%u", pool->allocated);
xmlTextWriterEndElement(writer); /* allocated */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "freecount");
xmlTextWriterWriteFormatString(writer, "%u", pool->freecount);
xmlTextWriterEndElement(writer); /* freecount */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "freemax");
xmlTextWriterWriteFormatString(writer, "%u", pool->freemax);
xmlTextWriterEndElement(writer); /* freemax */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "fillcount");
xmlTextWriterWriteFormatString(writer, "%u", pool->fillcount);
xmlTextWriterEndElement(writer); /* fillcount */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "gets");