jarischaefer / docker-librenms

Docker image for LibreNMS
MIT License
115 stars 38 forks source link

Fail: You have a different system timezone (CST) than the php configured timezone (UTC) ? #107

Closed valsily closed 5 years ago

valsily commented 5 years ago

Hi,

I am trying to set system timezone to UTC+8 by setting TZ=Asia/Taipei but the log entries are still in UTC. Running Validate Config gives the following error in the PHP section:

Fail: You have a different system timezone (CST) than the php configured timezone (UTC)
Fix: 
Please correct either your system timezone or your timezone set in php.ini.

Are there any ways to modify the timezone settings in the php.ini?

Many thanks.

jarischaefer commented 5 years ago

Could you please post the full docker command line (without sensitive information)?

valsily commented 5 years ago

Hi,

Sorry that I configured this on a Synology NAS through its GUI. It took me some time to figure out how to extract the docker command from an existing container. Below is what I extracted from the LibreNMS container. Many thanks for looking into this for me.

docker run --name=jarischaefer-docker-librenms1 \ --hostname=librenms \ --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ --env=LIBRENMS_VERSION=1.53.1 \ --env=LIBRENMS_WEATHERMAP_VERSION=5bb4fcccbaa9f5801325b9d79e811575c37fd84e \ --env=TZ=Asia/Taipei \ --env=RRDCACHED_LISTEN=unix:/var/run/rrdcached/rrdcached.sock \ --env=RRDCACHED_CONNECT=unix:/var/run/rrdcached/rrdcached.sock \ --env='SNMP_SCAN_CRON=0 0 ' \ --env='WEATHERMAP_CRON=/5 ' \ --env=POLLERS=8 \ --env='POLLERS_CRON=/5 *' \ --env=APP_KEY=base64:** \ --env=DB_HOST=192.168.2.92 \ --env=DB_NAME=librenms \ --env=DB_USER=librenms \ --env=DB_PASS=*** \ --env=BASE_URL=http://192.168.2.92:7080 \ --volume=/volume3/docker/LibreNMS/data/logs:/opt/librenms/logs:rw \ --volume=/volume3/docker/LibreNMS/data/rrd:/opt/librenms/rrd:rw \ --volume=/opt/librenms/rrd \ --volume=/opt/librenms/html/plugins/Weathermap/configs \ --volume=/var/log/nginx \ --volume=/opt/librenms/logs \ --volume=/opt/librenms/html/plugins/Weathermap/output \ --volume=/etc/nginx/ssl \ --volume=/opt/librenms/storage \ -p 0.0.0.0:10443:443 -p 0.0.0.0:7080:80 \ --restart=no \ --log-driver=db \ --detach=true jarischaefer/docker-librenms /sbin/my_init

jarischaefer commented 5 years ago

The timezone should be automatically detected and set in

There are no validation errors on my test container using Asia/Taipei. Since I am unable to reproduce the problem, we will have to gather more information.

Could you please run the following commands and post the ouput?

docker exec jarischaefer-docker-librenms1 php -i | grep -i timezone docker exec jarischaefer-docker-librenms1 php-fpm7.3 -i | grep -i timezone docker exec jarischaefer-docker-librenms1 php -r 'echo date("T") . PHP_EOL;'

valsily commented 5 years ago

Hi,

Please see below for output from each line of commands. Thank you.

docker exec jarischaefer-docker-librenms1 php -i | grep -i timezone

/etc/php/7.3/cli/conf.d/100-timezone.ini, "Olson" Timezone Database Version => 0.system Timezone Database => internal Default timezone => UTC date.timezone => UTC => UTC

docker exec jarischaefer-docker-librenms1 php-fpm7.3 -i | grep -i timezone

/etc/php/7.3/fpm/conf.d/100-timezone.ini, "Olson" Timezone Database Version => 0.system Timezone Database => internal Default timezone => UTC date.timezone => UTC => UTC

docker exec jarischaefer-docker-librenms1 php -r 'echo date("T") . PHP_EOL;'

UTC

jarischaefer commented 5 years ago

Alright, so /etc/php/7.3/cli/conf.d/100-timezone.ini probably contains the wrong configuration.

Please also check docker exec jarischaefer-docker-librenms1 cat /etc/php/7.3/cli/conf.d/100-timezone.ini docker exec jarischaefer-docker-librenms1 env | grep TZ

valsily commented 5 years ago

Sorry for the late response. Please see below:

docker exec jarischaefer-docker-librenms1 cat /etc/php/7.3/cli/conf.d/100-timezone.ini

date.timezone=UTC

docker exec jarischaefer-docker-librenms1 env | grep TZ

TZ=Asia/Taipei

jarischaefer commented 5 years ago

Please try stopping and then removing the container. This will destroy the container's virtual filesystem, including any stale configuration files.

valsily commented 5 years ago

Thank you so much!! By removing the container and re-creating it with the same commands (and new APP_KEY), it is now showing log entries with correct local time.

docker exec jarischaefer-docker-librenms1 cat /etc/php/7.3/cli/conf.d/100-timezone.ini

date.timezone=Asia/Taipei

And I just think it over again, the problem might be caused by the procedure I created the original container. The TZ variable was actually added after I created the container (through Synology Docker app GUI) when I realized the system was in UTC timezone. Although I restarted the container after adding the TZ variable, it obviously did not work.