Local time vs UTC

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
immauss
Posts: 7
Joined: Mon Nov 15, 2010 7:57 am

Local time vs UTC

Post by immauss »

It took me a while to notice what was happening. I live in Italy. (CET or Central European Time). The timezone info on my fresh install of openSuSE 12.1 is set as such, and the hardware clock is set to UTC. I'm using ntp on the box and it stays pretty accurate. My graphs for cacti however don't seem to realize all of that.

Every graph shows up two hours late with the last two hours of the graph blank. For example the graph data would go up to 1800 when it is actually 2000. Even for the localhost data. This just happens to be the time difference from UTC to CET right now with day light savings in effect. It took me a while to notice because the data doesn't show up for two hours. :o

I'm sure it has something to do with a timezone setting somewhere, but I can find no reference to timezone settings in cacti. I've set the timezone to CET in the php.ini, but that doesn't seem to have made any effect.

ideas?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Local time vs UTC

Post by gandalf »

Current Cacti does not have a timezone setting on it's own. It relies on the system and php timezone
R.
immauss
Posts: 7
Joined: Mon Nov 15, 2010 7:57 am

Re: Local time vs UTC

Post by immauss »

So what do you recommend?
immauss
Posts: 7
Joined: Mon Nov 15, 2010 7:57 am

Re: Local time vs UTC

Post by immauss »

Here's an example.
Note the time frame of the graph. This image was saved at 8:44. But the data at 6:40 is the current data.
I took a look at the cacti.log and realized the poller is logging to it two hours late. (ie the same time as what is showing up on the graphs.) I'm relatively certain it is something with php , but can't think what. I've tried a few different timezone settings in php.ini. The only thing that really makes a changes is if I set it to UTC. Then the graphs look normal, just two hours behind. Well, on time just for UTC not my timezone.
graph_image.png
graph_image.png (19.02 KiB) Viewed 1892 times
FWIW, I'm not a php guru, perl is my forte, so I haven't even tried to analyze any of the php code.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Local time vs UTC

Post by gandalf »

immauss wrote: I've set the timezone to CET in the php.ini, but that doesn't seem to have made any effect.
Did you restart httpd, then?
R.
immauss
Posts: 7
Joined: Mon Nov 15, 2010 7:57 am

Re: Local time vs UTC

Post by immauss »

So in a "grasping at straws" effort, I went through the other files in the /etc/php directory looking for another one with a timezone setting. Sure enough , /etc/php5/cli/php.ini had a timezone setting and it was set to "UTC". I changed it to my local timezone, and poof! Now all of my graphs are looking as they should.
:D
n00blab
Posts: 3
Joined: Sun Aug 26, 2012 8:47 am

Re: Local time vs UTC

Post by n00blab »

i feel your pain!

Spent a day troubleshooting this! Has only ever happened to me once out of 10+ cacti installs.

Wrote a tutorial on it here:

http://n00blab.com/correcting-cacti-timezone/

Gandalf, just have future users complaining of this to run:

sudo find / -name php.ini

they will like have:

/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini


as immauss and I did!
immauss
Posts: 7
Joined: Mon Nov 15, 2010 7:57 am

Re: Local time vs UTC

Post by immauss »

It made sense after I thought about it a bit. cmd.php is using the php.ini in /etc/php5/cli (it is running from the CLI) and the web pages are all using the one from the /etc/php5/apache2 directory.

But I couldn't find any reference to it on the web anywhere either. Hopefully this thread and your tut will make up for that.
Thanks,

:)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest