How to patch a plugin ?

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

French_Poul
Cacti User
Posts: 105
Joined: Thu Apr 08, 2010 4:17 am
Location: France

How to patch a plugin ?

Post by French_Poul »

Hello,

I would like to know how to patch a plugin ? Where I must be (in what directory) ?

Because, I install the plugin nectar, and I must patch the plugin settings. I have do a thing, but it asks for the file to patch...

Code: Select all

server:/usr/share/cacti/site/plugins/settings# patch -p1 -N < settings_include_functions.php.patch
(Stripping trailing CRs from patch.)
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- cacti_plugins/settings/trunk/include/functions.php 2009-10-29 23:46:43.000000000 +0100
|+++ plugin087d/plugins/settings/include/functions.php  2009-12-05 22:23:07.000000000 +0100
--------------------------
File to patch:
Skip this patch? [y] y
Skipping patch.
2 out of 2 hunks ignored
I use cacti version 0.8.7b, the plugin architecture 2.1, and the plugin is already installed.

Thanks a lot early for your responses!!

-- Sorry for my english!! --
French_Poul
Cacti User
Posts: 105
Joined: Thu Apr 08, 2010 4:17 am
Location: France

Post by French_Poul »

It seems that a patch, for all plugins, must be done in the directory where cacti is installed, with :

Code: Select all

server:/usr/share/cacti/site# patch -p1 -N < settings_include_functions.php.patch
(Stripping trailing CRs from patch.)
patching file plugins/settings/include/functions.php
I have done this, and it seems it's correct... :roll:
"Sorry for my english... I'm french!"
Cacti version : 0.8.7e
Plugin Architecture : 2.6
Plugins : Settings 0.5, Monitor 0.8.2, Thresholds 0.4.1, Nectar 0.26, Discovery 0.9, Realtime 0.32, Update 0.4, Weathermap 0.97a, Hostinfo 0.2
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

That's indeed correct
R.
jrwagz
Posts: 12
Joined: Tue Sep 01, 2009 7:10 pm

Post by jrwagz »

I am having a very similar issue when I try to install the patch for Nectar. I am running Cacti 0.8.7f with PA 2.7 I am trying to install Nectar v0.26.

Code: Select all

[root@routerback cacti]# pwd
/var/www/cacti
[root@routerback cacti]# patch -p1 -N < plugins/nectar/settings_include_functions.php.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- cacti_plugins/settings/trunk/include/functions.php 2009-10-29 23:46:43.000000000 +0100
|+++ plugin087d/plugins/settings/include/functions.php  2009-12-05 22:23:07.000000000 +0100
--------------------------
File to patch:
Skip this patch? [y] y
Skipping patch.
2 out of 2 hunks ignored
My guess is that the patch is trying to locate a file named functions.php that should be in the cacti/plugins/settings/include folder, but that path doesn't not exist in my installation and I cannot find that functions.php file anywhere else for the life of me.

The plugin is recognized in the Plugin Managment window, and I gave myself permissions, but I don't see the Nectar link under the utilities in the console.

I have also updated the html_utility.php file located at cacti/lib directory. As was mentioned in the README file.

Any help?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I recently committed a new patch to SVN that covers 087g. 087f should not be used.
R.
jrwagz
Posts: 12
Joined: Tue Sep 01, 2009 7:10 pm

Post by jrwagz »

So I should downgrade to 0.8.7e and nectar will work fine?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

gandalf wrote:I recently committed a new patch to SVN that covers 087g. 087f should not be used.
R.
Oops, sorry. That was the wrong plugin. Working too much these days. The new patch for the settings plugin is attached
R
Attachments
settings_include_functions.php.patch
(2.01 KiB) Downloaded 562 times
jrwagz
Posts: 12
Joined: Tue Sep 01, 2009 7:10 pm

Post by jrwagz »

So I replaced the patch I had with the patch you posted and I got the same error:

Code: Select all

[root@routerback cacti]# patch -p1 -N < plugins/nectar/settings_include_functions.php.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- plugins/settings/include/functions.php     2009-10-29 23:46:43.000000000 +0100
|+++ plugins/settings/include/functions.php     2009-12-05 22:23:07.000000000 +0100
--------------------------
File to patch:
Skip this patch? [y] y
Skipping patch.
2 out of 2 hunks ignored
I found a functions.php under lib and tried telling it to patch it. I got the following:

Code: Select all

[root@routerback cacti]# patch -p1 -N < plugins/nectar/settings_include_functions.php.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- plugins/settings/include/functions.php     2009-10-29 23:46:43.000000000 +0100
|+++ plugins/settings/include/functions.php     2009-12-05 22:23:07.000000000 +0100
--------------------------
File to patch: lib/functions.php
patching file lib/functions.php
Hunk #1 FAILED at 22.
Hunk #2 FAILED at 107.
2 out of 2 hunks FAILED -- saving rejects to file lib/functions.php.rej
Any ideas?
dbau
Posts: 1
Joined: Mon Jun 21, 2010 6:26 pm

Post by dbau »

FWIW I got a similar error:

Code: Select all

administrator@cacti:/usr/share/cacti/site$ sudo patch -p1 -N < /usr/share/cacti/site/plugins/nectar/settings_include_functions.php.patch
patching file plugins/settings/include/functions.php
Hunk #1 FAILED at 22.
Hunk #2 FAILED at 107.
2 out of 2 hunks FAILED -- saving rejects to file plugins/settings/include/functions.php.rej
I'm using Cacti 0.8.7e & Nectar 0.26.
jrwagz
Posts: 12
Joined: Tue Sep 01, 2009 7:10 pm

Post by jrwagz »

You need to run that patch command from the cacti directory, not from the root directory.

I figured out the problem I was having earlier...I needed to have the settings plugin installed, I guess it is a pre-requisite for Nectar, even though none of the documentation says so!
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

jrwagz wrote:I needed to have the settings plugin installed, I guess it is a pre-requisite for Nectar
Yes
, even though none of the documentation says so!
oops
R.
darkpixel
Posts: 2
Joined: Sat Feb 19, 2011 2:40 pm

Re: How to patch a plugin ?

Post by darkpixel »

I there, im new to cacti and im also having problems with the same pacth file. Sorry for my inglish.

Here are some information about my installation:

Cacti Version 0.8.7e
Cacti OS unix (Ubuntu 10.04.1 LTS Server x86_64)
SNMP Version NET-SNMP version: 5.4.2.1
RRDTool Version RRDTool 1.3.x

Nectar plugin version: v0.30
Settings plugin version: v0.7-1

My problem is that i can´t patch the functions.php file properlly, i get this:

Code: Select all

root@server:/usr/share/cacti/site# patch -p1 -N < /usr/share/cacti/site/plugins/nectar/0.8.7e/settings_include_functions.php.patch
patching file plugins/settings/include/functions.php
Hunk #2 FAILED at 107.
1 out of 2 hunks FAILED -- saving rejects to file plugins/settings/include/functions.php.rej
The file functions.php.rej contains the following:

--- settings/trunk/include/functions.php 2009-10-29 23:46:43.000000000 +0100
+++ plugins/settings/include/functions.php 2009-12-05 22:23:07.000000000 +0100

@@ -107,24 +107,22 @@
return $Mailer->error();
}

- if (is_array($filename) && !empty($filename) && strstr($message, '<GRAPH>') !==0) {
- foreach($filename as $val) {
- $graph_data_array = array("output_flag"=> RRDTOOL_OUTPUT_STDOUT);
- $data = rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
- if ($data != "") {

+ if (is_array($data_array) && !empty($data_array) && strstr($message, '<GRAPH>') !==0) {
+ foreach($data_array as $data_item) {
+ if ($data_item["attachment"] != "") {

$cid = $Mailer->content_id();
- if ($Mailer->attach($data, $val['filename'].'.png', "image/png", "inline", $cid) == false) {
+ if ($Mailer->attach($data_item["attachment"], $data_item['filename'], $data_item["mime_type"], $data_item["inline"], $cid) == false) {
print "ERROR: " . $Mailer->error() . "\n";
return $Mailer->error();
}
$message = str_replace('<GRAPH>', "<br><br><img src='cid:$cid'>", $message);
} else {
- $message = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $message);
+ $message = str_replace('<GRAPH>', "<br><img src='" . $data_item['file'] . "'><br>Could not open!<br>" . $data_item['file'], $message);
}
}
}
$text = array('text' => '', 'html' => '');
- if ($filename == '') {
+ if ($data_array == '') {
$message = str_replace('<br>', "\n", $message);
$message = str_replace('<BR>', "\n", $message);
$message = str_replace('</BR>', "\n", $message);


END

I still havent updated the html_utility.php file because of theese problem.

What can be the problem? I really need netcar to work!

Thank´s in advance! :)
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: How to patch a plugin ?

Post by gandalf »

Then please use PIA 2.9. It includes all required patches
R.
in2deep
Posts: 22
Joined: Thu Jan 13, 2011 9:39 pm

Re: How to patch a plugin ?

Post by in2deep »

Hi, I'm current running 8.7g with PIA 2.8. Can someone provide the instruction how to upgrade PIA to 2.9.

Reason i want to upgrade because after I upraded Thold-04.1 to Thold-0.4.4-1 the threshold email notification stops working. Hopping to upgrade PIA will solve this problem. Also, reason I want to upgrade Thold because version 0.4.1 doesn't allow me to select multiple data source (e.g cpu graph, it only allows me to select "user" ds and ignore the rest such as, idle, nice, etc...). thanks for your help inadvance.

tho
Operating System:Linux version 2.6.18-164.el5
Webserver: Apache/2.2.17
Cacti:8.7g
Spine:rpm 8.7g
MySQL:Server version: 5.5.8
PHP: 5.3.5
RRDTool (Cygwin or Win32 version): 1.4.4
Net-SNMP: 5.3
Plugin Architecture: 2.8
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: How to patch a plugin ?

Post by noname »

in2deep wrote:Hi, I'm current running 8.7g with PIA 2.8. Can someone provide the instruction how to upgrade PIA to 2.9.
(A) Newly install Cacti0.8.7g & PIA2.9

(B) Revert PIA2.8, then install PIA2.9

For (B), if you hadn't apply official Cacti patch yet, try as follows:
(not tested fully, not recommended for production environment)

1) Logout Cacti GUI and stop poller in crontab

2) Revert PIA2.8 patch
Check first:
% patch -p1 -N --reverse --dry-run < cacti-plugin-0.8.7g-PA-v2.8.diff

When warned like as,

Code: Select all

patching file include/config.php
Unreversed patch detected!  Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/config.php.rej
revert to default settings in 'include/config.php' such like:

Code: Select all

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

-and-

$url_path = "/";
If not warned, then revert actually.
% patch -p1 -N --reverse < cacti-plugin-0.8.7g-PA-v2.8.diff

3) Apply official patches
http://www.cacti.net/download_patches.php

4) Install PIA2.9
% patch -p1 -N < cacti-plugin-0.8.7g-PA-v2.9.diff
('pa.sql' is not changed, no need to re-import)

Then modify 'include/config.php' along with your environment.

5) Restart poller in crontab and login Cacti
And see 'Console -> Plugin Management'.

Good luck.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests