Page 1 of 1

Nagios' $LONGDATETIME$ different from system date

Posted: Thu Aug 14, 2014 6:03 am
by sebastiaopburnay
Hi!

I'm running a Nagios Core 3.5.0 on a 64 bit Ubuntu Server 12.0.4 LTS.

- I have an '@horly ntpdate <Portuguese-NTP-IP>' entry on my server's crontab
- I also have a 'use_timezone=Europe/Lisbon' on my nagios.cfg file.

Consequently:
- I always get good values for a shell command 'date'
- my nagios web interface always displays correct date/time.

Yet, when I use the Nagios' Macro $LONGDATETIME$ in my notification commands/scripts, I get a timestamp with local time minus one hour.

I've made a simple php script and placed it under /usr/local/nagios/share:

Code: Select all

<?php
if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}
if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone');
}
echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
?>
When I open it (http://my-nagios-server/nagios/GetTimeZone.php, I get a page with:
date_default_timezone_set: Europe/Paris
Europe/Paris => Europe/Paris => CEST
If I was getting Paris Time, I would get a time-stamp with local time plus one hour and not minus one hour as I'm getting.

Do you understand why this happens (I'm worried about the $LONGDATETIME$, not about the php timezone output)

Furthermore, I've run the command 'dpkg-reconfigure tzdata' and selected (the already predefined value Europe/Lisbon). In the end, it returned:
Current default time zone: 'Europe/Lisbon'
Local time is now: Thu Aug 14 12:34:32 WEST 2014.
Universal Time is now: Thu Aug 14 11:34:32 UTC 2014.
Could it be that my Nagios' $LONGDATETIME$ is being populated by this UTC hour?

Re: Nagios' $LONGDATETIME$ different from system date

Posted: Thu Aug 14, 2014 8:43 pm
by sreinhardt
More than likely the nagios daemon was started and has been running from a point where the systems time or timezone were off by an hour from what you are using now due to an ntp update. It is possible that it is somehow capturing that utc timezone, but it should be taking the local system time and keeping an internal counter if i recall, of the current time as nagios sees it, much like mysql does.