diff --git a/boswatch/packet/packet.py b/boswatch/packet/packet.py index a0353cf..248a48a 100644 --- a/boswatch/packet/packet.py +++ b/boswatch/packet/packet.py @@ -34,7 +34,11 @@ class Packet: self._packet = {"timestamp": time.time()} else: logging.debug("create bwPacket from string") - self._packet = eval(bwPacket) + try: + self._packet = eval(bwPacket.strip()) + except: + # todo can we repair teh packet anyway? + logging.exception("error while create packet from string") def __str__(self): """!Return the intern _packet dict as string""" diff --git a/boswatch/plugin/plugin.py b/boswatch/plugin/plugin.py index b5f230c..be256ff 100644 --- a/boswatch/plugin/plugin.py +++ b/boswatch/plugin/plugin.py @@ -35,6 +35,7 @@ class Plugin: # for time counting self._sumTime = 0 + self._cumTime = 0 self._setupTime = 0 self._alarmTime = 0 self._teardownTime = 0 @@ -109,6 +110,7 @@ class Plugin: self._teardownTime = time.time() - self._tmpTime self._sumTime = self._setupTime + self._alarmTime + self._teardownTime + self._cumTime += self._sumTime self._endTime = time.time() logging.debug("[%s] took %0.3f seconds", self._pluginName, self._sumTime) @@ -120,9 +122,15 @@ class Plugin: """!Returns statistical information's from last plugin run @return Statistics as pyton dict""" - stats = {"runCount": self._runCount, "sumTime": self._sumTime, "cumTime": self._runCount * self._sumTime, - "setupTime": self._setupTime, "alarmTime": self._alarmTime, "teardownTime": self._teardownTime, - "setupErrorCount": self._setupErrorCount, "alarmErrorCount": self._alarmErrorCount, "teardownErrorCount": self._teardownErrorCount} + stats = {"runCount": self._runCount, + "sumTime": self._sumTime, + "cumTime": self._cumTime, + "setupTime": self._setupTime, + "alarmTime": self._alarmTime, + "teardownTime": self._teardownTime, + "setupErrorCount": self._setupErrorCount, + "alarmErrorCount": self._alarmErrorCount, + "teardownErrorCount": self._teardownErrorCount} return stats def onLoad(self):