PDA

View Full Version : {TIME} macro displays UTC


gelowe
26-06-2010, 18:45
*solved*
My Alerts are displaying the time in UTC. Whats odd is the web interface shows time adjusted to my time zone. Also the info in triggers and the dashboard show the right time. Any ideas on how to fix this?

I had set time via tzconfig but it turns out in ubuntu you should use

dpkg-reconfigure tzdata

gelowe
27-06-2010, 01:44
I did more research and I found that mysql was not reading the localization string. I confirmed this by running the "select now();" and "SELECT @@global.time_zone, @@session.time_zone;" and I manually fixed this with an addition to my.cnf. I have restarted mysql, apache, zabbix_server and zabbix_agent. Still I get a GMT time on my alerts. I did deeper digging and the values stored in the DB are GMT. But looking at the code the localtime function is called to change time to the local adjusted time. For whatever reason in the case of the TIME macro it's not working. I need some help here on troubleshooting further. I even created some test code to see if the C++ localtime function was working and it is. Any ideas?

My zabbix install is an upgrade from 1.4. I had to run both the 1.6 update sql as well as the sql upgrade script for 1.8/ So far this is the only issue i have had.


Here is my test code and results

/* localtime example */
#include <stdio.h>
#include <time.h>

int main ()
{
time_t rawtime;
time_t seconds;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "Current local time and date: %s\n", asctime (timeinfo) );

time ( &rawtime );
timeinfo = gmtime(&rawtime) ;
printf ( "Current GMT time and date: %s\n", asctime (timeinfo) );


seconds = time (NULL);
printf ("%ld seconds since January 1, 1970\n", seconds);

return 0;
}


results

g++ -Wall timetest.cc -o timetest
./timetest
Current local time and date: Sat Jun 26 18:41:04 2010
Current GMT time and date: Sat Jun 26 23:41:04 2010
1277595664 seconds since January 1, 1970

gelowe
27-06-2010, 04:45
I had set time via tzconfig but it turns out in ubuntu you should use

dpkg-reconfigure tzdata

:D