prelude-correlator/master: Implement the Context.stats() method
[email protected] Fri, 18 Dec 2009 16:58:32 +0100 (CET)
| Newsgroups | gmane.comp.security.ids.prelude.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 4ec941a82ad936a1085ab28225cdde41de2f857f Author: Yoann Vandoorselaere <[email protected]> Date: Fri Dec 18 15:51:04 2009 +0100 Implement the Context.stats() method Dump useful statistics concerning the context. ======================================== PreludeCorrelator/context.py | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) ======================================== diff --git a/PreludeCorrelator/context.py b/PreludeCorrelator/context.py index 0b9081b..8602ae0 100644 --- a/PreludeCorrelator/context.py +++ b/PreludeCorrelator/context.py @@ -132,6 +132,13 @@ class Context(IDMEF, Timer): self.destroy() + def stats(self, log_func, now=time.time()): + if not self._timer_start: + log_func("[%s]: threshold=%d/%d update=%d" % (self._name, self._threshold_count, self._options["threshold"], self._update_count)) + else: + log_func("[%s]: threshold=%d/%d update=%d expire=%d/%d" % (self._name, self._threshold_count, self._options["threshold"], + self._update_count, self.elapsed(now), self._options["expire"])) + def getOptions(self): return self._options @@ -180,7 +187,4 @@ def wakeup(now): def stats(logger): now = time.time() for ctx in _CONTEXT_TABLE.values(): - if not ctx._timer_start: - logger.info("[%s]: threshold=%d/%d update=%d" % (ctx._name, ctx._threshold_count, ctx._options["threshold"], ctx._update_count)) - else: - logger.info("[%s]: threshold=%d/%d update=%d expire=%d/%d" % (ctx._name, ctx._threshold_count, ctx._options["threshold"], ctx._update_count, (now - ctx._timer_start), ctx._options["expire"])) + ctx.stats(logger.info, now) _______________________________________________ Prelude-cvslog site list [email protected] http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog