Docker-Nagios icon indicating copy to clipboard operation
Docker-Nagios copied to clipboard

Wrong Date

Open darox opened this issue 7 years ago • 5 comments

Unfortunately the date is wrong under last check:, how can this be fixed? wrongdate

darox avatar Dec 03 '17 18:12 darox

Hello, I also ran into this awhile back and while this isn't the most elegant solution it worked well for me.

From w/in your nagios container: In order to change timezone, remove the /etc/localtime and assign symbolic link to your desired city.

root@08ec913f43f8:/usr/share/zoneinfo# rm /etc/localtime root@08ec913f43f8:/usr/share/zoneinfo# ln -s /usr/share/zoneinfo/America/New_York /etc/localtime root@08ec913f43f8:/usr/share/zoneinfo# date Thu Feb 23 08:57:53 EST 2017

Thanks for the excellent work Jason in making this image.

After noting that you're asking about "Wrong Date" the above may NOT help your situation. Nonetheless, that is something I've had to do.... ;-)

-Greg

thinkitdata avatar Dec 12 '17 20:12 thinkitdata

Thanks for this information @thinkitdata. Sorry for the lack of response @darox Work has been a little hectic. I'm trying to work out how best to deal with this, IIRC the image currently uses UTC, (I could be wrong), perhaps mounting /etc/localtime from the host system is a good idea, alternatives would be to have an environment variable to set this, but this means that one must know exactly what the file is on disk, which could be an issue.

I think my preference would be mounting /etc/localtime from the host, as assuming the host time is correct, the container will also have the correct time, at the very least, the container will have the same timezone as the host in this case, which is probably the best-case-scenario.

Thanks for the kind words @thinkitdata

@darox Please could you confirm if this is a timezone issue or if it's more than that? it would be useful to run the command "date" on both the docker host, and within the container at roughly the same time (a few seconds either way isn't an issue).

/J

JasonRivers avatar Dec 12 '17 23:12 JasonRivers

@JasonRiversThanks for responding! I run the date command and the time and date was correct om the host amd docker container.

darox avatar Dec 13 '17 05:12 darox

@darox Thanks for this, so the only thing that's wrong is nagios? I may have to look a little deeper in to this, Please could you paste a screenshot of the date command and the nagios page taken roughly at the same time?

JasonRivers avatar Dec 13 '17 09:12 JasonRivers

The shortest possible way I found to fix timezone issue was Dockerfile like this:

FROM jasonrivers/nagios
ENV TZ=Europe/Berlin
RUN echo "SetEnv TZ $TZ" > /etc/apache2/conf-available/timezone.conf

PassEnv doesn't work for me. ENV is not required, so it's possible pass Europe/Berlin directly. Waiting for update :) 👍

Update: Sorry, I found useful NAGIOS_TIMEZONE in the documentation which solves my problem :)

panov-andy avatar Jul 25 '18 09:07 panov-andy