[master] add JSON statistics channel

3524.	[func]		Added an alternate statistics channel in JSON format,
			when the server is built with the json-c library:
			http://[address]:[port]/json.  [RT #32630]
This commit is contained in:
Evan Hunt
2013-03-13 14:24:50 -07:00
parent 8a64253066
commit feb067b25a
18 changed files with 1432 additions and 23 deletions
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef ISC_JSON_H
#define ISC_JSON_H 1
/*
* This file is here mostly to make it easy to add additional libjson header
* files as needed across all the users of this file. Rather than place
* these libjson includes in each file, one include makes it easy to handle
* the ifdef as well as adding the ability to add additional functions
* which may be useful.
*/
#ifdef HAVE_JSON
#include <json/json.h>
#endif
#define ISC_JSON_RENDERCONFIG 0x00000001 /* render config data */
#define ISC_JSON_RENDERSTATS 0x00000002 /* render stats */
#define ISC_JSON_RENDERALL 0x000000ff /* render everything */
#endif /* ISC_JSON_H */
+10
View File
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <isc/json.h>
#include <isc/lang.h>
#include <isc/mutex.h>
#include <isc/platform.h>
@@ -554,6 +555,15 @@ isc_mem_renderxml(xmlTextWriterPtr writer);
*/
#endif /* HAVE_LIBXML2 */
#ifdef HAVE_JSON
isc_result_t
isc_mem_renderjson(json_object *memobj);
/*%<
* Render all contexts' statistics and status in JSON.
*/
#endif /* HAVE_JSON */
/*
* Memory pools
*/
+12 -5
View File
@@ -57,13 +57,14 @@
*** Imports
***/
#include <isc/lang.h>
#include <isc/types.h>
#include <isc/event.h>
#include <isc/eventclass.h>
#include <isc/time.h>
#include <isc/lang.h>
#include <isc/json.h>
#include <isc/region.h>
#include <isc/sockaddr.h>
#include <isc/time.h>
#include <isc/types.h>
#include <isc/xml.h>
ISC_LANG_BEGINDECLS
@@ -1143,15 +1144,21 @@ isc__socketmgr_maxudp(isc_socketmgr_t *mgr, int maxudp);
*/
#ifdef HAVE_LIBXML2
int
isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer);
/*%<
* Render internal statistics and other state into the XML document.
*/
#endif /* HAVE_LIBXML2 */
#ifdef HAVE_JSON
isc_result_t
isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats);
/*%<
* Render internal statistics and other state into JSON format.
*/
#endif /* HAVE_JSON */
#ifdef USE_SOCKETIMPREGISTER
/*%<
* See isc_socketmgr_create() above.
+5 -1
View File
@@ -81,6 +81,7 @@
***/
#include <isc/eventclass.h>
#include <isc/json.h>
#include <isc/lang.h>
#include <isc/stdtime.h>
#include <isc/types.h>
@@ -787,10 +788,13 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp);
#ifdef HAVE_LIBXML2
int
isc_taskmgr_renderxml(isc_taskmgr_t *mgr, xmlTextWriterPtr writer);
#endif
#ifdef HAVE_JSON
isc_result_t
isc_taskmgr_renderjson(isc_taskmgr_t *mgr, json_object *tasksobj);
#endif
/*%<
+2 -1
View File
@@ -129,7 +129,8 @@ typedef enum {
/*% Statistics formats (text file or XML) */
typedef enum {
isc_statsformat_file,
isc_statsformat_xml
isc_statsformat_xml,
isc_statsformat_json
} isc_statsformat_t;
#endif /* ISC_TYPES_H */