docker-collectd-plugin icon indicating copy to clipboard operation
docker-collectd-plugin copied to clipboard

Date&Time issue, bare metal in CEST timezone

Open x8k opened this issue 8 years ago • 4 comments

Hello, I'm experiencing a strange behavior with the plugin. I've the bare-metal in CEST (+0200) that runs the docker plugins inside a docker image running with -v /var/run/docker.sock:/var/run/docker.sock:ro option. The t = stats['read'] has value like "2016-04-13T14:44:03.808905789+02:00" When the plugin run the if below use the time.mktime() function

if t:
            val.time = time.mktime(dateutil.parser.parse(t).timetuple())
        else:
            val.time = time.time()

And from documentation: The timetuple parameter given to mktime() doesn't contain any time zone information (it never does, there is no time zone field in a timetuple). Therefore the function has to "guess" which time zone it might be, and mktime() just always assumes that it is local time. That's just how the function behaves. That means the plugin sends the metrics 2 hours in the future :)

x8k avatar Apr 13 '16 13:04 x8k

If I remove the if and leaving the val.time = time.time()or changing time.mktime(dateutil.parser.parse(t).timetuple()) in val.time = time.mktime(dateutil.parser.parse(t ignoretz=True).timetuple()) the problem does not occurs. I really dont know if I'm doing well

x8k avatar Apr 13 '16 15:04 x8k

Seconded. I run my servers using a non-UTC timezone (BST), and the collected metrics are 1 hour in the future in the summer months :)

Ideally as per Collectd spec the timestamps collected would be in epoch time.

xneo64 avatar Jun 22 '16 09:06 xneo64

Thirded. Using the ignoretz=True fix proposed by @stregatto doesn't seem to work though. Had to resort to using val.time = time.time() and ignoring stats['read'] altogether.

StefanVanDyck avatar Jul 07 '16 12:07 StefanVanDyck

Hello. Сan anyone know how to solve this problem? I have time for 3 hours in the past.

TimonDDD avatar Nov 28 '17 18:11 TimonDDD