From: Naoki Kambe Date: Wed, 1 Aug 2012 06:47:21 +0000 (+0900) Subject: [2136] Updated the 'show' command handler X-Git-Tag: trac2351_base~112^2~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1045e7f9b31bd683fb3a100bbd24fd21d4ab2c7e;p=thirdparty%2Fkea.git [2136] Updated the 'show' command handler The stats module decides if polling should be done by the the last time of polling. If more than one seconds past since the last request to each module, the stats module requests each module statistics data and then shows the latest result. Otherwise, the stats module just shows statistics data which it has. --- diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in index 4ca674f103..2aa95dfca5 100755 --- a/src/bin/stats/stats.py.in +++ b/src/bin/stats/stats.py.in @@ -164,6 +164,8 @@ class Stats: 'last_update_time': get_datetime()}): logger.warn(STATS_RECEIVED_INVALID_STATISTICS_DATA, self.module_name) + # define the variable of the last time of polling + self._lasttime_poll = 0.0 # try to do polling firstly self.do_polling() @@ -238,6 +240,8 @@ class Stats: logger.warn( STATS_RECEIVED_INVALID_STATISTICS_DATA, self.module_name) + # if successfully done, set the last time of polling + self._lasttime_poll = get_timestamp() def start(self): """ @@ -487,6 +491,14 @@ class Stats: """ handle show command """ + # decide if polling should be done by the the last time of + # polling. If more than one seconds past since the last + # request to each module, the stats module requests each + # module statistics data and then shows the latest + # result. Otherwise, the stats module just shows statistics + # data which it has. + if get_timestamp() - self._lasttime_poll > 1.0: + self.do_polling() if owner or name: logger.debug(DBG_STATS_MESSAGING, STATS_RECEIVED_SHOW_NAME_COMMAND,