Ticket #252 (closed enhancement: patch does not fit)
Add ability to graph as if system is UTC timezone and not localtimezone
| Reported by: | human | Owned by: | oetiker |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | misc | Version: | |
| Keywords: | Cc: | jyavenard@… |
Description
From jyavenard@… rrdtool_graph calculates the x-axis labels and axis ticks based on the local timezone. The graph itself works in accordance with the --start and --time provided. Consolidation however is done according to UTC.
So unless you are living in the UTC timezone, when plotting daily average, the grid will not match the data plotted.
This is most obvious when calculating daily average. A daily average is done from midnight to midnight UTC.
You can work around the timezone by setting the environment variable TZ before calling rrdtool and this is mostly good enough, like TZ=UTC rrdtool graph ....
However, there are cases where you can't overwride the timezone without nasty side effects. This is mostly happening when using the rrdtool language binding like PHP, Python etc... When changing the TZ environment variable, it has an effect on the whole program.
This patch adds a --utc option to rrdtool_graph so time calculations are performed as if UTC timezone was set, ignoring the local timezone.
Attachments
Change History
comment:1 Changed 2 years ago by human
The original discussion was done on the user list: https://lists.oetiker.ch/pipermail/rrd-users/2009-December/016129.html
In the discussion 'how to calculate daily average from midnight to midnight local time'
comment:2 Changed 2 years ago by human
I think a better implementation would be to allow you to override the TZ environment. My main problem is that I run rrdsrv (via xinetd) and thereby can not set the TZ-variable (trying to add 'env = TZ=CET' in /etc/xinetd/rrdsrv does not seem to work).
So if the patch allowed for IE --tz=utc or --tz=cet it would probably solve a few issues about this.
comment:3 Changed 23 months ago by oetiker
- Status changed from new to closed
- Resolution set to patch does not fit
note that the timezone setting is global 'pre process' if you are working with an rrd module it makes no sense 'hacking' the TZ setting within rrdtool as everything else would be affected by it anyway ...
as you explained earlier, this problem shows in connection with the php bindings, so if you can not properly set TZ and call tzset from within php, an appropriate patch should be done to the php bindings ...
comment:4 Changed 23 months ago by human
I totally disagree with this last comment..
The point of this patch is precisely so you don't have to "hack" the TZ variables when you work with daily average.. Modifying an environment variable prior calling rrdtool is ugly at best and I just don't understand how this is the recommended solution.
Not everyone wants to see an average done from midnight to midnight in UTC timezone. I guess people living in Europe just don't care because it doesn't affect them. But myself, being 10 hours away from UTC timezone, it is..
Unfortunate that I will have to keep my own fork of rrdtools, just so I get the desired result in my graph :(




Add --utc option to rrd graph