docker-collectd-plugin
docker-collectd-plugin copied to clipboard
Date&Time issue, bare metal in CEST timezone
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 :)
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
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.
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.
Hello. Сan anyone know how to solve this problem? I have time for 3 hours in the past.