On a clean Cacti 1.2.31 install from a tarball:
NOTE: Plugin mactrack installed successfully.
NOTE: Plugin mactrack enabled.
Mactrack plugin is not enabled (status: 2)
Status 2 is "needs configuration". lib/plugins.php:773 sets it when api_plugin_check_config() returns false.
plugin_mactrack_check_config() gates enablement on loading Net_DNS2, whose autoloader resolves classes with a relative include:
// Net/DNS2.php:302
include str_replace('_', '/', $name) . '.php';
That only resolves when the plugin directory is the current directory or on include_path. mactrack_resolver.php calls chdir(__DIR__) before loading it, so that path is fine. Cacti calls plugin_mactrack_check_config() from the web root and from cli/plugin_manage.php, neither of which changes directory, so Net_DNS2_Resolver never loads and the check fails.
Reproduced directly inside the install:
Net/DNS2.php is_file: true
PHP Warning: include(Net/DNS2/Resolver.php): Failed to open stream: No such file or directory
in .../plugins/mactrack/Net/DNS2.php on line 302
plugin_mactrack_check_config() => false
The gate did not exist before #336:
function plugin_mactrack_check_config() {
// Here we will check to ensure everything is configured
mactrack_check_upgrade();
return true;
}
plugin_flowview vendors the same library and does not reference it in setup.php either. DNS resolution is an optional collector feature used by one CLI script, so it should not gate enablement.
Fixed in #345: restore the original body, and add the plugin directory to include_path in the resolver so the autoloader no longer depends on the chdir side effect. The resolver's require_once is also guarded with is_file() so the diagnostic below it is reachable, which is what turned the #336 mistake into a fatal instead of a log line.
Related to #346.
On a clean Cacti 1.2.31 install from a tarball:
Status 2 is "needs configuration".
lib/plugins.php:773sets it whenapi_plugin_check_config()returns false.plugin_mactrack_check_config()gates enablement on loading Net_DNS2, whose autoloader resolves classes with a relative include:That only resolves when the plugin directory is the current directory or on
include_path.mactrack_resolver.phpcallschdir(__DIR__)before loading it, so that path is fine. Cacti callsplugin_mactrack_check_config()from the web root and fromcli/plugin_manage.php, neither of which changes directory, soNet_DNS2_Resolvernever loads and the check fails.Reproduced directly inside the install:
The gate did not exist before #336:
plugin_flowview vendors the same library and does not reference it in setup.php either. DNS resolution is an optional collector feature used by one CLI script, so it should not gate enablement.
Fixed in #345: restore the original body, and add the plugin directory to
include_pathin the resolver so the autoloader no longer depends on the chdir side effect. The resolver'srequire_onceis also guarded withis_file()so the diagnostic below it is reachable, which is what turned the #336 mistake into a fatal instead of a log line.Related to #346.