Cacti Usr Share Php Adodb Drivers Adodb Mysql Inc Php

Active7 years, 2 months ago

I am currently setting up a new Debian (6.0.5) server. I put Cacti (0.8.7g) on it yesterday and have been battling with it ever since.

Initial issue

  • Jun 01, 2010  Bottom line is that the mysql_pconnect() is a mysql module function and adodb has nothing to do with it. So, my suspicion is that PHP is not configured properly for Apache. Running phpinfo() will confirm.
  • Red Hat Bugzilla – Bug 1390770. Cacti needs to be ported to PHP 7. Last modified: 2017-01-28 19:20:18 EST.

Sep 27, 2013  Cacti Running Out Of Memory In adodb.inc.php Leave a comment Posted by newspaint on September 27, 2013 I upgraded Debian to Wheezy testing and suddenly Cacti stopped working. Nov 06, 2007  Configuration in /etc/cacti/debian.php: php ## ## database access settings in php format ## automatically generated from /etc/dbconfig-common/cacti.conf.

The initial issue I was observing, was that my graphs weren't updating. So I checked my cacti.log and found this concerning message:

I recently upgraded to PHP7 and Cacti 1.0, but while the webinterface continues to work as before, the poller seems to ignore the credentials that are present, correct and working in include/config.php. Root@hades:~# sudo -u www-data php. WINNT 4 Workstation, PHP4 odbc_connect() kept giving me weird errors when trying to connect to a MSaccess DSN(Microsoft Jet engine couldn't open the database 'Unknow'.

That can't be good, right? So I went checking and started poller.php myself (via sudo -u www-data php poller.php --force). It will pump out a lot of messages (which all look like what I would expect) and then hang for a minute. After that 1 minute, it will loop the following message:

This goes on for 4 more minutes until the process is forcefully ended for running longer than 298s.

So far so good

I went on for a good hour trying to determine what poller might still be running, until I got to the conclusion that there simply is no running poller.

Debugging

I checked poller.php to see how that warning is issued and why. On line 368, Cacti will retrieve the number of finished processes from the database and use that value to calculate how many processes are still running. So, let's see that value!

I added the following debug code into poller.php:

Result

This will print the following within a second of starting poller.php:

Cacti Usr Share Php Adodb Drivers Adodb Mysql Inc Php Insurance

So the values are being read and are valid. Until we get to the part where it keeps looping:

Suddenly, the value is gone. Why? Putting var_dump() in there confirms the issue:

The return value is NULL. How can that be when querying SELECT COUNT()..? (SELECT COUNT() should always return one result row, shouldn't it?)

More debugging

So I went into libdatabase.php and had a look at that db_fetch_cell(). A bit of testing confirmed, that the result set is actually empty.

So I added my own database query code in there to see what that would do:

Jo beverley book list. This will output

So, the data is there and can be accessed without any problems, just not with the method Cacti is using?

Double-check that!

I enabled MySQL logging to make sure I'm not imagining things. Sure enough, when the error message is looped, the cacti.log reads as if it was querying like mad:

But none of these queries are logged by MySQL. Yet, when I add my own database query code, it shows up just fine.

What the heck is going on here?

Digging deeper..

I concluded that the database connection must be lost somewhere in the process and adodb simply doesn't care.

So after a bit of digging around, I finally placed the debug message in drivers/adodb-mysql.inc.php, line 529, in the _close function. I wanted to see when the connection is closed.

I actually (finally) turned on PHP debugging and realized mysql_query() was called with a boolean connection id (an indicator of an intentionally closed connection).

What does that print?

And now I'm too tired to investigate that..

Der Hochstapler
Der HochstaplerDer Hochstapler
2,90515 gold badges43 silver badges76 bronze badges

1 Answer

I did investigate a bit further and realized the closing of the connection to the database is intentional. The connection should be reestablished for the next polling run. But it isn't.

Here's an excerpt from poller.php:

I also checked db_connect_real and it is, in fact, called after usleep completes. So that's where I will keep digging.

For the time being, I modified the section like this:

Now the poller runs without any warnings and my graphs are being drawn. Yet, there's still an issue. Not all of my graphs are being drawn properly, as can be seen from the following image:

I assumed this is due to the poller running too rarely for certain data sources. To solve that, I switched to spine (which I wanted to do anyway) and set it to use 4 threads.

So far, so good..

Update

I dug deeper into this issue and thought I had fixed it. I assumed the connection is not properly stored after the reconnect attempt of the poller.

My attempt to resolve that looked promising at first, but the resulting graphs were still faulty. So the problem lies deeper.

The workaround I developed earlier and presented in this answer still works perfectly. I decided to not invest any more time on this issue and stay with the workaround. Sorry.

Der HochstaplerDer Hochstapler
2,90515 gold badges43 silver badges76 bronze badges

Cacti Usr Share Php Adodb Drivers Adodb Mysql Inc Php Agency

Not the answer you're looking for? Browse other questions tagged phpdebian-squeezecacti or ask your own question.