diff --git a/configure.ac b/configure.ac index d76500d205..a2febd2305 100644 --- a/configure.ac +++ b/configure.ac @@ -807,6 +807,7 @@ AC_OUTPUT([doc/version.ent src/bin/stats/stats.py src/bin/stats/stats_httpd.py src/bin/stats/stats.spec + src/bin/stats/stats-schema.spec src/bin/stats/stats-httpd.spec src/bin/stats/stats-httpd-xml.tpl src/bin/stats/stats-httpd-xsd.tpl diff --git a/src/bin/stats/Makefile.am b/src/bin/stats/Makefile.am index 485bc0598a..3ca0544e79 100644 --- a/src/bin/stats/Makefile.am +++ b/src/bin/stats/Makefile.am @@ -5,7 +5,7 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@ pkglibexec_SCRIPTS = b10-stats b10-stats-httpd b10_statsdir = $(pkgdatadir) -b10_stats_DATA = stats.spec stats-httpd.spec +b10_stats_DATA = stats.spec stats-httpd.spec stats-schema.spec b10_stats_DATA += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl CLEANFILES = b10-stats stats.pyc @@ -13,7 +13,7 @@ CLEANFILES += b10-stats-httpd stats_httpd.pyc man_MANS = b10-stats.8 b10-stats-httpd.8 EXTRA_DIST = $(man_MANS) b10-stats.xml b10-stats-httpd.xml -EXTRA_DIST += stats.spec stats-httpd.spec +EXTRA_DIST += stats.spec stats-httpd.spec stats-schema.spec EXTRA_DIST += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl if ENABLE_MAN diff --git a/src/bin/stats/stats-schema.spec.in b/src/bin/stats/stats-schema.spec.in new file mode 100644 index 0000000000..37e9c1ae9a --- /dev/null +++ b/src/bin/stats/stats-schema.spec.in @@ -0,0 +1,87 @@ +{ + "module_spec": { + "module_name": "Stats", + "module_description": "Statistics data schema", + "config_data": [ + { + "item_name": "report_time", + "item_type": "string", + "item_optional": false, + "item_default": "1970-01-01T00:00:00Z", + "item_title": "Report time", + "item_description": "A date time when stats module reports", + "item_format": "date-time" + }, + { + "item_name": "bind10.boot_time", + "item_type": "string", + "item_optional": false, + "item_default": "1970-01-01T00:00:00Z", + "item_title": "bind10.BootTime", + "item_description": "A date time when bind10 process starts initially", + "item_format": "date-time" + }, + { + "item_name": "stats.boot_time", + "item_type": "string", + "item_optional": false, + "item_default": "1970-01-01T00:00:00Z", + "item_title": "stats.BootTime", + "item_description": "A date time when the stats module starts initially or when the stats module restarts", + "item_format": "date-time" + }, + { + "item_name": "stats.start_time", + "item_type": "string", + "item_optional": false, + "item_default": "1970-01-01T00:00:00Z", + "item_title": "stats.StartTime", + "item_description": "A date time when the stats module starts collecting data or resetting values last time", + "item_format": "date-time" + }, + { + "item_name": "stats.last_update_time", + "item_type": "string", + "item_optional": false, + "item_default": "1970-01-01T00:00:00Z", + "item_title": "stats.LastUpdateTime", + "item_description": "The latest date time when the stats module receives from other modules like auth server or boss process and so on", + "item_format": "date-time" + }, + { + "item_name": "stats.timestamp", + "item_type": "real", + "item_optional": false, + "item_default": 0.0, + "item_title": "stats.Timestamp", + "item_description": "A current time stamp since epoch time (1970-01-01T00:00:00Z)", + "item_format": "second" + }, + { + "item_name": "stats.lname", + "item_type": "string", + "item_optional": false, + "item_default": "", + "item_title": "stats.LocalName", + "item_description": "A localname of stats module given via CC protocol" + }, + { + "item_name": "auth.queries.tcp", + "item_type": "integer", + "item_optional": false, + "item_default": 0, + "item_title": "auth.queries.tcp", + "item_description": "A number of total query counts which all auth servers receive over TCP since they started initially" + }, + { + "item_name": "auth.queries.udp", + "item_type": "integer", + "item_optional": false, + "item_default": 0, + "item_title": "auth.queries.udp", + "item_description": "A number of total query counts which all auth servers receive over UDP since they started initially" + } + ], + "commands": [] + } +} diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in index 821a7194b0..8e2cc4a638 100644 --- a/src/bin/stats/stats.py.in +++ b/src/bin/stats/stats.py.in @@ -39,13 +39,15 @@ isc.util.process.rename() # from a directory relative to that, otherwise we use the ones # installed on the system if "B10_FROM_SOURCE" in os.environ: - SPECFILE_LOCATION = os.environ["B10_FROM_SOURCE"] + os.sep + \ - "src" + os.sep + "bin" + os.sep + "stats" + os.sep + "stats.spec" + BASE_LOCATION = os.environ["B10_FROM_SOURCE"] + os.sep + \ + "src" + os.sep + "bin" + os.sep + "stats" else: PREFIX = "@prefix@" DATAROOTDIR = "@datarootdir@" - SPECFILE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@" + os.sep + "stats.spec" - SPECFILE_LOCATION = SPECFILE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX) + BASE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@" + BASE_LOCATION = BASE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX) +SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats.spec" +SCHEMA_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-schema.spec" class Singleton(type): """ @@ -184,8 +186,7 @@ class CCSessionListener(Listener): self.session = self.subject.session = self.cc_session._session # initialize internal data - self.config_spec = self.cc_session.get_module_spec().get_config_spec() - self.stats_spec = self.config_spec + self.stats_spec = isc.config.module_spec_from_file(SCHEMA_SPECFILE_LOCATION).get_config_spec() self.stats_data = self.initialize_data(self.stats_spec) # add event handler invoked via SessionSubject object diff --git a/src/bin/stats/stats.spec.in b/src/bin/stats/stats.spec.in index 4d42ebf0d3..25f6b54827 100644 --- a/src/bin/stats/stats.spec.in +++ b/src/bin/stats/stats.spec.in @@ -2,86 +2,7 @@ "module_spec": { "module_name": "Stats", "module_description": "Stats daemon", - "config_data": [ - { - "item_name": "report_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "Report time", - "item_description": "A date time when stats module reports", - "item_format": "date-time" - }, - { - "item_name": "bind10.boot_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "bind10.BootTime", - "item_description": "A date time when bind10 process starts initially", - "item_format": "date-time" - }, - { - "item_name": "stats.boot_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "stats.BootTime", - "item_description": "A date time when the stats module starts initially or when the stats module restarts", - "item_format": "date-time" - }, - { - "item_name": "stats.start_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "stats.StartTime", - "item_description": "A date time when the stats module starts collecting data or resetting values last time", - "item_format": "date-time" - }, - { - "item_name": "stats.last_update_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "stats.LastUpdateTime", - "item_description": "The latest date time when the stats module receives from other modules like auth server or boss process and so on", - "item_format": "date-time" - }, - { - "item_name": "stats.timestamp", - "item_type": "real", - "item_optional": false, - "item_default": 0.0, - "item_title": "stats.Timestamp", - "item_description": "A current time stamp since epoch time (1970-01-01T00:00:00Z)", - "item_format": "second" - }, - { - "item_name": "stats.lname", - "item_type": "string", - "item_optional": false, - "item_default": "", - "item_title": "stats.LocalName", - "item_description": "A localname of stats module given via CC protocol" - }, - { - "item_name": "auth.queries.tcp", - "item_type": "integer", - "item_optional": false, - "item_default": 0, - "item_title": "auth.queries.tcp", - "item_description": "A number of total query counts which all auth servers receive over TCP since they started initially" - }, - { - "item_name": "auth.queries.udp", - "item_type": "integer", - "item_optional": false, - "item_default": 0, - "item_title": "auth.queries.udp", - "item_description": "A number of total query counts which all auth servers receive over UDP since they started initially" - } - ], + "config_data": [], "commands": [ { "command_name": "status", diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in index dd9220ea31..97e9c784a4 100644 --- a/src/bin/stats/stats_httpd.py.in +++ b/src/bin/stats/stats_httpd.py.in @@ -46,7 +46,7 @@ else: BASE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@" BASE_LOCATION = BASE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX) SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd.spec" -STATS_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats.spec" +SCHEMA_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-schema.spec" XML_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xml.tpl" XSD_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsd.tpl" XSL_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsl.tpl" @@ -175,7 +175,7 @@ class StatsHttpd: SPECFILE_LOCATION, self.config_handler, self.command_handler) self.cc_session = self.mccs._session # read spec file of stats module and subscribe 'Stats' - self.stats_module_spec = isc.config.module_spec_from_file(STATS_SPECFILE_LOCATION) + self.stats_module_spec = isc.config.module_spec_from_file(SCHEMA_SPECFILE_LOCATION) self.stats_config_spec = self.stats_module_spec.get_config_spec() self.stats_module_name = self.stats_module_spec.get_module_name() diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py index 818b67ac79..830869d77d 100644 --- a/src/bin/stats/tests/b10-stats_test.py +++ b/src/bin/stats/tests/b10-stats_test.py @@ -540,9 +540,14 @@ class TestStats2(unittest.TestCase): os.environ["B10_FROM_SOURCE"] + os.sep + \ "src" + os.sep + "bin" + os.sep + "stats" + \ os.sep + "stats.spec") + self.assertEqual(stats.SCHEMA_SPECFILE_LOCATION, + os.environ["B10_FROM_SOURCE"] + os.sep + \ + "src" + os.sep + "bin" + os.sep + "stats" + \ + os.sep + "stats-schema.spec") imp.reload(stats) # change path of SPECFILE_LOCATION stats.SPECFILE_LOCATION = TEST_SPECFILE_LOCATION + stats.SCHEMA_SPECFILE_LOCATION = TEST_SPECFILE_LOCATION self.assertEqual(stats.SPECFILE_LOCATION, TEST_SPECFILE_LOCATION) self.subject = stats.SessionSubject(session=self.session, verbose=True) self.session = self.subject.session