[SOLVED] Plugin Architecture v2.0 bug ?
Moderators: Developers, Moderators
[SOLVED] Plugin Architecture v2.0 bug ?
I upgraded to cacti 0.8.7b and plugin architecture 2.0 and my plugins (thold, weathermap) had url broken for console, graphs, ...
I have $config['url_path']="/"; setup in config.php but i had to modify include/plugins.php to get it working with the correct url.
at line 35 there's a "if" which is setting the value for $config['url_path'] in database. The issue for me, it's set as empty and it should be set as "/".
I don't investigate more and ugly patched the code inserting the value "/" in database in settings.url_path and i modified the code to do in the "if" part the same than in the "else" (SELECT ...).
That's a temp workaround, for people that have the same issue.
If jimmy can tell us if it's a real bug and patch it or if it's a setup issue on my side.
I have $config['url_path']="/"; setup in config.php but i had to modify include/plugins.php to get it working with the correct url.
at line 35 there's a "if" which is setting the value for $config['url_path'] in database. The issue for me, it's set as empty and it should be set as "/".
I don't investigate more and ugly patched the code inserting the value "/" in database in settings.url_path and i modified the code to do in the "if" part the same than in the "else" (SELECT ...).
That's a temp workaround, for people that have the same issue.
If jimmy can tell us if it's a real bug and patch it or if it's a setup issue on my side.
I fixed it on my Redhat server by squashing the fancy code in plugins.php. Here is exactly what I did:
Edit include/plugins.php
Add a static definition above the last 'define' line, such as:
if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['REMOTE_ADDR'])) {
$config['url_path'] = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']), strlen(__FILE__) - strlen($_SERVER['DOCUMENT_ROOT']) - strlen('include/plugins.php'));
db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . $config['url_path'] . "')");
} else {
$config['url_path'] = db_fetch_cell("SELECT value FROM settings WHERE name = 'url_path'");
}
$config['url_path'] = '/cacti/';
define('URL_PATH', $config['url_path']);
So nearly the same answer....kinda annoying
Edit include/plugins.php
Add a static definition above the last 'define' line, such as:
if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['REMOTE_ADDR'])) {
$config['url_path'] = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']), strlen(__FILE__) - strlen($_SERVER['DOCUMENT_ROOT']) - strlen('include/plugins.php'));
db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . $config['url_path'] . "')");
} else {
$config['url_path'] = db_fetch_cell("SELECT value FROM settings WHERE name = 'url_path'");
}
$config['url_path'] = '/cacti/';
define('URL_PATH', $config['url_path']);
So nearly the same answer....kinda annoying
- TheWitness
- Developer
- Posts: 17047
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Jimmy admited that he should not have attempted to "rediscover" that which should be specified by the administrator.
TheWitness
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?
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?
Phew! Thank God for that!!! I (foolishly) slapped plugin 2.0 over a new cacti install this morning that I want to use in a couple of hours! Thanks to those that posted here.
Spent most of the morning trying to figure why it decided to append a "/i" after my defined url_path in config.php - for some reason plugins.php is not one of the places I looked (fairly green with cacti, more green with plugins and VERY green with PHP)
Turns out it does not append, seemingly the "fancy schmancy stuff" (heheh) just blats right over my configured value - It does almost get it right too, at least in my install. It always comes up with /cacti/i/ no matter if I define url_path in config.php or not (or indeed as I did at one point, define it as "/argh-its/broke/").
Spent most of the morning trying to figure why it decided to append a "/i" after my defined url_path in config.php - for some reason plugins.php is not one of the places I looked (fairly green with cacti, more green with plugins and VERY green with PHP)
Turns out it does not append, seemingly the "fancy schmancy stuff" (heheh) just blats right over my configured value - It does almost get it right too, at least in my install. It always comes up with /cacti/i/ no matter if I define url_path in config.php or not (or indeed as I did at one point, define it as "/argh-its/broke/").
Wow - holy cr....
Man this was a nasty suprise!
It seems new version of cacti was broken and had to jippo it, and after i managed to get that going i tried the plug-in infrastructure.
My entire installation went down the drain.
Seems now the url path had a "de" added between, tried setting my path with the old
(ie what used to be "http://www.thavinci.za.net/monitor/
now was http://www.thavinci.za.net/monitor/de)
$config['url_path'] = '/monitor/';
story but didn't work eventually just restored what i had!
This was a BAD upgrade attempt, every package seems to need a hack to work.....
It seems new version of cacti was broken and had to jippo it, and after i managed to get that going i tried the plug-in infrastructure.
My entire installation went down the drain.
Seems now the url path had a "de" added between, tried setting my path with the old
(ie what used to be "http://www.thavinci.za.net/monitor/
now was http://www.thavinci.za.net/monitor/de)
$config['url_path'] = '/monitor/';
story but didn't work eventually just restored what i had!
This was a BAD upgrade attempt, every package seems to need a hack to work.....
More ppl with same issue
http://cactiusers.org/forums/viewtopic. ... poller+ran
Great software, can't wait for next stable release.
Great software, can't wait for next stable release.
I had a similar problem with some plugins and PA2.0 and windows.
My problem was that in windows the / is converted automaticâlly by plugins.php to \ .
1/ But This is wrong for SQL request --> CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')
2/ some plugins had problem with this and have seen the wrong url.
Because I have windows I had to do in plugins.php this:
My problem was that in windows the / is converted automaticâlly by plugins.php to \ .
1/ But This is wrong for SQL request --> CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')
2/ some plugins had problem with this and have seen the wrong url.
Because I have windows I had to do in plugins.php this:
Code: Select all
$search= array('\\');
$replace='/';
$config['url_path']= str_replace($search,$replace,$config['url_path']);
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
Thanks Pepj, I was getting the same error in my logs:
CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')
I'm on windows too.
I added your hack in plugins.php:
right before this line:
That works for me!
Thanks again,
Bob
CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')
I'm on windows too.
I added your hack in plugins.php:
Code: Select all
$search= array('\\');
$replace='/';
$config['url_path']= str_replace($search,$replace,$config['url_path']);
Code: Select all
define('URL_PATH', $config['url_path']);
Thanks again,
Bob
I propose use
Code: Select all
addslashes
(PHP 3, PHP 4, PHP 5)
addslashes -- Quote string with slashes
Description
string addslashes ( string str )
Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
Code: Select all
db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . addslashes($config['url_path']) . "')");
Who is online
Users browsing this forum: No registered users and 0 guests