[SOLVED] Plugin Architecture v2.0 bug ?

Support for the Plugin Architecture

Moderators: Moderators, Developers

Post Reply
Posts: 4
Joined: Tue Sep 04, 2007 1:59 pm

[SOLVED] Plugin Architecture v2.0 bug ?

#1 Post by qantic » Wed Feb 13, 2008 3:36 pm

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.

Cacti User
Posts: 79
Joined: Thu Feb 16, 2006 8:14 am

#2 Post by Tybio » Wed Feb 13, 2008 5:28 pm

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 :)

User avatar
Posts: 14855
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA

#3 Post by TheWitness » Wed Feb 13, 2008 8:44 pm

Jimmy admited that he should not have attempted to "rediscover" that which should be specified by the administrator.

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

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository

I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

Cacti User
Posts: 91
Joined: Fri Feb 09, 2007 10:55 pm
Location: So. Cal

#4 Post by zeki » Tue Feb 19, 2008 6:48 pm

thanx tybio adding that line fixed mine :D

Posts: 2
Joined: Thu Feb 21, 2008 5:17 am

#6 Post by tin » Thu Feb 21, 2008 5:29 am

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! :oops: 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/").

Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB

Wow - holy cr....

#7 Post by thavinci » Sun Feb 24, 2008 6:16 pm

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.....

Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB

More ppl with same issue

#8 Post by thavinci » Sun Feb 24, 2008 6:33 pm

http://cactiusers.org/forums/viewtopic. ... poller+ran

Great software, can't wait for next stable release.

Posts: 15
Joined: Sun Aug 06, 2006 8:08 pm
Location: zhengzhou.china


#9 Post by nifi » Thu Feb 28, 2008 2:05 am

i have the same error,follow tybio's way,i solved it!

Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

#10 Post by pepj » Fri Feb 29, 2008 6:54 am

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:

Code: Select all

  $search= array('\\');
  $config['url_path']= str_replace($search,$replace,$config['url_path']);
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

Posts: 48
Joined: Fri Feb 17, 2006 10:31 am

#11 Post by laamidd » Wed Mar 05, 2008 11:27 am

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:

Code: Select all

$search= array('\\');
  $config['url_path']= str_replace($search,$replace,$config['url_path']); 
right before this line:

Code: Select all

define('URL_PATH', $config['url_path']);
That works for me!

Thanks again,

Posts: 3
Joined: Tue Mar 11, 2008 9:40 am

#12 Post by Ptica79 » Tue Mar 11, 2008 9:54 am

I propose use

Code: Select all

(PHP 3, PHP 4, PHP 5)

addslashes -- Quote string with slashes
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']) . "')");

Post Reply