From 12d3f91d59ac3d69433e5642b1c904c0fe2be410 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 10 Mar 2014 13:25:08 -0400 Subject: [PATCH] Amend connection count to avoid oversized count Since the log analysis merely needs to know if a connect/disconnect is redundant, only report 0, 1, or '2' connections to indicate 2 or greater. log analysis then would want to seek out a connect with eventdata of '1' and disconnect with eventdata of '0' and mostly ignore the '2' info. Desire for more data could be done by actually counting the connects and disconnects, this is just to provide a fast path to finding the 'first connection' and 'last disconnect' signatures. --- confluent/consoleserver.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/confluent/consoleserver.py b/confluent/consoleserver.py index ee42b62c..c0d9bfea 100644 --- a/confluent/consoleserver.py +++ b/confluent/consoleserver.py @@ -63,17 +63,24 @@ class _ConsoleHandler(object): self.users[username] += 1 else: self.users[username] = 1 + edata = self.users[username] + if edata > 2: # for log purposes, only need to + # clearly indicate redundant connections + # not connection count + edata = 2 self.logger.log( logdata=username, ltype=log.DataTypes.event, - event=log.Events.clientconnect, - eventdata=self.users[username]) + event=log.Events.clientconnect, eventdata=edata) def detachuser(self, username): self.users[username] -= 1 + if self.users[username] < 2: + edata = self.users[username] + else: + edata = 2 self.logger.log( logdata=username, ltype=log.DataTypes.event, - event=log.Events.clientdisconnect, - eventdata=self.users[username]) + event=log.Events.clientdisconnect, eventdata=edata) def _handle_console_output(self, data): if type(data) == int: