Couldn't add a map file

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Couldn't add a map file

Post by JLo8 »

Hello,

I am new to weathermap and I couldn't add a new map successfully.
It didn't show the "config file" and "title" after adding the new map.

Here are the current Cacti configuration.

Cacti version : 0.8.8f
OS : Ubuntu 16.04.1 LTS
PHP version : 5.6.25
Apache version : 2.4.18
MySQL version : 5.7.13
Weathermap version: 0.98

Here are the log messages in /var/log/apache2/error.log file

[Sun Sep 04 11:24:10.344344 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP Warning: mysql_insert_id(): Access denied for user ''@'localhost' (using password: NO) in /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php on line 843, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344361 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP Stack trace:, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344371 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 1. {main}() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:0, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344380 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 2. add_config() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:274, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344389 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 3. mysql_insert_id() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:843, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344416 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP Warning: mysql_insert_id(): A link to the server could not be established in /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php on line 843, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344426 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP Stack trace:, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344435 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 1. {main}() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:0, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344444 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 2. add_config() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:274, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker
[Sun Sep 04 11:24:10.344453 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP 3. mysql_insert_id() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:843, referer: http://192.168.1.105/cacti/plugins/weat ... map_picker



Anyone can help on this issue?
Thanks so much.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

Code: Select all

[Sun Sep 04 11:24:10.344344 2016] [:error] [pid 4683] [client 192.168.1.102:52021] PHP Warning: mysql_insert_id(): Access denied for user ''@'localhost' (using password: NO) in /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php on line 843, referer: http://192.168.1.105/cacti/plugins/weathermap/weathermap-cacti-plugin-mgmt.php?action=addmap_picker
This is strange. It looks like the mysql user can't write to the database (mysql perms, not linux perms). It also looks like there is no username, just '' there.

Is this with Cacti installed from Ubuntu packages? Config files move around in the packaged version.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

Hi Howie,

Yes, Cacti installed from Ubuntu packages.
I installed it with this command => apt-get install cacti cacti-spine

How can I fix this issue?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

I don't know, but I can test on a VM now.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

Thanks Howie. 8) :D
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

And how did you install PHP 5.6 (that's not the default for Ubuntu 16.04, or even in the default package repo)? Then I can recreate your environment properly.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

Yes, you are right. PHP5.6 isn't the default package for Ubuntu 16.04.

I used the method that mention in the following URL.

http://askubuntu.com/questions/756879/c ... untu-16-04

Using PHP PPA to coinstall PHP 5.6 with PHP 7.0
=> sudo add-apt-repository ppa:ondrej/php
=> sudo apt-get update
=> sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-
mod-php5.6 libapache2-mod-php7.0

Switch PHP version ( Apache ):
from php5.6 to php7.0:
=>sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
from php7.0 to php5.6:
=>sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

BTW, I also installed the following packages.

apt-get install php5.6-common php5.6-cli php5.6-xml php5.6-snmp php5.6-gd

Besides, I remove the php symbolic link that pointing to /usr/bin/php7.0

rm /etc/alternatives/php

And add another php symbolic link that pointing to /usr/bin/php5.6

ln -s /usr/bin/php5.6 php5.6 php
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

Thanks - I can reproduce now. I created a github issue for this (I'll update this thread too though - I just wanted somewhere searchable to save the details)

https://github.com/howardjones/network- ... /issues/38
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

The Debian/Ubuntu package configures Cacti to use mysqli instead of mysql. Weathermap uses mysql_ (in this version) throughout. This specific error can be fixed by replacing `mysql_insert_id()` with `db_fetch_insert_id()` on line 843 of `weathermap-cacti-plugin-mgmt.php`, but you will immediately hit other issues with `mysql_real_escape_string` which is more widely used (nearly anywhere a value is changed in the database).

The next release replaces all of this with PDO for all database access in Weathermap.

The fixes are:

1) wait for 0.98a which doesn't use the same database code for other reasons anyway.

or 2) get Cacti to use the older 'mysql' driver, which the source-installed version does by default. However, I just tried changing the line in the /etc/cacti/debian.php file back to mysql from mysqli and the adodb files for that are missing too, even though the php extension is present, so it isn't that straightforward.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

Thanks a lot!
I understand now.
I better wait for 0.98a.
May I know the earliest possible release day of 0.98a? :lol:
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

:lol:

Actually, I just removed the last "old style" database code. I still need to go through the data source plugins (some use DB access) and obviously lots of testing. So - maybe next week earliest?
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
JLo8
Posts: 7
Joined: Sat Sep 03, 2016 10:28 pm

Re: Couldn't add a map file

Post by JLo8 »

Thank you for your hard working.
Can't wait to hear your good news. 8)
ceenizz
Posts: 5
Joined: Wed Mar 29, 2017 9:36 am

Re: Couldn't add a map file

Post by ceenizz »

I have just run into this problem or something very much like it. When I try to add example.conf nothing happens and through the editor when i try to create a config file it does not populate in the directory.


I am running
cacti 0.8.8f
weathermaps 0.98
mysql 5.7.17
ubuntu 16.04
php 5.6

I was getting these two errors initially in the cacti log

03/29/2017 02:57:54 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"update weathermap_maps set filehash=LEFT(MD5(concat(id,configfile,rand())),20) where id='
03/29/2017 02:57:54 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"insert into weathermap_auth (mapid,userid) VALUES (,1)'


Thanks to this post I looked in /var/log/apache2/error.log and found

[Wed Mar 29 14:57:54.648253 2017] [:error] [pid 24418] [client 10.3.7.118:2772] PHP Warning: mysql_insert_id(): A link to the server could not be established in /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php on line 843, referer: http://10.3.7.117/cacti/plugins/weather ... map_picker
[Wed Mar 29 14:57:54.648260 2017] [:error] [pid 24418] [client 10.3.7.118:2772] PHP Stack trace:, referer: http://10.3.7.117/cacti/plugins/weather ... map_picker
[Wed Mar 29 14:57:54.648267 2017] [:error] [pid 24418] [client 10.3.7.118:2772] PHP 1. {main}() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:0, referer: http://10.3.7.117/cacti/plugins/weather ... map_picker
[Wed Mar 29 14:57:54.648275 2017] [:error] [pid 24418] [client 10.3.7.118:2772] PHP 2. add_config() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:274, referer: http://10.3.7.117/cacti/plugins/weather ... map_picker
[Wed Mar 29 14:57:54.648282 2017] [:error] [pid 24418] [client 10.3.7.118:2772] PHP 3. mysql_insert_id() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin-mgmt.php:843, referer: http://10.3.7.117/cacti/plugins/weather ... map_picker




So i took some of the recommended action replacing the bits of PHP code replacing `mysql_insert_id()` with `db_fetch_insert_id()` on line 843 of `weathermap-cacti-plugin-mgmt.php`

then further replacing `mysql_real_escape_string` with `mysqli_real_escape_string`

I did this using sed while in /usr/share/cacti/site/plugins/weathermap/ like this:


sed 's/mysql_insert_id/db_fetch_insert_id/g' weathermap*

and

sed 's/mysql_real_escape_string/mysqli_real_escape_string/g' weathermap*

now I see that output/ is populated with the various files put there by example.conf and I am nolonger getting any errors in the cacti log but I still dont see and filename in the map manager through cacti and I get a "broken image" icon at the top of the map.


I feel like Im getting closer to fixing this but I am at somewhat of a loss is there anything further you can recommend to help?

also when do you expect to release 0.98a?


p.s. I am now seeing

[Wed Mar 29 15:20:21.367770 2017] [:error] [pid 26167] [client 10.3.7.118:3277] PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin.php on line 654, referer: http://10.3.7.117/cacti/plugins/weather ... plugin.php
[Wed Mar 29 15:20:21.367777 2017] [:error] [pid 26167] [client 10.3.7.118:3277] PHP Stack trace:, referer: http://10.3.7.117/cacti/plugins/weather ... plugin.php
[Wed Mar 29 15:20:21.367784 2017] [:error] [pid 26167] [client 10.3.7.118:3277] PHP 1. {main}() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin.php:0, referer: http://10.3.7.117/cacti/plugins/weather ... plugin.php
[Wed Mar 29 15:20:21.367793 2017] [:error] [pid 26167] [client 10.3.7.118:3277] PHP 2. weathermap_translate_id() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin.php:27, referer: http://10.3.7.117/cacti/plugins/weather ... plugin.php
[Wed Mar 29 15:20:21.367801 2017] [:error] [pid 26167] [client 10.3.7.118:3277] PHP 3. mysqli_real_escape_string() /usr/share/cacti/site/plugins/weathermap/weathermap-cacti-plugin.php:654, referer: http://10.3.7.117/cacti/plugins/


in /var/log/apache2/error.log
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Couldn't add a map file

Post by Howie »

If you are using php 5.6, you can use "mysql" instead of "mysqli" for the database type in the cacti config.php, which solves the problem by going backwards :-)

Or you could live life on the edge and try the not-really-supported-or-finished dev version, which is nearly all converted to use PDO now:
https://github.com/howardjones/network- ... e-refactor
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests