Ad Widget

Collapse

{TIME} macro displays UTC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gelowe
    Member
    • Jun 2008
    • 30

    #1

    {TIME} macro displays UTC

    *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
    Last edited by gelowe; 27-06-2010, 04:44. Reason: problem solved
  • gelowe
    Member
    • Jun 2008
    • 30

    #2
    More info

    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

    Comment

    • gelowe
      Member
      • Jun 2008
      • 30

      #3
      *solved*

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

      dpkg-reconfigure tzdata

      Comment

      Working...