prelude-correlator/master: Sort dump of context statistics

[email protected] Sat, 16 Jan 2010 17:24:06 +0100 (CET)
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
commit 8df4661a39fc563a53bf32452a569d796550b6bc
Author: Yoann Vandoorselaere <[email protected]>
Date:   Fri Jan 15 17:37:21 2010 +0100

    Sort dump of context statistics
    
    When dumping context statistics, sort the context by threshold. This
    can make debugging easier.


========================================

 PreludeCorrelator/context.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

========================================

diff --git a/PreludeCorrelator/context.py b/PreludeCorrelator/context.py
index 8602ae0..4d5aefb 100644
--- a/PreludeCorrelator/context.py
+++ b/PreludeCorrelator/context.py
@@ -186,5 +186,15 @@ def wakeup(now):
 
 def stats(logger):
         now = time.time()
+
+        with_threshold = []
+
         for ctx in _CONTEXT_TABLE.values():
+                if ctx._options["threshold"] == -1:
+                        ctx.stats(logger.info, now)
+                else:
+                        with_threshold.append(ctx)
+
+        with_threshold.sort(lambda x, y: x.getUpdateCount() - y.getUpdateCount())
+        for ctx in with_threshold:
                 ctx.stats(logger.info, now)
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog