Hi all,

since the upgrade of icinga2 from version 2.5.4-1~ppa1~xenial1 to version 
2.6.0-2~ppa1~xenial2 and of icingaweb2 from version 2.3.4+fix-1~ppa1604+1 to 
version 2.4.0-1~ppa1604+1 Icinga Web 2 gets all sorts of timestamps wrong (e. 
g. of the last and next checks, of comments, of acknowledgement).

Here are the basics of the installation:

OS: Ubuntu 16.04.1 LTS
icinga2 -- 2.6.0-2~ppa1~xenial2
icinga2-ido-pgsql -- 2.6.0-2~ppa1~xenial
icingaweb2 -- 2.4.0-1~ppa1604+1
postgresql-9.5 -- 9.5.5-0ubuntu0.16.04

The icinga2 and icingaweb2 packages are from http://packages.icinga.org/ubuntu/ 
(icinga-xenial).

The database schema is /usr/share/icinga2-ido-pgsql/schema/pgsql.sql from the 
icinga2-ido-pgsql package, with a small correction of the functions 
from_unixtime and unix_timestamp -- see below.

The date.timezone setting is correctly configured in php.ini. When I put an 
info.php into the icingaweb2/public/ directory with the following contents:

   echo date("Y-m-d H:i:s e/Z", time())

the browser correctly gets

   2017-01-05 09:40:28 Europe/Berlin/3600

phpinfo(), too, reports the timezone as "Europe/Berlin".

The timestamps in the icinga2 database are in local time.

That's why I tried -- successfully! -- to fix the problem by altering the SQL 
functions from_unixtime and unix_timestamp thus:

*****************
* from_unixtime *
*****************
package version:

CREATE FUNCTION from_unixtime(bigint) RETURNS timestamp as '
  SELECT to_timestamp($1) AT TIME ZONE 'UTC' AS result' language sql;

my version:

CREATE FUNCTION from_unixtime(bigint) RETURNS timestamp without time zone as '
  SELECT to_timestamp($1)::timestamp without time zone AS result;' language sql;

******************
* unix_timestamp *
******************

package version:

CREATE FUNCTION unix_timestamp(timestamp) RETURNS bigint as '
  SELECT CAST(EXTRACT(EPOCH FROM $1) AS bigint) AS result;' language sql;

my version:

CREATE FUNCTION unix_timestamp(timestamp without time zone) RETURNS bigint as '
  SELECT EXTRACT(EPOCH FROM $1::timestamp with time zone)::bigint AS result;' 
language sql;

This works, but I don't know if it's worthy of being integrated into the 
ido-psql package, that's why I'd like some comments from the mailing list. 
Thanks for your input.

Cheers
Dominik

_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to