kozfelipe / centreon-weathermap

network weathermap module for centreon
5 stars 1 forks source link

PHP warnings #2

Closed Rico29 closed 8 months ago

Rico29 commented 1 year ago

Hello I installed your adapted weathermap in centreon, using php8.1

problem is that the created service "weathermap poller" calls the following command using centreon-engine user :

php /usr/share/centreon/www/modules/centreon-weathermap/php/../poller.php

which results in errors :

# sudo -u centreon-engine php  /usr/share/centreon/www/modules/centreon-weathermap/php/../poller.php
PHP Warning:  require(/etc/centreon/centreon.conf.php): Failed to open stream: Permission denied in /usr/share/centreon/config/centreon.config.php on line 40

Warning: require(/etc/centreon/centreon.conf.php): Failed to open stream: Permission denied in /usr/share/centreon/config/centreon.config.php on line 40
PHP Fatal error:  Uncaught Error: Failed opening required '/etc/centreon/centreon.conf.php' (include_path='.:/usr/share/php') in /usr/share/centreon/config/centreon.config.php:40
Stack trace:
#0 /usr/share/centreon/www/class/centreonDB.class.php(40): require_once()
#1 /usr/share/centreon/www/modules/centreon-weathermap/poller.php(10): require('...')
#2 {main}
  thrown in /usr/share/centreon/config/centreon.config.php on line 40

Fatal error: Uncaught Error: Failed opening required '/etc/centreon/centreon.conf.php' (include_path='.:/usr/share/php') in /usr/share/centreon/config/centreon.config.php:40
Stack trace:
#0 /usr/share/centreon/www/class/centreonDB.class.php(40): require_once()
#1 /usr/share/centreon/www/modules/centreon-weathermap/poller.php(10): require('...')
#2 {main}
  thrown in /usr/share/centreon/config/centreon.config.php on line 40

/usr/share/centreon/config/centreon.config.php tried to include : require _CENTREONETC . '/centreon.conf.php';

so I've set-up a crontab qhich generates the output images

# tail /etc/cron.d/centreon -n2

# Cron for weathermaps generation
*/2 * * * * root php  /usr/share/centreon/www/modules/centreon-weathermap/php/../poller.php

but I still have warnings like :

Deprecated: Function strftime() is deprecated in /usr/share/centreon/www/modules/centreon-weathermap/src/lib/Weathermap.class.php on line 3207
PHP Deprecated:  Implicit conversion from float 84.5 to int loses precision in /usr/share/centreon/www/modules/centreon-weathermap/src/lib/WeatherMapNode.class.php on line 640

Deprecated: Implicit conversion from float 84.5 to int loses precision in /usr/share/centreon/www/modules/centreon-weathermap/src/lib/WeatherMapNode.class.php on line 640
PHP Deprecated:  Implicit conversion from float 101.5 to int loses precision in /usr/share/centreon/www/modules/centreon-weathermap/src/lib/WeatherMapNode.class.php on line 640
kozfelipe commented 1 year ago

Hi @Rico29, seems your poller.php has not enough permissions to reach centreon.conf.php which grants weathermap access to the database. You may try to increase it using chmod, also, ensure these directories have write permission:

/usr/share/centreon/www/modules/centreon-weathermap/src/configs
/usr/share/centreon/www/modules/centreon-weathermap/src/output
/usr/share/centreon/www/modules/centreon-weathermap/src/images

you may ignore those deprecated warnings or omit them, prepending a @ operator

let me know if you managed to fix it by changing permissions

Tolkyen commented 8 months ago

Hello, I'm getting the same error messages as Rico29. I've made sure that these directories have write permissions /usr/share/centreon/www/modules/centreon-weathermap/src/configs /usr/share/centreon/www/modules/centreon-weathermap/src/output /usr/share/centreon/www/modules/centreon-weathermap/src/images

kozfelipe commented 8 months ago

hi @Tolkyen, have you ensure centreon-engine is the owner of output directory?

Tolkyen commented 8 months ago

Yes, this is the current setting image

kozfelipe commented 8 months ago

@Tolkyen can you show how are permission settings for poller.php?

Tolkyen commented 8 months ago

image

kozfelipe commented 8 months ago

sudo chown -R apache:apache /usr/share/centreon/www/modules/centreon-weathermap/ chown -R centreon-engine:apache /usr/share/centreon/www/modules/centreon-weathermap/src/output/ chmod 777 /usr/share/centreon/www/modules/centreon-weathermap/poller.php

I got the following output without errors: 2024-03-04 18:48 - 0 processed

image

can you confirm these steps?

I used php 8.1.12 -rw-r--r-- 1 apache apache /etc/centreon/centreon.conf.php

Tolkyen commented 8 months ago

Hi @kozfelipe, I followed your instructions. I've found the reason for the error: you need to add read access for others to the /etc/centreon/centreon.conf.php file.. This is less secure than what the centreon documentation recommends (https://docs.centreon.com/docs/23.04/administration/secure-platform/#securing-configuration-files).

Thank you for your help.

kozfelipe commented 8 months ago

Very well, I'm glad you made it