Cacti Ubuntu problemLately, I’ve been spending a lot of time with Cacti on my Ubunto 8 install. Cacti as we all know is a (great) PHP wrapper application around the rrdtool command. Cacti and rrdtool are typically used by network/systems administrators for graphing network conditions, churning out great looking graphs for various SNMP data.

I’ve been investigating whether I could use Cacti to graph other kinds of data like my website loading time etc. And, it does, brilliantly, but that’s another story for another day.

In any case, after getting Cacti running smoothly on Ubuntu, I decided to try the Cacti Plugin Architecture to see if I could learn how to build some plugins for Cacti. And it wasn’t so straightforward.

It seems the Cacti Plugin Architecture patch is not friendly towards a default Ubuntu install. That’s because Ubuntu places the Cacti files in different paces, and the Cacti Plugin hasn’t been built to support Ubuntu cacti install.

Invalid PHP_SELF path
The first telltale you will see is the “Invalid PHP_SELF Path” error message when you try to access your Cacti pages after patching. This is because a few of the $configs in global.php are wrongly pathed.

The Solution
Open up your global.php with your favourite editor. My global.php is located at /usr/share/cacti/site/include/. If you’re install is the default Ubuntu, it should be there too.

So, to get it working, you need to change the following lines in the global.php.

At line 104:
    $config["rra_path"] = $config["base_path"]."/rra";
change it to:
    $config["rra_path"] = "/var/lib/cacti/rra";
At line 128 where it says:
    $_SERVER["PHP_SELF"]
change it to:
    basename($_SERVER["PHP_SELF"])
the whole line should say:
    if (!((is_file($_SERVER[”SCRIPT_FILENAME”])) && (substr_count($_SERVER[”SCRIPT_FILENAME”], basename($_SERVER[”PHP_SELF”]))))) {
At line 201:
    include($config["library_path"]."/adodb/adodb.inc.php");
change it to:
    include("/usr/share/php/adodb/adodb.inc.php");

Also, don’t forget to update (if you haven’t done so) the following, as stated in the Plugin install docs

On line 56 Change:
    $config[’url_path’] = ‘/’;
to:
    $config[’url_path’] = ‘/cacti/’;

After this, try again, you should have your Cacti back in action. (Hopefully…)