Commit dcb5ce50 authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[master] Merge branch 'trac2136'

Conflicts:
	tests/system/bindctl/nsx1/b10-config.db.template.in
parents 76fa08f8 945773f7
......@@ -1101,6 +1101,7 @@ AC_CONFIG_FILES([Makefile
src/bin/zonemgr/tests/Makefile
src/bin/stats/Makefile
src/bin/stats/tests/Makefile
src/bin/stats/tests/testdata/Makefile
src/bin/usermgr/Makefile
src/bin/tests/Makefile
src/lib/Makefile
......
......@@ -1621,9 +1621,8 @@ const std::string HARDCODED_DNS_SERVER = "2001:db8:1::1";</pre><p>
</p><p>
This stats daemon provides commands to identify if it is
running, show specified or all statistics data, show specified
or all statistics data schema, and set specified statistics
data.
running, show specified or all statistics data, and show specified
or all statistics data schema.
For example, using <span class="command"><strong>bindctl</strong></span>:
......
......@@ -1790,8 +1790,8 @@ Chapter 16. Statistics
statistics data from various modules and aggregates it.
This stats daemon provides commands to identify if it is running, show
specified or all statistics data, show specified or all statistics data
schema, and set specified statistics data. For example, using bindctl:
specified or all statistics data, and show specified or all statistics data
schema. For example, using bindctl:
> Stats show
{
......
......@@ -3027,9 +3027,8 @@ const std::string HARDCODED_DNS_SERVER = "2001:db8:1::1";</screen>
<para>
This stats daemon provides commands to identify if it is
running, show specified or all statistics data, show specified
or all statistics data schema, and set specified statistics
data.
running, show specified or all statistics data, and show specified
or all statistics data schema.
For example, using <command>bindctl</command>:
......
......@@ -229,7 +229,7 @@ daemon immediately\&.
\fBshow_processes\fR
lists the current processes managed by
\fBbind10\fR\&. The output is an array in JSON format containing the process ID and the name for each\&.
\fBbind10\fR\&. The output is an array in JSON format containing the process ID, the name for each and the address name used on each message bus\&.
.PP
......
......@@ -414,7 +414,7 @@ xfrin
<command>show_processes</command> lists the current processes
managed by <command>bind10</command>.
The output is an array in JSON format containing the process
ID and the name for each.
ID, the name for each and the address name used on each message bus.
<!-- TODO: what is name? -->
<!-- TODO: change to JSON object format? -->
<!-- TODO: ticket #1406 -->
......
......@@ -281,7 +281,8 @@ class BoB:
pids.sort()
process_list = [ ]
for pid in pids:
process_list.append([pid, self.components[pid].name()])
process_list.append([pid, self.components[pid].name(),
self.components[pid].address()])
return process_list
def _get_stats_data(self):
......
......@@ -938,9 +938,10 @@ class TestStartStopProcessesBob(unittest.TestCase):
#self.check_started_dhcp(bob, True, True)
class MockComponent:
def __init__(self, name, pid):
def __init__(self, name, pid, address=None):
self.name = lambda: name
self.pid = lambda: pid
self.address = lambda: address
class TestBossCmd(unittest.TestCase):
......@@ -966,10 +967,10 @@ class TestBossCmd(unittest.TestCase):
"""
bob = MockBob()
bob.register_process(1, MockComponent('first', 1))
bob.register_process(2, MockComponent('second', 2))
bob.register_process(2, MockComponent('second', 2, 'Second'))
answer = bob.command_handler("show_processes", None)
processes = [[1, 'first'],
[2, 'second']]
processes = [[1, 'first', None],
[2, 'second', 'Second']]
self.assertEqual(answer, {'result': [0, processes]})
class TestParseArgs(unittest.TestCase):
......
'\" t
.\" Title: b10-stats
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
.\" Date: June 20, 2012
.\" Manual: BIND10
.\" Source: BIND10
......@@ -9,6 +9,15 @@
.\"
.TH "B10\-STATS" "8" "June 20, 2012" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
......@@ -37,7 +46,12 @@ and communicates by using the Command Channel by
with other modules like
\fBbind10\fR,
\fBb10\-auth\fR
and so on\&. It waits for coming data from other modules, then other modules send data to stats module periodically\&. Other modules send stats data to stats module independently from implementation of stats module, so the frequency of sending data may not be constant\&. The stats module collects data and aggregates it\&.
and so on\&.
\fBb10\-stats\fR
periodically requests statistics data to each module and receives\&. The interval time can be configured via
\fBbindctl\fR\&.
\fBb10\-stats\fR
cannot accept any command from other modules for updating statistics data\&. The stats module collects data and aggregates it\&.
\fBb10\-stats\fR
invokes an internal command for
\fBbind10\fR
......@@ -53,17 +67,20 @@ This enables maximum debug logging\&.
.RE
.SH "CONFIGURATION AND COMMANDS"
.PP
The
The configurable setting in
stats\&.spec
is:
.PP
\fIpoll\-interval\fR
.RS 4
is a timer interval in seconds for
\fBb10\-stats\fR
command does not have any configurable settings\&.
to polling each module for its statistics data\&. The default is 60 second\&. Polling can be disabled by setting to 0\&. The type of the value should be an unsigned integer\&. Setting to a negative integer is ignored\&.
.RE
.PP
The configuration commands are:
.PP
\fBset\fR
will set new statistics data specified in arguments\&. Statistics data to be set and the module name which owns statistics data are required in argument\&. Pid of the module in argument is optional\&.
.PP
\fBshow\fR
will send the statistics data in JSON format\&. By default, it outputs all the statistics data it has collected\&. An optional item name may be specified to receive individual output\&.
.PP
......@@ -93,7 +110,7 @@ statistics:
.PP
boot_time
.RS 4
The date and time when this daemon was started in ISO 8601 format\&. This is a constant which can\'t be reset except by restarting
The date and time when this daemon was started in ISO 8601 format\&. This is a constant which can\*(Aqt be reset except by restarting
\fBb10\-stats\fR\&.
.RE
.PP
......@@ -106,7 +123,7 @@ lname
.RS 4
This is the name used for the
\fBb10\-msgq\fR
command\-control channel\&. (This is a constant which can\'t be reset except by restarting
command\-control channel\&. (This is a constant which can\*(Aqt be reset except by restarting
\fBb10\-stats\fR\&.)
.RE
.PP
......
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2010-2012 Internet Systems Consortium, Inc. ("ISC")
-
......@@ -59,11 +59,11 @@
<command>bind10</command> and communicates by using the
Command Channel by <command>b10-msgq</command> with other
modules like <command>bind10</command>, <command>b10-auth</command>
and so on. It waits for coming data from other modules, then
other modules send data to stats module periodically. Other
modules send stats data to stats module independently from
implementation of stats module, so the frequency of sending
data may not be constant. The stats module collects data and
and so on. <command>b10-stats</command> periodically requests statistics
data from each module. The interval time can be configured
via <command>bindctl</command>. <command>b10-stats</command> cannot
accept any command from other modules for updating statistics data. The
stats module collects data and
aggregates it. <command>b10-stats</command> invokes an internal
command for <command>bind10</command> after its initial
starting to make sure it collects statistics data from
......@@ -78,9 +78,9 @@
<varlistentry>
<term><option>-v</option>, <option>--verbose</option></term>
<listitem>
<para>
This enables maximum debug logging.
</para>
<para>
This enables maximum debug logging.
</para>
</listitem>
</varlistentry>
</variablelist>
......@@ -90,22 +90,29 @@
<title>CONFIGURATION AND COMMANDS</title>
<para>
The <command>b10-stats</command> command does not have any
configurable settings.
The only configurable setting in <filename>stats.spec</filename>
is:
</para>
<variablelist>
<varlistentry>
<term><varname>poll-interval</varname></term>
<listitem>
<para>
is a time interval in seconds at which <command>b10-stats</command>
requests each module to return its statistics data. The default is 60
seconds. Polling can be disabled by setting it to 0. The type of the
value should be an unsigned integer. Negative integers are ignored.
</para>
</listitem>
</varlistentry>
</variablelist>
<!-- TODO: formating -->
<para>
The configuration commands are:
</para>
<para>
<command>set</command> will set new statistics data specified in
arguments. Statistics data to be set and the module name which owns
statistics data are required in argument. Pid of the module in argument
is optional.
</para>
<para>
<command>show</command> will send the statistics data
in JSON format.
......
This diff is collapsed.
......@@ -2,7 +2,13 @@
"module_spec": {
"module_name": "Stats",
"module_description": "Stats daemon",
"config_data": [],
"config_data": [
{ "item_name": "poll-interval",
"item_type": "integer",
"item_optional": true,
"item_default": 60
}
],
"commands": [
{
"command_name": "status",
......@@ -59,34 +65,6 @@
"item_description": "statistics item name of the owner"
}
]
},
{
"command_name": "set",
"command_description": "set the value of specified name in statistics data",
"command_args": [
{
"item_name": "owner",
"item_type": "string",
"item_optional": false,
"item_default": "",
"item_description": "module name of the owner of the statistics data"
},
{
"item_name": "pid",
"item_type": "integer",
"item_optional": true,
"item_default": -1,
"item_description": "process id of the owner module"
},
{
"item_name": "data",
"item_type": "map",
"item_optional": false,
"item_default": {},
"item_description": "statistics data set of the owner",
"map_item_spec": []
}
]
}
],
"statistics": [
......
# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2011, 2012 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
......@@ -53,8 +53,12 @@ response indicating that it is running normally.
An unknown command has been sent to the stats module. The stats module
will respond with an error and the command will be ignored.
% STATS_SEND_REQUEST_BOSS requesting boss to send statistics
This debug message is printed when a request is sent to the boss module
% STATS_RECEIVED_INVALID_STATISTICS_DATA received invalid statistics data from %1
Invalid statistics data has been received from the module while
polling and it has been discarded.
% STATS_SEND_STATISTICS_REQUEST requesting %1 to send statistics
This debug message is printed when a request is sent to the module
to send its data to the stats module.
% STATS_STARTING starting
......
SUBDIRS = testdata .
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
PYTESTS = b10-stats_test.py b10-stats-httpd_test.py
EXTRA_DIST = $(PYTESTS) test_utils.py
......@@ -23,7 +25,7 @@ endif
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/stats:$(abs_top_builddir)/src/bin/stats/tests:$(abs_top_builddir)/src/bin/msgq:$(abs_top_builddir)/src/lib/python/isc/config \
B10_FROM_SOURCE=$(abs_top_srcdir) \
BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/config/tests/testdata \
CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/bin/stats/tests/testdata \
B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
......
This diff is collapsed.
......@@ -144,11 +144,71 @@ class MockBoss:
"module_spec": {
"module_name": "Boss",
"module_description": "Mock Master process",
"config_data": [],
"config_data": [
{
"item_name": "components",
"item_type": "named_set",
"item_optional": false,
"item_default": {
"b10-stats": { "address": "Stats", "kind": "dispensable" },
"b10-cmdctl": { "special": "cmdctl", "kind": "needed" }
},
"named_set_item_spec": {
"item_name": "component",
"item_type": "map",
"item_optional": false,
"item_default": { },
"map_item_spec": [
{
"item_name": "special",
"item_optional": true,
"item_type": "string"
},
{
"item_name": "process",
"item_optional": true,
"item_type": "string"
},
{
"item_name": "kind",
"item_optional": false,
"item_type": "string",
"item_default": "dispensable"
},
{
"item_name": "address",
"item_optional": true,
"item_type": "string"
},
{
"item_name": "params",
"item_optional": true,
"item_type": "list",
"list_item_spec": {
"item_name": "param",
"item_optional": false,
"item_type": "string",
"item_default": ""
}
},
{
"item_name": "priority",
"item_optional": true,
"item_type": "integer"
}
]
}
}
],
"commands": [
{
"command_name": "sendstats",
"command_description": "Send data to a statistics module at once",
"command_name": "shutdown",
"command_description": "Shut down BIND 10",
"command_args": []
},
{
"command_name": "ping",
"command_description": "Ping the boss process",
"command_args": []
},
{
......@@ -185,10 +245,11 @@ class MockBoss:
self.spec_file.close()
self.cc_session = self.mccs._session
self.got_command_name = ''
self.pid_list = [[ 9999, "b10-auth" ],
[ 9998, "b10-auth-2" ],
[ 9997, "b10-auth-3" ],
[ 9996, "b10-auth-4" ]]
self.pid_list = [[ 9999, "b10-auth", "Auth" ],
[ 9998, "b10-auth-2", "Auth" ]]
self.statistics_data = {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME)
}
def run(self):
self.mccs.start()
......@@ -209,16 +270,9 @@ class MockBoss:
def command_handler(self, command, *args, **kwargs):
self._started.set()
self.got_command_name = command
params = { "owner": "Boss",
"data": {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME)
}
}
if command == 'sendstats':
send_command("set", "Stats", params=params, session=self.cc_session)
return isc.config.create_answer(0)
elif command == 'getstats':
return isc.config.create_answer(0, params)
sdata = self.statistics_data
if command == 'getstats':
return isc.config.create_answer(0, sdata)
elif command == 'show_processes':
# Return dummy pids
return isc.config.create_answer(
......@@ -232,13 +286,7 @@ class MockAuth:
"module_name": "Auth",
"module_description": "Mock Authoritative service",
"config_data": [],
"commands": [
{
"command_name": "sendstats",
"command_description": "Send data to a statistics module at once",
"command_args": []
}
],
"commands": [],
"statistics": [
{
"item_name": "queries.tcp",
......@@ -349,12 +397,11 @@ class MockAuth:
def command_handler(self, command, *args, **kwargs):
self.got_command_name = command
if command == 'sendstats':
params = { "owner": "Auth",
"data": { 'queries.tcp': self.queries_tcp,
'queries.udp': self.queries_udp,
'queries.perzone' : self.queries_per_zone } }
return send_command("set", "Stats", params=params, session=self.cc_session)
sdata = { 'queries.tcp': self.queries_tcp,
'queries.udp': self.queries_udp,
'queries.perzone' : self.queries_per_zone }
if command == 'getstats':
return isc.config.create_answer(0, sdata)
return isc.config.create_answer(1, "Unknown Command")
class MyStats(stats.Stats):
......@@ -428,9 +475,13 @@ class BaseModules:
# MockAuth
self.auth = ThreadingServerManager(MockAuth)
self.auth.run()
self.auth2 = ThreadingServerManager(MockAuth)
self.auth2.run()
def shutdown(self):
# MockAuth
self.auth2.shutdown()
self.auth.shutdown()
# MockBoss
self.boss.shutdown()
......
{ "version": 2,
"Boss": {
"components": {
"b10-auth": {
"kind": "needed",
"special": "auth"
},
"b10-auth-2": {
"kind": "needed",
"special": "auth"
}
}
}
}
......@@ -371,6 +371,14 @@ class BaseComponent:
"""
pass
def address(self):
"""
Provides the name of the address used on the message bus
You need to provide this method in a concrete implementation.
"""
pass
class Component(BaseComponent):
"""
The most common implementation of a component. It can be used either
......@@ -454,6 +462,12 @@ class Component(BaseComponent):
else:
self._procinfo.process.terminate()
def address(self):
"""
Returns the name of the address used on the message bus
"""
return self._address
class Configurator:
"""
This thing keeps track of configuration changes and starts and stops
......
......@@ -164,6 +164,13 @@ class ComponentTests(BossUtils, unittest.TestCase):
component = self.__create_component('core')
self.assertEqual('No process', component.name())
def test_address(self):
"""
Test the address provides whatever we passed to the constructor as process.
"""
component = self.__create_component('core')
self.assertEqual("homeless", component.address())
def test_guts(self):
"""
Test the correct data are stored inside the component.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment