Browse Source

[trac763] addressed review comments

Jelte Jansen 14 years ago
parent
commit
1658417dae

+ 1 - 1
src/bin/stats/stats.py.in

@@ -224,7 +224,7 @@ class CCSessionListener(Listener):
         self.stats_data['stats.lname'] = self.session.lname
         self.cc_session.start()
         # request Bob to send statistics data
-        logger.debug(DBG_STATS_MESSAGING, STATS_SEND_STATS_REQUEST_BOSS)
+        logger.debug(DBG_STATS_MESSAGING, STATS_SEND_REQUEST_BOSS)
         cmd = isc.config.ccsession.create_command("sendstats", None)
         seq = self.session.group_sendmsg(cmd, 'Boss')
         self.session.group_recvmsg(True, seq)

+ 21 - 21
src/bin/stats/stats_httpd.py.in

@@ -42,8 +42,8 @@ logger = isc.log.Logger("stats-httpd")
 
 # Some constants for debug levels, these should be removed when we
 # have #1074
-DBG_STATS_HTTPD_INIT = 10
-DBG_STATS_HTTPD_MESSAGING = 30
+DBG_STATHTTPD_INIT = 10
+DBG_STATHTTPD_MESSAGING = 30
 
 # If B10_FROM_SOURCE is set in the environment, we use data files
 # from a directory relative to that, otherwise we use the ones
@@ -109,7 +109,7 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
                     return None
         except StatsHttpdError as err:
             self.send_error(500)
-            logger.error(STATS_HTTPD_SERVER_ERROR, err)
+            logger.error(STATHTTPD_SERVER_ERROR, err)
             return None
         else:
             self.send_response(200)
@@ -167,7 +167,7 @@ class StatsHttpd:
     def open_mccs(self):
         """Opens a ModuleCCSession object"""
         # create ModuleCCSession
-        logger.debug(DBG_STATS_HTTPD_INIT, STATS_HTTPD_STARTING_CC_SESSION)
+        logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_STARTING_CC_SESSION)
         self.mccs = isc.config.ModuleCCSession(
             SPECFILE_LOCATION, self.config_handler, self.command_handler)
         self.cc_session = self.mccs._session
@@ -181,7 +181,7 @@ class StatsHttpd:
         if self.mccs is None:
             return
 
-        logger.debug(DBG_STATS_HTTPD_INIT, STATS_HTTPD_CLOSING_CC_SESSION)
+        logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_CLOSING_CC_SESSION)
         self.mccs.close()
         self.mccs = None
 
@@ -230,7 +230,7 @@ class StatsHttpd:
                     (server_address[0], server_address[1],
                      err.__class__.__name__, err))
         else:
-            logger.info(STATS_HTTPD_STARTED, server_address[0],
+            logger.info(STATHTTPD_STARTED, server_address[0],
                         server_address[1])
         return httpd
 
@@ -239,7 +239,7 @@ class StatsHttpd:
         if len(self.httpd) == 0:
             return
         for ht in self.httpd:
-            logger.info(STATS_HTTPD_CLOSING, ht.server_address[0],
+            logger.info(STATHTTPD_CLOSING, ht.server_address[0],
                         ht.server_address[1])
             ht.server_close()
         self.httpd = []
@@ -277,7 +277,7 @@ class StatsHttpd:
     def stop(self):
         """Stops the running StatsHttpd objects. Closes CC session and
         HTTP handling sockets"""
-        logger.info(STATS_HTTPD_SHUTDOWN)
+        logger.info(STATHTTPD_SHUTDOWN)
         self.close_httpd()
         self.close_mccs()
 
@@ -294,11 +294,11 @@ class StatsHttpd:
     def config_handler(self, new_config):
         """Config handler for the ModuleCCSession object. It resets
         addresses and ports to listen HTTP requests on."""
-        logger.debug(DBG_STATS_HTTPD_MESSAGING, STATS_HTTPD_HANDLE_CONFIG,
+        logger.debug(DBG_STATHTTPD_MESSAGING, STATHTTPD_HANDLE_CONFIG,
                    new_config)
         for key in new_config.keys():
             if key not in DEFAULT_CONFIG and key != "version":
-                logger.error(STATS_HTTPD_UNKNOWN_CONFIG_ITEM, key)
+                logger.error(STATHTTPD_UNKNOWN_CONFIG_ITEM, key)
                 return isc.config.ccsession.create_answer(
                     1, "Unknown known config: %s" % key)
         # backup old config
@@ -308,7 +308,7 @@ class StatsHttpd:
         try:
             self.open_httpd()
         except HttpServerError as err:
-            logger.error(STATS_HTTPD_SERVER_ERROR, err)
+            logger.error(STATHTTPD_SERVER_ERROR, err)
             # restore old config
             self.config_handler(old_config)
             return isc.config.ccsession.create_answer(
@@ -320,19 +320,19 @@ class StatsHttpd:
         """Command handler for the ModuleCCSesson object. It handles
         "status" and "shutdown" commands."""
         if command == "status":
-            logger.debug(DBG_STATS_HTTPD_MESSAGING,
-                         STATS_HTTPD_RECEIVED_STATUS_COMMAND)
+            logger.debug(DBG_STATHTTPD_MESSAGING,
+                         STATHTTPD_RECEIVED_STATUS_COMMAND)
             return isc.config.ccsession.create_answer(
                 0, "Stats Httpd is up. (PID " + str(os.getpid()) + ")")
         elif command == "shutdown":
-            logger.debug(DBG_STATS_HTTPD_MESSAGING,
-                         STATS_HTTPD_RECEIVED_SHUTDOWN_COMMAND)
+            logger.debug(DBG_STATHTTPD_MESSAGING,
+                         STATHTTPD_RECEIVED_SHUTDOWN_COMMAND)
             self.running = False
             return isc.config.ccsession.create_answer(
                 0, "Stats Httpd is shutting down.")
         else:
-            logger.debug(DBG_STATS_HTTPD_MESSAGING,
-                         STATS_HTTPD_RECEIVED_UNKNOWN_COMMAND, command)
+            logger.debug(DBG_STATHTTPD_MESSAGING,
+                         STATHTTPD_RECEIVED_UNKNOWN_COMMAND, command)
             return isc.config.ccsession.create_answer(
                 1, "Unknown command: " + str(command))
 
@@ -471,13 +471,13 @@ if __name__ == "__main__":
         stats_httpd = StatsHttpd()
         stats_httpd.start()
     except OptionValueError as ove:
-        logger.fatal(STATS_HTTPD_BAD_OPTION_VALUE, ove)
+        logger.fatal(STATHTTPD_BAD_OPTION_VALUE, ove)
         sys.exit(1)
     except isc.cc.session.SessionError as se:
-        logger.fatal(STATS_HTTPD_CC_SESSION_ERROR, se)
+        logger.fatal(STATHTTPD_CC_SESSION_ERROR, se)
         sys.exit(1)
     except HttpServerError as hse:
-        logger.fatal(STATS_HTTPD_START_SERVER_ERROR, hse)
+        logger.fatal(STATHTTPD_START_SERVER_ERROR, hse)
         sys.exit(1)
     except KeyboardInterrupt as kie:
-        logger.info(STATS_HTTPD_STOPPED_BY_KEYBOARD)
+        logger.info(STATHTTPD_STOPPED_BY_KEYBOARD)

+ 30 - 30
src/bin/stats/stats_httpd_messages.mes

@@ -15,75 +15,75 @@
 # No namespace declaration - these constants go in the global namespace
 # of the stats_httpd_messages python module.
 
-% STATS_HTTPD_BAD_OPTION_VALUE bad command line argument: %1
-The stats-httpd module was called with a bad command-line argument,
+% STATHTTPD_BAD_OPTION_VALUE bad command line argument: %1
+The stats-httpd module was called with a bad command-line argument
 and will not start.
 
-% STATS_HTTPD_CC_SESSION_ERROR error connecting to message bus: %1
+% STATHTTPD_CC_SESSION_ERROR error connecting to message bus: %1
 The stats-httpd module was unable to connect to the BIND 10 command
-and control channel. A likely problem is that the message bus daemon
+and control bus. A likely problem is that the message bus daemon
 (b10-msgq) is not running. The stats-httpd module will now shut down.
 
-% STATS_HTTPD_CLOSING_CC_SESSION stopping cc session
-Debug message indicating that the stats httpd module is disconnecting
-from the command and control channel.
+% STATHTTPD_CLOSING_CC_SESSION stopping cc session
+Debug message indicating that the stats-httpd module is disconnecting
+from the command and control bus.
 
-% STATS_HTTPD_CLOSING closing %1#%2
-The stats-httpd daemon will stop listening for requests on te given
+% STATHTTPD_CLOSING closing %1#%2
+The stats-httpd daemon will stop listening for requests on the given
 address and port number.
 
-% STATS_HTTPD_HANDLE_CONFIG reading configuration: %1
+% STATHTTPD_HANDLE_CONFIG reading configuration: %1
 The stats-httpd daemon has received new configuration data and will now
 process it. The (changed) data is printed.
 
-% STATS_HTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
+% STATHTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
 A shutdown command was sent to the stats-httpd module, and it will
 now shut down.
 
-% STATS_HTTPD_RECEIVED_STATUS_COMMAND received command to return status
+% STATHTTPD_RECEIVED_STATUS_COMMAND received command to return status
 A status command was sent to the stats-httpd module, and it will
 respond with 'Stats Httpd is up.' and its PID.
 
-% STATS_HTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
+% STATHTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
 An unknown command has been sent to the stats-httpd module. The
 stats-httpd module will respond with an error, and the command will
 be ignored.
 
-% STATS_HTTPD_SERVER_ERROR http server error: %1
+% STATHTTPD_SERVER_ERROR http server error: %1
 An internal error occurred while handling an http request. A HTTP 500
 response will be sent back, and the specific error is printed. This
-is an error condition that should not occur, and likely points to a
-module that is not responding correctly to statistic requests.
+is an error condition that likely points to a module that is not
+responding correctly to statistic requests.
 
-% STATS_HTTPD_SERVER_INIT_ERROR http server initialization error: %1
+% STATHTTPD_SERVER_INIT_ERROR http server initialization error: %1
 There was a problem initializing the http server in the stats-httpd
-module upon receiving new configuration data.The most likely cause is a
-port binding problem or a bad configuration value. The specific error
-is printed in the message. The new configuration is ignored, and an
-error is sent back.
+module upon receiving its configuration data. The most likely cause
+is a port binding problem or a bad configuration value. The specific
+error is printed in the message. The new configuration is ignored,
+and an error is sent back.
 
-% STATS_HTTPD_SHUTDOWN shutting down
-The stats-httpd daemon will now shut down.
+% STATHTTPD_SHUTDOWN shutting down
+The stats-httpd daemon is shutting down.
 
-% STATS_HTTPD_START_SERVER_INIT_ERROR http server initialization error: %1
+% STATHTTPD_START_SERVER_INIT_ERROR http server initialization error: %1
 There was a problem initializing the http server in the stats-httpd
 module upon startup. The most likely cause is that it was not able
 to bind to the listening port. The specific error is printed, and the
 module will shut down.
 
-% STATS_HTTPD_STARTED listening on %1#%2
+% STATHTTPD_STARTED listening on %1#%2
 The stats-httpd daemon will now start listening for requests on the
 given address and port number.
 
-% STATS_HTTPD_STARTING_CC_SESSION starting cc session
-Debug message indicating that the stats httpd module is connecting to
-the command and control channel.
+% STATHTTPD_STARTING_CC_SESSION starting cc session
+Debug message indicating that the stats-httpd module is connecting to
+the command and control bus.
 
-% STATS_HTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
+% STATHTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
 There was a keyboard interrupt signal to stop the stats-httpd
 daemon. The daemon will now shut down.
 
-% STATS_HTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
+% STATHTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
 The stats-httpd daemon received new configuration. However, one of the
 items in the configuration is unknown. The new configuration is ignored,
 and an error is sent back. As possible cause is that there was an

+ 15 - 12
src/bin/stats/stats_messages.mes

@@ -16,24 +16,27 @@
 # of the stats_messages python module.
 
 % STATS_BAD_OPTION_VALUE bad command line argument: %1
-The stats module was called with a bad command-line argument, and will
+The stats module was called with a bad command-line argument and will
 not start.
 
 % STATS_CC_SESSION_ERROR error connecting to message bus: %1
 The stats module was unable to connect to the BIND 10 command and
-control channel. A likely problem is that the message bus daemon
+control bus. A likely problem is that the message bus daemon
 (b10-msgq) is not running. The stats module will now shut down.
 
 % STATS_RECEIVED_NEW_CONFIG received new configuration: %1
-This debug message is printed when the configuration manager has sent
-the stats module a configuration update.
+This debug message is printed when the stats module has received a
+configuration update from the configuration manager.
 
 % STATS_RECEIVED_REMOVE_COMMAND received command to remove %1
 A remove command for the given name was sent to the stats module, and
-it will now be removed.
+the given statistics value will now be removed. It will not appear in
+statistics reports until it appears in a statistics update from a
+module again.
 
 % STATS_RECEIVED_RESET_COMMAND received command to reset all statistics
-The stats module received a command to reset all collected statistics.
+The stats module received a command to clear all collected statistics.
+The data is cleared until it receives an update from the modules again.
 
 % STATS_RECEIVED_SHOW_ALL_COMMAND received command to show all statistics
 The stats module received a command to show all statistics that it has
@@ -44,19 +47,19 @@ The stats module received a command to show the statistics that it has
 collected for the given item.
 
 % STATS_RECEIVED_SHUTDOWN_COMMAND shutdown command received
-A shutdown command was sent to the stats module, and it will now shut down.
+A shutdown command was sent to the stats module and it will now shut down.
 
 % STATS_RECEIVED_STATUS_COMMAND received command to return status
-A status command was sent to the stats module, and it will respond with
-'I'm alive'.
+A status command was sent to the stats module. It will return a
+response indicating that it is running normally.
 
 % STATS_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
 An unknown command has been sent to the stats module. The stats module
-will respond with an error, and the command will be ignored.
+will respond with an error and the command will be ignored.
 
-% STATS_SEND_STATS_REQUEST_BOSS requesting boss to send statistics data
+% STATS_SEND_REQUEST_BOSS requesting boss to send statistics
 This debug message is printed when a request is sent to the boss module
-to send statistics data to the stats module.
+to send its data to the stats module.
 
 % STATS_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
 There was a keyboard interrupt signal to stop the stats daemon. The