statschannel.c File Reference

#include <config.h>
#include <isc/buffer.h>
#include <isc/httpd.h>
#include <isc/mem.h>
#include <isc/once.h>
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/stats.h>
#include <isc/string.h>
#include <isc/task.h>
#include <dns/cache.h>
#include <dns/db.h>
#include <dns/opcode.h>
#include <dns/resolver.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/stats.h>
#include <dns/view.h>
#include <dns/zt.h>
#include <named/log.h>
#include <named/server.h>
#include <named/statschannel.h>
#include "bind9.xsl.h"

Go to the source code of this file.

Data Structures

struct  ns_statschannel
struct  stats_dumparg

Defines

#define nsstats_xmldesc   NULL
#define resstats_xmldesc   NULL
#define adbstats_xmldesc   NULL
#define zonestats_xmldesc   NULL
#define sockstats_xmldesc   NULL
#define dnssecstats_xmldesc   NULL
#define TRY0(a)   do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0)
#define SET_NSSTATDESC(counterid, desc, xmldesc)
#define SET_RESSTATDESC(counterid, desc, xmldesc)
#define SET_ADBSTATDESC(id, desc, xmldesc)
#define SET_ZONESTATDESC(counterid, desc, xmldesc)
#define SET_SOCKSTATDESC(counterid, desc, xmldesc)
#define SET_DNSSECSTATDESC(counterid, desc, xmldesc)

Typedefs

typedef struct stats_dumparg stats_dumparg_t

Functions

static void set_desc (int counter, int maxcounter, const char *fdesc, const char **fdescs, const char *xdesc, const char **xdescs)
static void init_desc (void)
static void generalstat_dump (isc_statscounter_t counter, isc_uint64_t val, void *arg)
 Dump callback functions.
static isc_result_t dump_counters (isc_stats_t *stats, isc_statsformat_t type, void *arg, const char *category, const char **desc, int ncounters, int *indices, isc_uint64_t *values, int options)
static void rdtypestat_dump (dns_rdatastatstype_t type, isc_uint64_t val, void *arg)
static void rdatasetstats_dump (dns_rdatastatstype_t type, isc_uint64_t val, void *arg)
static void opcodestat_dump (dns_opcode_t code, isc_uint64_t val, void *arg)
static isc_result_t 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)
static void shutdown_listener (ns_statschannel_t *listener)
static isc_boolean_t client_ok (const isc_sockaddr_t *fromaddr, void *arg)
static void destroy_listener (void *arg)
static isc_result_t add_listener (ns_server_t *server, ns_statschannel_t **listenerp, const cfg_obj_t *listen_params, const cfg_obj_t *config, isc_sockaddr_t *addr, cfg_aclconfctx_t *aclconfctx, const char *socktext)
static void update_listener (ns_server_t *server, ns_statschannel_t **listenerp, const cfg_obj_t *listen_params, const cfg_obj_t *config, isc_sockaddr_t *addr, cfg_aclconfctx_t *aclconfctx, const char *socktext)
isc_result_t ns_statschannels_configure (ns_server_t *server, const cfg_obj_t *config, cfg_aclconfctx_t *aclconfctx)
 [Re]configure the statistics channels.
void ns_statschannels_shutdown (ns_server_t *server)
 Initiate shutdown of all the statistics channel listeners.
isc_result_t ns_stats_dump (ns_server_t *server, FILE *fp)
 Dump statistics counters managed by the server to the file fp.

Variables

static isc_once_t once = ISC_ONCE_INIT
static const char * nsstats_desc [dns_nsstatscounter_max]
 Statistics descriptions. These could be statistically initialized at compile time, but we configure them run time in the init_desc() function below so that they'll be less susceptible to counter name changes.
static const char * resstats_desc [dns_resstatscounter_max]
static const char * adbstats_desc [dns_adbstats_max]
static const char * zonestats_desc [dns_zonestatscounter_max]
static const char * sockstats_desc [isc_sockstatscounter_max]
static const char * dnssecstats_desc [dns_dnssecstats_max]
static int nsstats_index [dns_nsstatscounter_max]
 Mapping arrays to represent statistics counters in the order of our preference, regardless of the order of counter indices. For example, nsstats_desc[nsstats_index[0]] will be the description that is shown first.
