AW: AW: Displayed Timestamps on the web interface

Fiederling, Daniel daniel.fiederling at warema.de
Fri Aug 13 09:51:19 CEST 2004


Hi,

thanks for your hints. I've spent some time on trying to understand the code
- I'm unfortunately not a C crack.
I suspect that for example the cast 

  last_update=(time_t)strtoul(PQgetvalue(xsddb_pgres,tuple,2),NULL,10);
  (line 1590 in xsddb.c, procedure int xsddb_add_host_status(void))

causes the wrong timestamps. The timestamps are saved as "timestamp without
timezone" (\dt hoststatus via psql). The actual values are in localtime (as
seen by a select via psql). As far as I understand struct time_t it is
considered to by "calendar time", which is UTC (tell me if I'm wrong!)???

I can't spend more time on changing the code for now. I think, there should
be a conversion from localtime to gmt. Maybe something like
  tmp_last_update=(time_t)strtoul(PQgetvalue(xsddb_pgres,tuple,2),NULL,10);
  last_update=mktime(gmtime(&tmp_last_update));
could be a solution. If you don't disagree to my theory, I'll try it in the
next weeks.

Changing the datatype of the timestamp columns to timestamp with timezone
information may be another solutions?! Any opions?

Thanks as far for your help!
Daniel



-----Ursprungliche Nachricht-----
Von: Ethan Galstad [mailto:nagios at nagios.org]
Gesendet: Freitag, 13. August 2004 03:12
An: nagios-devel at lists.sourceforge.net
Betreff: Re: AW: [Nagios-devel] Displayed Timestamps on the web
interface


Daniel -

You can find the PostgreSQL code for status data in the xdata/xsddb.c 
file.   Code for MySQL is mixed in there as well, but the PostgreSQL 
code should be fairly evident, as it is enclosed in #define 
statements.  Let me know if you find anything wrong with the code.


On 11 Aug 2004 at 10:25, Fiederling, Daniel wrote:

> Thanks Ethan!
> 
> I suspect that reading is the problem. If I use psql to query the
> timestamps everythings seems to be ok. I've done a little very dirty
> hack to display the times correctly: just before calling
> get_time_string() for display purposes I decrease the time (-2h). For
> now I've changed extinfo.c and status.c. I've also tried to find the
> file where the reading from pgsql is done but I didn't find it. Can
> you tell me where I find this code?
> 
> As far as I know PostgreSQL uses local timezone settings (TZ
> environment variable) but that variable isn't set in my login shell -
> so I expect Apache not to set it when starting CGIs. The parameter
> "timezone" in postgresql.conf is not set, I've tried to change it -
> without success. But LC_TIME is set in postgresql.conf to "de_DE at euro"
> which was set by initdb and is correctly for my environment.
> 
> It would by nice if anyone could supply with information about using
> Nagios with PostgreSQL and the actual timezone settings.
> 
> Greets
> Daniel
> 
> 
> 
> -----Ursprungliche Nachricht-----
> Von: Ethan Galstad [mailto:nagios at nagios.org]
> Gesendet: Mittwoch, 11. August 2004 05:31
> An: nagios-devel at lists.sourceforge.net
> Betreff: Re: [Nagios-devel] Displayed Timestamps on the web interface
> 
> 
> Sounds like the time isn't being written to or read from PostgreSQL
> correctly.  I no longer have a PostgreSQL server setup, so I can't
> test this easily.  Is anyone else able to test this?
> 
> On 5 Aug 2004 at 10:42, Fiederling, Daniel wrote:
> 
> > Hi list,
> > 
> > I've already posted this to the Users-List, but there where no
> > answers. Perhaps you can help:
> > 
> > --------------------------------------------------------------------
> > -- ------ --- I have Nagios running for about 4 weeks and I really
> > like it and there is the plan to substitue BigBrother with Nagios.
> > But there is one problem with the web interface: the timestamps
> > displayed are wrong (for example in extinfo.cgi). They are always
> > +2h. The timestamp display in "Current Network Status" / Last
> > Updated (the box in the upper left) is correct.
> > 
> > I have found some questions about that issue in the list archive but
> > no answers. The FAQ says nothing about timezones / wrong timestamps.
> > Can anybody help me?
> > 
> > My system is a SuSE 8.2 box with Nagios 1.2 (2004-02-02). My system
> > time is local time (CEST), synchronized with xntp to our main time
> > server. I use PostgreSQL for data storage. The timestamps in the
> > database are displayed correct with psql - maybe psql adjusts the
> > display to the current timezone, I don't know.
> > 
> > I think, GMT is our local time - 2h, or in other words CEST is GMT+2
> > (not sure about that!). I don't know if that's a hint to the
> > problem.
> > --------------------------------------------------------------------
> > -- ------ ---
> > 
> > In the meantime I tried to alter the function get_time_string() in
> > cgiutils.c, without success. I think that timestamps read from the
> > database are thought as being UTC but they are already CEST. The
> > localtime()-call in cgiutils.c adds 2h and I get the wrong times on
> > the web interface. Any tipps for me?
> > 
> > Please help me!
> > Daniel
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by OSTG. Have you noticed the changes
> > on Linux.com, ITManagersJournal and NewsForge in the past few weeks?
> > Now, one more big change to announce. We are now OSTG- Open Source
> > Technology Group. Come see the changes on the new OSTG site.
> > www.ostg.com _______________________________________________
> > Nagios-devel mailing list Nagios-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagios-devel
> 
> 
> 
> Ethan Galstad,
> Nagios Developer
> ---
> Email: nagios at nagios.org
> Website: http://www.nagios.org
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save
> 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________ Nagios-devel mailing
> list Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel



Ethan Galstad,
Nagios Developer
---
Email: nagios at nagios.org
Website: http://www.nagios.org



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285




More information about the Developers mailing list