[Pkg-privacy-commits] [obfsproxy] 107/353: Fix heartbeat time glitches.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfsproxy.

commit 356c0524ffa69e7f79fe902f17e14867b5dafcb9
Author: George Kadianakis <desnacked at riseup.net>
Date:   Wed Jan 30 12:57:50 2013 +0200

    Fix heartbeat time glitches.
    
    Without this patch you get heartbeat messages like this:
    
    """
    [INFO] Heartbeat: During the last 22 hour(s) we saw 20 connection(s) from 2 unique address(es).
    [INFO] Heartbeat: obfsproxy's uptime is 5 day(s), 0 hour(s) and 0 minute(s).
    [INFO] Heartbeat: During the last 22 hour(s) we saw 20 connection(s) from 2 unique address(es).
    [INFO] Heartbeat: obfsproxy's uptime is 5 day(s), 1 hour(s) and 0 minute(s).
    [INFO] Heartbeat: During the last 23 hour(s) we saw 20 connection(s) from 2 unique address(es).
    [INFO] Heartbeat: obfsproxy's uptime is 5 day(s), 2 hour(s) and 0 minute(s).
    """
---
 obfsproxy/common/heartbeat.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/obfsproxy/common/heartbeat.py b/obfsproxy/common/heartbeat.py
index e7aa624..d145777 100644
--- a/obfsproxy/common/heartbeat.py
+++ b/obfsproxy/common/heartbeat.py
@@ -72,12 +72,16 @@ class Heartbeat(object):
         now = datetime.datetime.now()
         delta = now - self.started
 
-        if delta.days:
+        uptime_days = delta.days
+        uptime_hours = round(float(delta.seconds)/3600)
+        uptime_minutes = round(float(delta.seconds)/60)%60
+
+        if uptime_days:
             log.info("Heartbeat: obfsproxy's uptime is %d day(s), %d hour(s) and %d minute(s)." % \
-                         (delta.days, delta.seconds//3600, (delta.seconds//60)%60))
+                         (uptime_days, uptime_hours, uptime_minutes))
         else:
             log.info("Heartbeat: obfsproxy's uptime is %d hour(s) and %d minute(s)." % \
-                         (delta.seconds//3600, (delta.seconds//60)%60))
+                         (uptime_hours, uptime_minutes))
 
     def say_stats(self):
         """Log connection stats."""
@@ -87,7 +91,7 @@ class Heartbeat(object):
 
         log.info("Heartbeat: During the last %d hour(s) we saw %d connection(s)" \
                  " from %d unique address(es)." % \
-                     (reset_delta.seconds//3600 + reset_delta.days*24, self.n_connections,
+                     (round(float(reset_delta.seconds/3600)) + reset_delta.days*24, self.n_connections,
                       len(self.unique_ips)))
 
         # Reset stats every 24 hours.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git



More information about the Pkg-privacy-commits mailing list