static int resstats_index [dns_resstatscounter_max]
static int adbstats_index [dns_adbstats_max]
static int zonestats_index [dns_zonestatscounter_max]
static int sockstats_index [isc_sockstatscounter_max]
static int dnssecstats_index [dns_dnssecstats_max]


Detailed Description

Definition in file statschannel.c.


Define Documentation

#define nsstats_xmldesc   NULL

Definition at line 105 of file statschannel.c.

Referenced by init_desc().

#define resstats_xmldesc   NULL

Definition at line 106 of file statschannel.c.

Referenced by init_desc().

#define adbstats_xmldesc   NULL

Definition at line 107 of file statschannel.c.

Referenced by init_desc().

#define zonestats_xmldesc   NULL

Definition at line 108 of file statschannel.c.

Referenced by init_desc().

#define sockstats_xmldesc   NULL

Definition at line 109 of file statschannel.c.

Referenced by init_desc().

#define dnssecstats_xmldesc   NULL

Definition at line 110 of file statschannel.c.

Referenced by init_desc().

#define TRY0 (  )     do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0)

Definition at line 113 of file statschannel.c.

Referenced by dump_counters(), opcodestat_dump(), rdatasetstats_dump(), and rdtypestat_dump().

#define SET_NSSTATDESC ( counterid,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(dns_nsstatscounter_ ## counterid, \
                         dns_nsstatscounter_max, \
                         desc, nsstats_desc, xmldesc, nsstats_xmldesc); \
                nsstats_index[i++] = dns_nsstatscounter_ ## counterid; \
        } while (0)

Referenced by init_desc().

#define SET_RESSTATDESC ( counterid,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(dns_resstatscounter_ ## counterid, \
                         dns_resstatscounter_max, \
                         desc, resstats_desc, xmldesc, resstats_xmldesc); \
                resstats_index[i++] = dns_resstatscounter_ ## counterid; \
        } while (0)

Referenced by init_desc().

#define SET_ADBSTATDESC ( id,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(dns_adbstats_ ## id, dns_adbstats_max, \
                         desc, adbstats_desc, xmldesc, adbstats_xmldesc); \
                adbstats_index[i++] = dns_adbstats_ ## id; \
        } while (0)

Referenced by init_desc().

#define SET_ZONESTATDESC ( counterid,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(dns_zonestatscounter_ ## counterid, \
                         dns_zonestatscounter_max, \
                         desc, zonestats_desc, xmldesc, zonestats_xmldesc); \
                zonestats_index[i++] = dns_zonestatscounter_ ## counterid; \
        } while (0)

Referenced by init_desc().

#define SET_SOCKSTATDESC ( counterid,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(isc_sockstatscounter_ ## counterid, \
                         isc_sockstatscounter_max, \
                         desc, sockstats_desc, xmldesc, sockstats_xmldesc); \
                sockstats_index[i++] = isc_sockstatscounter_ ## counterid; \
        } while (0)

Referenced by init_desc().

#define SET_DNSSECSTATDESC ( counterid,
desc,
xmldesc   ) 

Value:

do { \
                set_desc(dns_dnssecstats_ ## counterid, \
                         dns_dnssecstats_max, \
                         desc, dnssecstats_desc, \
                         xmldesc, dnssecstats_xmldesc); \
                dnssecstats_index[i++] = dns_dnssecstats_ ## counterid; \
        } while (0)

Referenced by init_desc().


Typedef Documentation

typedef struct stats_dumparg stats_dumparg_t


Function Documentation

static void set_desc ( int  counter,
int  maxcounter,
const char *  fdesc,
const char **  fdescs,
const char *  xdesc,
const char **  xdescs 
) [inline, static]

Definition at line 128 of file statschannel.c.

References REQUIRE, and UNUSED.

static void init_desc ( void   )  [static]

Definition at line 147 of file statschannel.c.

References adbstats_desc, adbstats_xmldesc, dns_adbstats_max, dns_dnssecstats_max, dns_nsstatscounter_max, DNS_RESOLVER_QRYRTTCLASS0STR, DNS_RESOLVER_QRYRTTCLASS1STR, DNS_RESOLVER_QRYRTTCLASS2STR, DNS_RESOLVER_QRYRTTCLASS3STR, DNS_RESOLVER_QRYRTTCLASS4STR, dns_resstatscounter_max, dns_zonestatscounter_max, dnssecstats_desc, dnssecstats_xmldesc, INSIST, isc_sockstatscounter_max, nsstats_desc, nsstats_xmldesc, resstats_desc, resstats_xmldesc, SET_ADBSTATDESC, SET_DNSSECSTATDESC, SET_NSSTATDESC, SET_RESSTATDESC, SET_SOCKSTATDESC, SET_ZONESTATDESC, sockstats_desc, sockstats_xmldesc, zonestats_desc, and zonestats_xmldesc.

Referenced by ns_stats_dump(), and ns_statschannels_configure().

static void generalstat_dump ( isc_statscounter_t  counter,
isc_uint64_t  val,
void *  arg 
) [static]

Dump callback functions.

Definition at line 565 of file statschannel.c.

References stats_dumparg::countervalues, and REQUIRE.

Referenced by dump_counters().

static isc_result_t dump_counters ( isc_stats_t stats,
isc_statsformat_t  type,
void *  arg,
const char *  category,
const char **  desc,
int  ncounters,
int *  indices,
isc_uint64_t values,
int  options 
) [static]

Definition at line 573 of file statschannel.c.

References counter, stats_dumparg::counterindices, stats_dumparg::countervalues, error(), generalstat_dump(), ISC_LOG_ERROR, isc_log_write(), ISC_PRINT_QUADFORMAT, ISC_R_FAILURE, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_stats_dump(), ISC_STATSDUMP_VERBOSE, isc_statsformat_file, isc_statsformat_json, isc_statsformat_xml, ISC_XMLCHAR, stats_dumparg::ncounters, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TRY0, stats_dumparg::type, and UNUSED.

Referenced by ns_stats_dump().

static void rdtypestat_dump ( dns_rdatastatstype_t  type,
isc_uint64_t  val,
void *  arg 
) [static]

Definition at line 695 of file statschannel.c.

References stats_dumparg::arg, DNS_RDATASTATSTYPE_ATTR, DNS_RDATASTATSTYPE_ATTR_OTHERTYPE, DNS_RDATASTATSTYPE_BASE, dns_rdatatype_format(), error(), ISC_LOG_ERROR, isc_log_write(), ISC_PRINT_QUADFORMAT, ISC_R_FAILURE, isc_statsformat_file, isc_statsformat_json, isc_statsformat_xml, ISC_XMLCHAR, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, stats_dumparg::result, TRY0, and stats_dumparg::type.

Referenced by ns_stats_dump().

static void rdatasetstats_dump ( dns_rdatastatstype_t  type,
isc_uint64_t  val,
void *  arg 
) [static]

Definition at line 758 of file statschannel.c.

References stats_dumparg::arg, DNS_RDATASTATSTYPE_ATTR, DNS_RDATASTATSTYPE_ATTR_NXDOMAIN, DNS_RDATASTATSTYPE_ATTR_NXRRSET, DNS_RDATASTATSTYPE_ATTR_OTHERTYPE, DNS_RDATASTATSTYPE_ATTR_STALE, DNS_RDATASTATSTYPE_BASE, dns_rdatatype_format(), error(), ISC_FALSE, ISC_LOG_ERROR, isc_log_write(), ISC_PRINT_QUADFORMAT, ISC_R_FAILURE, isc_statsformat_file, isc_statsformat_json, isc_statsformat_xml, ISC_TRUE, ISC_XMLCHAR, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, stats_dumparg::result, TRY0, and stats_dumparg::type.

Referenced by ns_stats_dump().

static void opcodestat_dump ( dns_opcode_t  code,
isc_uint64_t  val,
void *  arg 
) [static]

Definition at line 843 of file statschannel.c.

References stats_dumparg::arg, dns_opcode_totext(), error(), isc_buffer_init, isc_buffer_usedlength, ISC_LOG_ERROR, isc_log_write(), ISC_PRINT_QUADFORMAT, ISC_R_FAILURE, isc_statsformat_file, isc_statsformat_json, isc_statsformat_xml, ISC_XMLCHAR, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, stats_dumparg::result, TRY0, and stats_dumparg::type.

Referenced by ns_stats_dump().

static isc_result_t 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 
) [static]

Definition at line 2049 of file statschannel.c.

References isc_buffer_add, isc_buffer_reinit(), ISC_R_SUCCESS, isc_time_parsehttptimestamp(), isc_time_secondsastimet(), isc_httpdurl::isstatic, isc_httpdurl::loadtime, send, UNUSED, and xslmsg.

Referenced by add_listener().

static void shutdown_listener ( ns_statschannel_t listener  )  [static]

Definition at line 2104 of file statschannel.c.

References ns_statschannel::address, ns_statschannel::httpdmgr, isc_httpdmgr_shutdown(), ISC_LOG_NOTICE, isc_log_write(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, NS_LOGCATEGORY_GENERAL, and NS_LOGMODULE_SERVER.

static isc_boolean_t client_ok ( const isc_sockaddr_t fromaddr,
void *  arg 
) [static]

Definition at line 2115 of file statschannel.c.

References ns_statschannel::acl, dns_acl_match(), ISC_FALSE, ISC_LOG_WARNING, isc_log_write(), isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, ISC_TRUE, ns_statschannel::lock, LOCK, match(), NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, REQUIRE, and UNLOCK.

Referenced by add_listener().

static void destroy_listener ( void *  arg  )  [static]

Definition at line 2142 of file statschannel.c.

References ns_statschannel::acl, DESTROYLOCK, dns_acl_detach(), ISC_LINK_LINKED, isc_mem_putanddetach, ns_statschannel::lock, ns_statschannel::mctx, and REQUIRE.

Referenced by add_listener().

static isc_result_t add_listener ( ns_server_t server,
ns_statschannel_t **  listenerp,
const cfg_obj_t listen_params,
const cfg_obj_t config,
isc_sockaddr_t addr,
cfg_aclconfctx_t aclconfctx,
const char *  socktext 
) [static]

Definition at line 2156 of file statschannel.c.

References ns_statschannel::acl, ns_statschannel::address, cfg_acl_fromconfig(), cfg_obj_islist(), cfg_tuple_get(), cleanup(), client_ok(), destroy_listener(), DESTROYLOCK, dns_acl_any(), dns_acl_attach(), dns_acl_detach(), ns_statschannel::httpdmgr, isc_httpdmgr_addurl(), isc_httpdmgr_addurl2(), isc_httpdmgr_create(), ISC_LINK_INIT, ISC_LOG_NOTICE, isc_log_write(), isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mem_putanddetach, isc_mutex_init, ISC_R_FAILURE, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_sockaddr_pf(), isc_socket_bind(), isc_socket_create(), isc_socket_detach(), isc_socket_ipv6only(), ISC_SOCKET_REUSEADDRESS, isc_socket_setname(), isc_sockettype_tcp, isc_task_create(), isc_task_detach(), isc_task_setname(), ISC_TRUE, ns_statschannel::lock, ns_statschannel::mctx, ns_server::mctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, render_xsl(), and sock.

static void update_listener ( ns_server_t server,
ns_statschannel_t **  listenerp,
const cfg_obj_t listen_params,
const cfg_obj_t config,
isc_sockaddr_t addr,
cfg_aclconfctx_t aclconfctx,
const char *  socktext 
) [static]

Definition at line 2286 of file statschannel.c.

References ns_statschannel::acl, ns_statschannel::address, cfg_acl_fromconfig(), cfg_obj_islist(), cfg_obj_log(), cfg_tuple_get(), dns_acl_any(), dns_acl_attach(), dns_acl_detach(), ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LOG_WARNING, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_equal(), ns_statschannel::lock, LOCK, ns_statschannel::mctx, ns_server::statschannels, and UNLOCK.

isc_result_t ns_statschannels_configure ( ns_server_t server,
const cfg_obj_t config,
cfg_aclconfctx_t aclconfctx 
)

[Re]configure the statistics channels.

If it is no longer there but was previously configured, destroy it here.

If the IP address or port has changed, destroy the old server and create a new one.

Definition at line 2337 of file statschannel.c.

References add_listener(), cfg_list_first(), cfg_list_next(), cfg_listelt_value(), cfg_map_get(), cfg_obj_assockaddr(), cfg_obj_log(), cfg_tuple_get(), init_desc(), ISC_LIST_APPEND, ISC_LIST_APPENDLIST, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, ISC_LIST_UNLINK, ISC_LOG_DEBUG, ISC_LOG_WARNING, isc_log_write(), isc_once_do, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_sockaddr_getport(), isc_sockaddr_setport(), NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, NS_STATSCHANNEL_HTTPPORT, once, r, RUNTIME_CHECK, shutdown_listener(), ns_server::statschannels, and update_listener().

Referenced by load_configuration().

void ns_statschannels_shutdown ( ns_server_t server  ) 

Initiate shutdown of all the statistics channel listeners.

Definition at line 2462 of file statschannel.c.

References ISC_LIST_HEAD, ISC_LIST_UNLINK, shutdown_listener(), and ns_server::statschannels.

Referenced by shutdown_server().

isc_result_t ns_stats_dump ( ns_server_t server,
FILE *  fp 
)

Dump statistics counters managed by the server to the file fp.

Definition at line 2472 of file statschannel.c.

References dns_view::adbstats, adbstats_desc, adbstats_index, stats_dumparg::arg, dns_view::cache, dns_view::cachedb, dns_adbstats_max, dns_cache_dumpstats(), dns_cache_getname(), dns_db_getrrsetstats(), dns_name_format(), DNS_NAME_FORMATSIZE, dns_nsstatscounter_max, dns_opcodestats_dump(), dns_rdatasetstats_dump(), dns_rdatatypestats_dump(), dns_resstatscounter_max, dns_view_iscacheshared(), dns_zone_first(), dns_zone_getorigin(), dns_zone_getrequeststats(), dns_zone_getview(), dns_zone_next(), dns_zonestatscounter_max, dump_counters(), init_desc(), ISC_LIST_HEAD, ISC_LIST_NEXT, isc_once_do, ISC_R_SUCCESS, isc_sockstatscounter_max, isc_statsformat_file, isc_stdtime_get(), dns_view::name, ns_server::nsstats, nsstats_desc, nsstats_index, once, opcodestat_dump(), ns_server::opcodestats, ns_server::rcvquerystats, rdatasetstats_dump(), rdtypestat_dump(), ns_server::resolverstats, dns_view::resquerystats, dns_view::resstats, resstats_desc, resstats_index, RUNTIME_CHECK, ns_server::sockstats, sockstats_desc, sockstats_index, stats_dumparg::type, ns_server::viewlist, ns_server::zonemgr, ns_server::zonestats, zonestats_desc, and zonestats_index.

Referenced by ns_server_dumpstats().


Variable Documentation

isc_once_t once = ISC_ONCE_INIT [static]

Definition at line 78 of file statschannel.c.

const char* nsstats_desc[dns_nsstatscounter_max] [static]

Statistics descriptions. These could be statistically initialized at compile time, but we configure them run time in the init_desc() function below so that they'll be less susceptible to counter name changes.

Definition at line 91 of file statschannel.c.

Referenced by init_desc(), and ns_stats_dump().

const char* resstats_desc[dns_resstatscounter_max] [static]

Definition at line 92 of file statschannel.c.

Referenced by init_desc(), and ns_stats_dump().

const char* adbstats_desc[dns_adbstats_max] [static]

Definition at line 93 of file statschannel.c.

Referenced by init_desc(), and ns_stats_dump().

const char* zonestats_desc[dns_zonestatscounter_max] [static]

Definition at line 94 of file statschannel.c.

Referenced by init_desc(), and ns_stats_dump().

const char* sockstats_desc[isc_sockstatscounter_max] [static]

Definition at line 95 of file statschannel.c.

Referenced by init_desc(), and ns_stats_dump().

const char* dnssecstats_desc[dns_dnssecstats_max] [static]

Definition at line 96 of file statschannel.c.

Referenced by init_desc().

int nsstats_index[dns_nsstatscounter_max] [static]

Mapping arrays to represent statistics counters in the order of our preference, regardless of the order of counter indices. For example, nsstats_desc[nsstats_index[0]] will be the description that is shown first.

Definition at line 120 of file statschannel.c.

Referenced by ns_stats_dump().

int resstats_index[dns_resstatscounter_max] [static]

Definition at line 121 of file statschannel.c.

Referenced by ns_stats_dump().

int adbstats_index[dns_adbstats_max] [static]

Definition at line 122 of file statschannel.c.

Referenced by ns_stats_dump().

int zonestats_index[dns_zonestatscounter_max] [static]

Definition at line 123 of file statschannel.c.

Referenced by ns_stats_dump().

int sockstats_index[isc_sockstatscounter_max] [static]

Definition at line 124 of file statschannel.c.

Referenced by ns_stats_dump().

int dnssecstats_index[dns_dnssecstats_max] [static]

Definition at line 125 of file statschannel.c.


Generated on Tue Apr 28 17:41:07 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha