pblasquez / weathermapper

Automatically generate weathermaps from a LibreNMS installation
GNU General Public License v3.0
53 stars 17 forks source link

SQL Error when running weathermapper.php #15

Open olie93 opened 4 years ago

olie93 commented 4 years ago

Hi,

When i run php weathermapper.php to generate my map i get the following error:

SQLSTATE[HY000] [2002] Connection refused

What would be the cause of this?

pblasquez commented 4 years ago

Make sure your LibreNMS conf location is correct in weathermapper.conf.php.

It uses the same DB connection mechanism as LibreNMS.

olie93 commented 4 years ago

My config is the default as my libreNMS installation is in /opt/librenms

pblasquez commented 4 years ago

Are you running the weathermapper on the same machine as the LibreNMS installation? The LibreNMS installation works correctly and does not have this error?

Usually this issue is caused by a mismatch in where mysql is listening vs where you are trying to connect. E.g., mysql is listening on 127.0.0.1 but you have configured the connection for the server IP.

Please provide more information about the mysql listener, where librenms is in running and from where it is connecting, and also where weathermapper is running and from where it is connecting.

olie93 commented 4 years ago

LibreNMS and Weathermapper are running on the same machine

LibreNMS is working without any problems

MySQL is listening on 127.0.0.1 and also the IP of the server

m3hrz4d commented 4 years ago

this seems to have become an issue due to LibreNMS removing the values for db_host, db_user, db_name and db_pass from LibreNMS' main config.php, which WeatherMapper relies on for it's db credentials.

pblasquez commented 4 years ago

@m3hrz4d thanks for pointing that out, I'll test this and put in a patch.

hanserasmus commented 3 years ago

Hi @pblasquez. Thank you for your time and trouble with this plugin. Have you perhaps had time to look into this issue. I have tried changing the location of the details to .env but then I get

php weathermapper.php 
APP_KEY=SCRUBBED

DB_HOST=localhost
DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=password

#APP_URL=
NODE_ID=SCRUBBED
LIBRENMS_USER=librenms
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 21
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 21
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 22
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 22
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 23
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 23
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 24
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 24
SQLSTATE[HY000] [1045] Access denied for user ' '@'localhost' (using password: NO)

I would really appreciate any help on this?

ZPrimed commented 2 years ago

I'll test this and put in a patch.

@pblasquez Did you ever add a patch for this (librenms moved its SQL parameters into a .env file instead of in config.php)?

What's the best way to work-around in the meantime? I have access to the .env file in /opt/librenms, so I know the name of the DB and user/pass... can those just be hardcoded in weathermapper.conf.php somehow? (I am not very experienced with PHP so I'm not sure how to set those variables to override whatever it is trying to pull from the librenms config.php...)

IPvCook commented 2 years ago

Having the same issue with

PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 21
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 21
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 22
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 22
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 23
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 23
PHP Notice:  Undefined variable: config in /opt/weathermapper/weathermapper.php on line 24
PHP Notice:  Trying to access array offset on value of type null in /opt/weathermapper/weathermapper.php on line 24

I'm going to see if I can figure out how to manually change the .php file to get that going. Looks like owner might be inactive now on github.