Hi Jean, Monday Jean-Yves Avenard wrote:
> Hi > > On 8 February 2010 16:39, Tobias Oetiker <[email protected]> wrote: > > all you have todo, if you don't want this change to be global, is > > to change TZ before calling rrdtol, and then change it back to the > > original value and call tzset() again ... > > This is the first thing I had tried. > > I did: > $tz = getenv("TZ") > putenv("TZ=UTC") > rrdool_graph(....) > putenv("TZ=$tz") > > to replace wherever I was doing > exec("TZ=UTC /usr/bin/rrdtool graph ....) > > Problem is that the TZ environement variable is changed during the > whole execution of rrdtool. > > Sometimes it takes a good second to render the graph ; during that > time, the TZ environment variable is shared with other php apache > pages. this would seem rather odd, is this somehow multithreaded ? If it was, it would not matter if the tzset was done in rrdtool or in php the effect would be the same. in any event, your patch for --utc should be fine ... whatever the benefit of it ... > I had noticed because I started to have errors in my apache log when > doing my stats on those. > The apache logs contained logs like > 155.144.40.31 - - [07/Feb/2010:06:44:40 +1100] "GET > /power/?rs=print_inverter&rst=&rsrnd=1265485478000 HTTP/1.1" 200 718 > "http://htpc.avenard.org/power/" "Mozilla/5.0 (Windows; U; Windows NT > 5.1; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4" > 155.144.40.31 - - [06/Feb/2010:19:44:42] "GET > /power/?rs=print_inverter&rst=&rsrnd=1265485478000 HTTP/1.1" 200 718 > "http://htpc.avenard.org/power/" "Mozilla/5.0 (Windows; U; Windows NT > 5.1; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4" > 155.144.40.31 - - [07/Feb/2010:06:44:45 +1100] "GET > /power/?rs=print_inverter&rst=&rsrnd=1265485478000 HTTP/1.1" 200 718 > "http://htpc.avenard.org/power/" "Mozilla/5.0 (Windows; U; Windows NT > 5.1; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4" > > Most of the apache log analyser aren't timezone aware and choke on > having a log with earlier date showing up > > > > > in php the calling of tzset seems to happen automagically when you > > call putenv with a TZ variable. > > > > the same would have to be be added to rrd_graph for this ... or are > > you looking for something else ? > > Check the patch I submitted ; I used gmtime_r instead of localtime_t > and gmtime instead of mktime ... they do not use the TZ environment > variable. > > I had the same issue in a python program, it's multi-threaded and if > the call to rrdtool happen at exactly the same time, the TZ variable > is modified for both, when I only wanted to do it for one.. > > I wouldn't have bothered with writing code if there was a way around it :) > Jean-Yves > > -- Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland http://it.oetiker.ch [email protected] ++41 62 775 9902 / sb: -9900 _______________________________________________ rrd-users mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
