PA 2.1 1st steps

Support for the Plugin Architecture

Moderators: Developers, Moderators

Post Reply
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

PA 2.1 1st steps

Post by divagater »

I am trying to wrap my head around the flow/usage for the features in 2.1. Right off the bat I am stuck on api_plugin_install(). The 'Plugin Management' link calls plugins.php in the root of cacti/.

plugins.php 1st calls retrieve_plugin_list() which calls the following sql:

SELECT directory FROM plugin_config ORDER BY name

I only see one place where entries are added to the plugin_config table and that is in api_plugin_install(). api_plugin_install() is only called from cacti/plugins.php and is initiated from a web request which should include mode and id. id being the name of the plugin and mode being install, uninstall, enable, etc.

cacti/plugins.php includes some links for installing, uninstalling etc. however those links are in a foreach($plugins) loop and the list of plugins is built from plugin_config which is built from api_plugin_install... so I appear to be stuck in an evil loop.

Additionally, the existance of plugin_<plugin_name>_install() in setup.php will cause the plugin to not be available at all as is the case with aggregate, do to what looks like this line in the api_plugin_hook_function method:

Code: Select all

if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
So none of the methods in setup.php will be executed if a method called plugin_<plugin_name>_install exists. So the question is, what is missing to actually kick off the process of getting a plugin "installed" in PA 2.1? It sort of looks like we need to provide the users with a well formed url to kick off the install process. Any insight appreciated as I am probably missing something obvious.

Thanks,
Billy
User avatar
TheWitness
Developer
Posts: 17059
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Billy,

Have you looked at Manage's organization of Setup.php yet? Also, ping Jimmy, he wrote it and has some unpublished plugins that use it.

Larry
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?
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Thanks for the tip, I will check out manage. I wanted to save hitting up Jimmy as a last resort hoping some one had found the solution.

Cheers,
Billy
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

TheWitness wrote:Billy,

Have you looked at Manage's organization of Setup.php yet? Also, ping Jimmy, he wrote it and has some unpublished plugins that use it.

Larry
The manage plugin was the secret sauce I needed. It was actually the readme file that saved me as it showed how a plugin should be installed in 2.x. In my case I was the cause of all the trouble. I had a copy of NPC in the plugins directory called npc-2.x.x or whatever so I could easily switch between versions for support. This was breaking the functionality of non-legacy plugins, those with a method called plugin_<plugin-name>_install. Because the new PA does a directory scan to find plugins it was finding both versions of NPC even though only one version was declared in global.php. This was causing the following fatal error breaking all 2.x plugins:

PHP Fatal error: Cannot redeclare plugin_init_npc()

Once the duplicate plugin was removed aggregate and manage show up under plugin management. I hope my folly can help others...

Cheers,
Billy
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests