Nagios' $LONGDATETIME$ different from system date

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
sebastiaopburnay
Posts: 105
Joined: Sun Oct 31, 2010 1:40 pm
Location: Lisbon, Portugal

Nagios' $LONGDATETIME$ different from system date

Post 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?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Nagios' $LONGDATETIME$ different from system date

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked