Patch: Graph Template Item Save Bug

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Patch: Graph Template Item Save Bug

Post by raX »

I ran into bug last night related to saving graph template items. Under certain conditions saving a graph template item could cause all attached graphs to swap data sources. If you don't play with graph templates, don't both with this patch, otherwise I recommend applying it.

To apply, download to your Cacti directory and apply like so:

Code: Select all

wget http://www.raxnet.net/downloads/cacti/patches/0.8.5/graph_item_inputs_save.patch
patch -p1 < graph_item_inputs_save.patch
Also from now on I am going to try and collect patches for each version of Cacti at the following URL:

http://www.raxnet.net/downloads/cacti/patches/

If the patch is important enough (like this one), I will post a note to the message board.

Edit: If you have already been bitten by this bug, simply go back into the graph template and re-save the affected graph items after aplying this patch.

-Ian
Last edited by raX on Sat Apr 03, 2004 4:53 pm, edited 1 time in total.
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

how do you apply the patch?

the command 'patch' is not known as an internal command (WIN32)
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

dieter wrote:how do you apply the patch?

the command 'patch' is not known as an internal command (WIN32)
If you don't have the 'patch' program, you can replace your 'lib/template.php' file with the following:

http://www.raxnet.net/downloads/cacti/p ... te.php.txt

PS: Does anyone know how to disable PHP parsing on a per-directory basis for Apache 2? I tried using 'php_admin_flag', 'RemoveHandler', and 'RemoveType' all to no avail.

-Ian
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

thank you raX!

:D
mondaka
Posts: 18
Joined: Wed Mar 03, 2004 7:47 pm

Re: Patch: Graph Template Item Save Bug

Post by mondaka »

raX wrote: To apply, download to your Cacti directory and apply like so:

Code: Select all

wget http://www.raxnet.net/downloads/cacti/patches/0.8.5/graph_item_inputs_save.patch
patch -p1 < graph_item_inputs_save.patch
-Ian
I couldnt patch my cacti0.85 because the system (linux) never return me the prompt, but i changed template.php with the new one patched. And with this way i got same results, the traffic_in not change when i try to modify it.
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Re: Patch: Graph Template Item Save Bug

Post by TFC »

raX wrote:I ran into bug last night related to saving graph template items. Under certain conditions saving a graph template item could cause all attached graphs to swap data sources. If you don't play with graph templates, don't both with this patch, otherwise I recommend applying it.

To apply, download to your Cacti directory and apply like so:

Code: Select all

wget http://www.raxnet.net/downloads/cacti/patches/0.8.5/graph_item_inputs_save.patch
patch -p1 < graph_item_inputs_save.patch
Also from now on I am going to try and collect patches for each version of Cacti at the following URL:

http://www.raxnet.net/downloads/cacti/patches/

If the patch is important enough (like this one), I will post a note to the message board.

Edit: If you have already been bitten by this bug, simply go back into the graph template and re-save the affected graph items after aplying this patch.

-Ian
Hi Ian,
I did this but my problem still exists in cacti-0.8.5
I still can't change max value of traffic_in...
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Re: Patch: Graph Template Item Save Bug

Post by raX »

TFC wrote:Hi Ian,
I did this but my problem still exists in cacti-0.8.5
I still can't change max value of traffic_in...
I think you're talking about a different bug. To fix this, simply replace your 'data_sources.php' file with the following:

http://www.raxnet.net/downloads/cacti/p ... es.php.txt

-Ian
s6a9d6u9s
Posts: 9
Joined: Sat Oct 18, 2003 5:51 pm

Post by s6a9d6u9s »

raX wrote:PS: Does anyone know how to disable PHP parsing on a per-directory basis for Apache 2? I tried using 'php_admin_flag', 'RemoveHandler', and 'RemoveType' all to no avail.-Ian
What option did you try using with php_admin_flag?

Just did a Google search for "disable php parsing per-directory basis"...

engine (boolean)
This directive is really only useful in the Apache module version of PHP. It is used by sites that would like to turn PHP parsing on and off on a per-directory or per-virtual server basis. By putting engine off in the appropriate places in the httpd.conf file, PHP can be enabled or disabled.

