def reportStats(self): """Write zenhubworker's current statistics to the log.""" now = time.time() if self.current != IDLE: self.log.info( "Currently performing %s, elapsed %.2f s", self.current, now - self.currentStart, ) else: self.log.info("Currently IDLE") if self.__registry: loglines = ["Running statistics:"] sorted_data = sorted( self.__registry.iteritems(), key=lambda kvp: (kvp[0][1], kvp[0][0].rpartition('.')[-1]), ) for svc, svcob in sorted_data: svc = "%s/%s" % (svc[1], svc[0].rpartition('.')[-1]) for method, stats in sorted(svcob.callStats.items()): loglines.append( " - %-48s %-32s %8d %12.2f %8.2f %s" % ( svc, method, stats.numoccurrences, stats.totaltime, stats.totaltime / stats.numoccurrences if stats.numoccurrences else 0.0, isoDateTime(stats.lasttime), ), ) self.log.info('\n'.join(loglines)) else: self.log.info("no service activity statistics")
def convertToUsersTimeZone(self, timestamp): """ This is an instance method so that it is available to tal statements, such as reports. """ user = self.zport.dmd.ZenUsers.getUserSettings() if user.timezone: return convertTimestampToTimeZone(timestamp, user.timezone) return isoDateTime(timestamp)
def convertToUsersTimeZone(self, timestamp): """ This is an instance method so that it is available to tal statements, such as reports. """ user = self.zport.dmd.ZenUsers.getUserSettings() if user.timezone: utc_dt = pytz.utc.localize(datetime.utcfromtimestamp(int(timestamp))) tz = pytz.timezone(user.timezone) tval = tz.normalize(utc_dt.astimezone(tz)) return tval.strftime(convertJsTimeFormatToPy(user.dateFormat+" "+user.timeFormat)) return isoDateTime(timestamp)
def convertToUsersTimeZone(self, timestamp): """ This is an instance method so that it is available to tal statements, such as reports. """ user = self.zport.dmd.ZenUsers.getUserSettings() if user.timezone: utc_dt = pytz.utc.localize( datetime.utcfromtimestamp(int(timestamp))) tz = pytz.timezone(user.timezone) tval = tz.normalize(utc_dt.astimezone(tz)) return tval.strftime( convertJsTimeFormatToPy(user.dateFormat + " " + user.timeFormat)) return isoDateTime(timestamp)
def reportStats(self): """Write zenhubworker's current statistics to the log.""" now = time.time() if self.current != IDLE: self.log.info( "Currently performing %s, elapsed %.2f s", self.current, now - self.currentStart, ) else: self.log.info("Currently IDLE") if self.__registry: loglines = ["Running statistics:"] sorted_data = sorted( self.__registry.iteritems(), key=lambda kv: kv[0].rpartition('.')[-1], ) loglines.append(" %-50s %-32s %8s %12s %8s %s" % ( "Service", "Method", "Count", "Total", "Average", "Last Run", )) for svc, svcob in sorted_data: svc = "%s" % svc.rpartition('.')[-1] for method, stats in sorted(svcob.callStats.items()): loglines.append( " - %-48s %-32s %8d %12.2f %8.2f %s" % ( svc, method, stats.numoccurrences, stats.totaltime, stats.totaltime / stats.numoccurrences if stats.numoccurrences else 0.0, isoDateTime(stats.lasttime), ), ) self.log.info('\n'.join(loglines)) else: self.log.info("no service activity statistics")
def reportStats(self): now = time.time() if self.current != IDLE: self.log.debug("(%d) Currently performing %s, elapsed %.2f s", self.pid, self.current, now-self.currentStart) else: self.log.debug("(%d) Currently IDLE", self.pid) if self.services: loglines = ["(%d) Running statistics:" % self.pid] for svc,svcob in sorted(self.services.iteritems(), key=lambda kvp:(kvp[0][1], kvp[0][0].rpartition('.')[-1])): svc = "%s/%s" % (svc[1], svc[0].rpartition('.')[-1]) for method,stats in sorted(svcob.callStats.items()): loglines.append(" - %-48s %-32s %8d %12.2f %8.2f %s" % (svc, method, stats.numoccurrences, stats.totaltime, stats.totaltime/stats.numoccurrences if stats.numoccurrences else 0.0, isoDateTime(stats.lasttime))) self.log.debug('\n'.join(loglines)) else: self.log.debug("no service activity statistics")