Trying to access Cacti's web page results in a PHP error.

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
PaydenKP
Posts: 5
Joined: Tue Apr 25, 2017 9:06 am

Trying to access Cacti's web page results in a PHP error.

Post by PaydenKP »

I'm putting this in General, because I can't be sure the issue is caused by me using Linux. The computer running with Cacti on it is the following:

Code: Select all

Linux cacti-server 4.10.10-200.fc25.x86_64 #1 SMP Thu Apr 13 01:11:51 UTC 2017 x86_64 GNU/Linux
It's using Arch's repos, but Fedora's kernel.

Specific error:

Code: Select all

[Tue Apr 25 14:05:01.853727 2017] [proxy_fcgi:error] [pid 25790] [client 192.168.5.5:33550] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Undefined class constant 'MYSQL_ATTR_FOUND_ROWS' in /usr/share/webapps/cacti/lib/database.php:52
Stack trace:
#0 /usr/share/webapps/cacti/include/global.php(207): db_connect_real('192.168.5.200', 'cacti_user', 'Cacti_Pass', 'cacti_DB', 'mysql', '3306', false)
#1 /usr/share/webapps/cacti/include/auth.php(27): include('/usr/share/weba...')
#2 /usr/share/webapps/cacti/index.php(25): include('/usr/share/weba...')
#3 {main}
 thrown in /usr/share/webapps/cacti/lib/database.php on line 52'
This is when going to hostname.com/cacti on a machine running a LAP configuration. Specifically, Linux, Apache, and PHP. I have a MariaDB MySQL server running on another machine on the LAN.

This same host is running PHPMyAdmin, and other web services which are working fine. PHPMyAdmin can connect to the MariaDB database as well.

Special things to consider:
  • 1. I've configured the config file under /etc/webapps/cacti/config.php for the remote server as well as the MySQL database (i.e. added user, gave privileges, etc). Because of this, I haven't installed mariadb on the server hosting cacti.
  • 2. The list of dependencies for cacti on Arch basically require installing Wayland and Mesa (display server and driver) for cairo. Specifically, it goes: rrdtool < pango < cairo < libgl < mesa < wayland. Where < means "depends on". I've opted to not do this and just copy the libGL.so file to the correct place, and install pango and rrdtool. I *could* be missing a symlink somewhere, but this is probably 100% unrelated to this issue.
While I've done stuff that's off the beaten path, I don't understand why any of it would make PHP throw an error when accessing a MySQL database because of an "Undefined class constant 'MYSQL_ATTR_FOUND_ROWS'".

Any help is appreciated.
PaydenKP
Posts: 5
Joined: Tue Apr 25, 2017 9:06 am

Re: Trying to access Cacti's web page results in a PHP error

Post by PaydenKP »

Is this just an odd error that no one has any idea on, or did I do something that should obviously break it that isn't obvious to me?
cigamit
Developer
Posts: 3368
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: Trying to access Cacti's web page results in a PHP error

Post by cigamit »

That generally means that you don't have php-pdo or php-mysql installed.
PaydenKP
Posts: 5
Joined: Tue Apr 25, 2017 9:06 am

Re: Trying to access Cacti's web page results in a PHP error

Post by PaydenKP »

cigamit wrote:That generally means that you don't have php-pdo or php-mysql installed.
That's what I had thought, however:

Code: Select all

[root@httpd ~]# grep -i pdo_mysql.so database.txt 
/usr/lib/php/modules/pdo_mysql.so
[root@httpd ~]# cat /etc/php/php.ini | grep pdo_mysql.so
extension=pdo_mysql.so
[root@httpd ~]# grep -i mysqli.so database.txt 
/usr/lib/php/modules/mysqli.so
[root@httpd ~]# cat /etc/php/php.ini | grep mysqli.so
extension=mysqli.so
Note that database.txt is just "find / > ~/database.txt" (so a listing of every file on my system). So I have the extension, it's uncommented in the php.ini file, and said extension is working fine for other web services such as PHPMyAdmin.

Checking "/srv/http/index.php" on the system attempting to run Cacti, which contains nothing but:
<?php phpinfo(); ?>
And it shows the following for mysqli:

Code: Select all

mysqli

MysqlI Support	enabled
Client API library version	mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $
Active Persistent Links	0
Inactive Persistent Links	0
Active Links	0
Directive	Local Value	Master Value
mysqli.allow_local_infile	On	On
mysqli.allow_persistent	On	On
mysqli.default_host	no value	no value
mysqli.default_port	3306	3306
mysqli.default_pw	no value	no value
mysqli.default_socket	/run/mysqld/mysqld.sock	/run/mysqld/mysqld.sock
mysqli.default_user	no value	no value
mysqli.max_links	Unlimited	Unlimited
mysqli.max_persistent	Unlimited	Unlimited
mysqli.reconnect	Off	Off
mysqli.rollback_on_cached_plink	Off	Off
The PDO section shows the following:

Code: Select all

PDO

PDO support	enabled
PDO drivers	no value
That's strange. Checking the configure command options for PHP on that page shows:

Code: Select all

'--with-pdo-dblib=shared,/usr' '--with-pdo-mysql=shared,mysqlnd' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-pgsql=shared' '--with-pdo-sqlite=shared,/usr'
Could this be caused by not having a MySQL service installed on the same machine as PHP? Again, I'd find that weird since I would think all that's needed to access a remote MySQL database is a driver for MySQL, and since it's working for PHPMyAdmin I wouldn't expect that to be the problem, but I've experienced weirder things.

Note: This is PHP Version 7.1.4.
PaydenKP
Posts: 5
Joined: Tue Apr 25, 2017 9:06 am

Re: Trying to access Cacti's web page results in a PHP error

Post by PaydenKP »

Reinstalling from scratch fixed this issue but caused another which I resolved later.
Post Reply

Who is online

Users browsing this forum: cigamit, cpntblues63 and 3 guests