So I think it would be

php_flag engine off

or maybe

php_admin_flag engine off

Hopefully that will get you one step closer at least :-)
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

s6a9d6u9s wrote:php_admin_flag engine off
I tried doing this and it appeared to have no effect. Someone told me that this only works when your PHP is in CGI mode, which mine is definitely not. I haven't seen this confirmed on any websites though.

Thanks for your suggestions!

-Ian
s6a9d6u9s
Posts: 9
Joined: Sat Oct 18, 2003 5:51 pm

Post by s6a9d6u9s »

raX wrote:
s6a9d6u9s wrote:php_admin_flag engine off
I tried doing this and it appeared to have no effect. Someone told me that this only works when your PHP is in CGI mode, which mine is definitely not. I haven't seen this confirmed on any websites though.
I just checked my httpd.conf (Redhat9) and noticed I wasn't using any php_admin_flag's, just php_admin_value's..

e.g. php_admin_value session.use_trans_sid 0

Hours past my bed time again, I'll try ASAP to set engine_off on a subdirectory of a vhost, but you might try php_admin_value engine 0 in a <Directory...>? Not sure if you can nest directories inside of vhosts or if you can just use the full path outside of a vhost though, never tried yet..

Best wishes
Jeremy Martin
s6a9d6u9s
Posts: 9
Joined: Sat Oct 18, 2003 5:51 pm

Post by s6a9d6u9s »

raX wrote:
s6a9d6u9s wrote:php_admin_flag engine off
I tried doing this and it appeared to have no effect. Someone told me that this only works when your PHP is in CGI mode, which mine is definitely not. I haven't seen this confirmed on any websites though.
Thanks for your suggestions!
-Ian
Err, sleep can wait for the likes of you ;-))

I just tested on apache 2.0.48 / Redhat9 / PHP 4.3.4

A vhost is set up for /home/emagic/html.. Right below the <directory...> for it I have this:
<Directory "/home/emagic/html/test">
php_admin_value engine 0
</Directory>

and it served up a little test index.php as plain text as soon as I set that up.

Hope that helps,
Jeremy
s6a9d6u9s
Posts: 9
Joined: Sat Oct 18, 2003 5:51 pm

Post by s6a9d6u9s »

Hmm it was serving it up strangely, I could view source and see the code but it wasn't showing up as normal text in the browser...

Thought of something even cooler though..

<Directory "/home/emagic/html/test">
AddType application/x-httpd-php-source .php
</Directory>

cheers
Jeremy
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

I figured it out! There was another reason why my "AddType text/plain .php" was not working. Apparently Redhat doesn't use AddType to assign PHP to .php files, but SetOutputFilter. I just replaced this statement with "AddType application/x-httpd-php .php", and all is well.

Thanks!

-Ian
fletch
Cacti User
Posts: 132
Joined: Mon Oct 06, 2003 5:40 pm
Location: Stanford, CA

Error saving graph items

Post by fletch »

I was having graph template issues (items swapped, not appearing etc) - replaced my template.php and data_sources.php with the new ones and now I get this on save of any graph item:

Warning: Cannot modify header information - headers already sent by (output started at /export/web/crawlspace/htdocs/cacti-0.8.5/lib/template.php:1162) in /export/web/crawlspace/htdocs/cacti-0.8.5/graph_templates_items.php on line 192

Also noticed the graph template item has a
Data Source [Field Not Templated]
next to it

HELP!
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Re: Error saving graph items

Post by raX »

fletch wrote:I was having graph template issues (items swapped, not appearing etc) - replaced my template.php and data_sources.php with the new ones and now I get this on save of any graph item:

Warning: Cannot modify header information - headers already sent by (output started at /export/web/crawlspace/htdocs/cacti-0.8.5/lib/template.php:1162) in /export/web/crawlspace/htdocs/cacti-0.8.5/graph_templates_items.php on line 192
There are only 1159 lines in the 'lib/template.php' file, which makes me think you have extra whitespace at the bottom. Simply getting rid of this whitespace should eliminate your error.

-Ian
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests