Problems installing PIA 2.1 on Cacti 0.8.7b + solution

Support for the Plugin Architecture

Moderators: Developers, Moderators

Post Reply
djee
Posts: 2
Joined: Wed May 28, 2008 7:06 am

Problems installing PIA 2.1 on Cacti 0.8.7b + solution

Post by djee »

I installed the above on a Debian system (although i doubt this is the cause of the problems), but not with the apt packaging system (as i wanted the PIA, which is not packaged yet for Debian). I had below two issues after install and before adding any Plugin. The solutions are scattered around on this forum in bits and pieces, for your convenience i stuffed the two solutions in one post :D

1) "Invalid PHP_SELF Path" when browsing to http://server/cacti

This can be solved by editing include/global.php, lookup the following code snippet:

Code: Select all

/* Sanity Check on "Corrupt" PHP_SELF */
if ((!is_file($_SERVER["PHP_SELF"])) && (!is_file($config["base_path"] . '/' . $_SERVER["PHP_SELF"]))) {
                if (!is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["PHP_SELF"])) {
                        if (!((is_file($_SERVER["SCRIPT_FILENAME"])) && (substr_count($_SERVER["SCRIPT_FILENAME"],
$_SERVER["PHP_SELF"])))) {
                                echo "\nInvalid PHP_SELF Path\n";
                                exit;
                        }
                }
}
and just comment it out, e.g. like this :

Code: Select all

/* Sanity Check on "Corrupt" PHP_SELF */
/* COMMENTED OUT DUE TO FAIL FOR ALIAS */
/*
if ((!is_file($_SERVER["PHP_SELF"])) && (!is_file($config["base_path"] . '/' . $_SERVER["PHP_SELF"]))) {
                if (!is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["PHP_SELF"])) {
                        if (!((is_file($_SERVER["SCRIPT_FILENAME"])) && (substr_count($_SERVER["SCRIPT_FILENAME"],
$_SERVER["PHP_SELF"])))) {
                                echo "\nInvalid PHP_SELF Path\n";
                                exit;
                        }
                }
}
*/
I understand this is a security feature that checks against the source URI, but I don't think it will ever pass when using an alias. Please let me know if it does and how I should put it to work properly (and yes, i already adapted $config['url_path'] :wink: )

2) "...cacti Passed variable is not an array..." when browsing to http://server/cacti

This was solved by editing lib/functions.php, find the following function

Code: Select all

/* read_default_config_option - finds the default value of a Cacti configuration setting
   @arg $config_name - the name of the configuration setting as specified $settings array
     in 'include/global_settings.php'
   @returns - the default value of the configuration option */
function read_default_config_option($config_name) {
        global $config, $settings;

        reset($settings);
        while (list($tab_name, $tab_array) = each($settings)) {
                if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
                        return $tab_array[$config_name]["default"];
                }else{
                        while (list($field_name, $field_array) = each($tab_array)) {
                                if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name]))
&& (isset($field_array["items"][$config_name]["default"]))) {
                                        return $field_array["items"][$config_name]["default"];
                                }
                        }
                }
        }
}
And add a check as follows:

Code: Select all

/* read_default_config_option - finds the default value of a Cacti configuration setting
   @arg $config_name - the name of the configuration setting as specified $settings array
     in 'include/global_settings.php'
   @returns - the default value of the configuration option */
function read_default_config_option($config_name) {
        global $config, $settings;
        if (is_array($settings)) {
        reset($settings);
        while (list($tab_name, $tab_array) = each($settings)) {
                if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
                        return $tab_array[$config_name]["default"];
                }else{
                        while (list($field_name, $field_array) = each($tab_array)) {
                                if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name]))
&& (isset($field_array["items"][$config_name]["default"]))) {
                                        return $field_array["items"][$config_name]["default"];
                                }
                        }
                }
        }
        }
}
This made my installation work, feel free to post any "better ways", fixes, patches i missed, ...
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

I believe that there is already a patch for this :)

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
djee
Posts: 2
Joined: Wed May 28, 2008 7:06 am

Post by djee »

Ok, was afraid that one was coming. I had a deeper look into the "official patches" section.
"Patch to Correct for a Uninitialized Settings Array When Using Superlinks Plugin" indeed is the fix for the second problem. The name of the patch however suggests the problem only occurs when using Superlinks plugin, but i had the problem already when no plugins were installed at all.

I don't find a patch that fixes the first problem however ... If you happen to have some more insight in the exact function of that check, i'm very interested also ;) !

Greets,
djee
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests