]> git.ipfire.org Git - collecty.git/commitdiff
Enforce running with UTC
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Oct 2015 20:09:56 +0000 (22:09 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Oct 2015 20:09:56 +0000 (22:09 +0200)
collecty records all data in UTC and writes them to the database
in UTC as well. When the system uses a different timezone the database
"corrects" the timestamps what we don't want here. Hence we force
resetting the timezone to UTC.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/daemon.py

index 0891f8a9f30a8405b6fb353ef3207f7a1cffc963..eb64571c4b9a9c171ffac00409ec6a21de019f70 100644 (file)
@@ -21,6 +21,7 @@
 
 import datetime
 import multiprocessing
 
 import datetime
 import multiprocessing
+import os
 import queue
 import rrdtool
 import signal
 import queue
 import rrdtool
 import signal
@@ -45,6 +46,10 @@ class Collecty(object):
        def __init__(self, debug=False):
                self.debug = debug
 
        def __init__(self, debug=False):
                self.debug = debug
 
+               # Reset timezone to UTC
+               # rrdtool is reading that from the environment
+               os.environ["TZ"] = "UTC"
+
                # Enable debug logging when running in debug mode
                if self.debug:
                        log.setLevel(logging.DEBUG)
                # Enable debug logging when running in debug mode
                if self.debug:
                        log.setLevel(logging.DEBUG)