Bonsai: An other cool zoom/history feature for Cacti

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Bisonlux
Cacti User
Posts: 79
Joined: Wed Jul 23, 2003 4:35 pm
Location: Luxembourg

Bonsai: An other cool zoom/history feature for Cacti

Post by Bisonlux »

Hi everybody,

I developed a similar Zoom/History function like the famous Cactistoric developed by Bruno Prigent (Bravo Bruno c’est du bon boulot!).
You can read the README file below and see a screenshot of the zoom function.
Two versions are available, the first for cacti-0.8.4 (bonsai-0.2-084.tar.gz) and the second for cacti-0.8.5 (bonsai-0.2-085.tar.gz).

Don’t hesitate to give me a feedback…

- Eric
Bonsai README File

ABOUT:

Bonsai is very similar to Cactistoric developed by Bruno Prigent, with a little bit more user friendly interface in mind (my opinion).

Select in the graph (with your mouse) an area you are interested in. It's magic... the selected time period is displayed in a new graph.

You can also add the displayed graph to your favorites in your browser.

REQUIREMENTS:

Unix-based operating system
Cacti-0.8.5

Bonsai has been successfully tested with the following components

Redhat: 9 (Linux 2.4.20-8)
Cacti: 0.8.5
rrdtool: 1.0.40, 1.0.46
apache: 2.0.45
php: 4.3.1
IE: 6.0

Please share the experience you make with other systems and components: eric.steffen@gmx.net


INSTALLATION:

tar -zxf bonsai-0.2-xxx.tar.gz -C <path to your cacti directory>
cd <path to your cacti directory>/bonsai-0.2-xxx
./install.sh

Done!

NOTE:

As Cactistoric don't forget do change the number of rows in your rra. (Recreate your rrd files or use the rrd tune command).
Attachments
bonsai-0.2-085.tar.gz
(6.6 KiB) Downloaded 1112 times
bonsai-0.2-084.tar.gz
(6.53 KiB) Downloaded 681 times
BonsaiSmall.PNG
BonsaiSmall.PNG (60.98 KiB) Viewed 19856 times
moonman
Cacti User
Posts: 101
Joined: Sat Sep 06, 2003 10:25 am

Great

Post by moonman »

its works
ifound two problems the first in line 62 of zoom.php you forgot "
$_GET[graph_end] should be $_GET["graph_end"]

and in line 64 There is Undefined variable: rra

Thanks
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Post by TFC »

H?,
I have cactistoric 0.8.5 and I try to install bonsai 8.5 But I gor these messages:

Code: Select all

[root@cacti_test bonsai-0.2-085]# ./install.sh
Installing Bonsai 0.2 for cacti-0.8.5 ...
patching file graph_image.php
Hunk #1 FAILED at 45.
1 out of 1 hunk FAILED -- saving rejects to file graph_image.php.rej
patching file graph.php
Hunk #1 succeeded at 67 (offset 18 lines).
Hunk #2 FAILED at 86.
1 out of 2 hunks FAILED -- saving rejects to file graph.php.rej
patching file zoom.php
patching file lib/functions.php
Hunk #1 FAILED at 868.
1 out of 1 hunk FAILED -- saving rejects to file lib/functions.php.rej
patching file lib/rrd.php
Hunk #1 succeeded at 563 with fuzz 2 (offset 31 lines).
Hunk #2 FAILED at 591.
Hunk #3 succeeded at 602 (offset 22 lines).
1 out of 3 hunks FAILED -- saving rejects to file lib/rrd.php.rej
patching file include/config_arrays.php
Hunk #1 succeeded at 259 (offset 21 lines).
patching file include/zoom.js
Done!
what is wrong?
P.S. All cacti dir ha nobody: nobody permission.
Apache 1.3.27
PHP 4.2.3
Guest

Post by Guest »

I suspect your problem is being caused by cactistoric. The patch files are expecting unmodified versions of the files they are for. You probably need to get back to clean version of cacti and re-apply the patches for bonsai.
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Post by TFC »

Anonymous wrote:I suspect your problem is being caused by cactistoric. The patch files are expecting unmodified versions of the files they are for. You probably need to get back to clean version of cacti and re-apply the patches for bonsai.
So, I must change my question at this time:
Can bonsai works with cactistoric?
Or
Can Bonsai show past data with 5 min. average? Like 2 months past?
Guest

Re: Great

Post by Guest »

moonman wrote:its works
ifound two problems the first in line 62 of zoom.php you forgot "
$_GET[graph_end] should be $_GET["graph_end"]

and in line 64 There is Undefined variable: rra

Thanks
Found another small problem with graph preview mode. graph_view.php needs to be modified to pass an end_time to graph.php.

Line 259 of graph_view.php
$now = time();
foreach ($graphs as $graph) {
print "<td align='center' width='" . (98 / read_graph_config_option("num_columns")) . "%'><a href='graph.php?rra_id=all&local_graph_id=" . $graph["local_graph_id"] . "'><img src='graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=" . (empty($set_rra_id) ? read_graph_config_option("default_rra_id") : $set_rra_id) . "&graph_start=-" . (empty($set_rra_id) ? read_graph_config_option("timespan") : "0") . "&graph_end=" . $now . "&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n";

Great job.
-Phil
moonman
Cacti User
Posts: 101
Joined: Sat Sep 06, 2003 10:25 am

Post by moonman »

TFC wrote:
Anonymous wrote:I suspect your problem is being caused by cactistoric. The patch files are expecting unmodified versions of the files they are for. You probably need to get back to clean version of cacti and re-apply the patches for bonsai.
So, I must change my question at this time:
Can bonsai works with cactistoric?
Or
Can Bonsai show past data with 5 min. average? Like 2 months past?
you can do..
just look at the patch file and apply the changes manually

its not simple but you can do it
Bisonlux
Cacti User
Posts: 79
Joined: Wed Jul 23, 2003 4:35 pm
Location: Luxembourg

Post by Bisonlux »

TFC wrote:
Anonymous wrote:I suspect your problem is being caused by cactistoric. The patch files are expecting unmodified versions of the files they are for. You probably need to get back to clean version of cacti and re-apply the patches for bonsai.
So, I must change my question at this time:
Can bonsai works with cactistoric?
Or
Can Bonsai show past data with 5 min. average? Like 2 months past?
Hello,

The mean reason I based the development on a fresh installed version of Cacti and not on Cactistoric is simple. Bonsai should be independent of other add-ons to be very easy to install.

Let’s take an example (in case of Bonsai is dependant of Cactistoric):
Someone wants to use the Bonsai’s zoom function. First of all he must install Cacti (ok normal), after that Cactistoric and at least Bonsai. So if something goes wrong it’s more difficult for him to find the problem. Imagine the complexity if you have a lot of add-ons …

So my question is (it’s for you PHP Expert), is it possible to have plug-ins (like Photoshop plug-ins) or something similar that allow you to install the feature you want. What are the best practices in developing PHP pages to simplify the integration of add-ons?

Here a link to understand the patch files (output of diff --context command)http://es-sun2.fernuni-hagen.de/cgi-bin ... %20Context for the people who have courage to modify it manually


Bonsai or Cactistoric give you the possibility to select and show graphs in the past, nothing else. If you want to display values with an average of 5 minutes and 2 month ago then the rrd file must contains these values (Rows). In your case, you have 1 sample in 5 minutes and you want an average of 5 minutes. So Step = 1. One day have 24*60=1440 minutes. So for 1 day you must store 1440/5=288 Steps and for 2 month 288*30*2=17280 Steps. So Rows = 17280.

An other example: You have an rrd files with 2 rra archives. The first represent 1 day with an average of 5 minutes (Step=1, Rows=288). The second represent 1 month with an average of 1 day (Step=288, Rows=30).

If you display a graph that shows the last 24 hours, it takes the first rra with 5 minutes average.

If you display a graph that shows 3 days ago, it takes the second rra (because the information are lost in the first rra) and take an average of 1 day.


Thank you to people who reports some bugs…

-Eric
vaidotas
Posts: 5
Joined: Thu Oct 16, 2003 11:05 am

Re: Great

Post by vaidotas »

moonman wrote:its works
ifound two problems the first in line 62 of zoom.php you forgot "
$_GET[graph_end] should be $_GET["graph_end"]

and in line 64 There is Undefined variable: rra

Thanks
Bug:
Warning: Undefined variable: rra in /cacti-0.8.5/zoom.php line 64
fixed by adding this code in file zoom.php before line 46

Code: Select all

$rras = get_associated_rras($_GET["local_graph_id"]);
foreach ( $rras as $q )
{
    if ( $q["id"] == $_GET["rra_id"] )
    {
        $rra = $q;
        break;
    }
}
I don't now is it right but for me it works :-)
Last edited by vaidotas on Tue Feb 17, 2004 12:40 pm, edited 1 time in total.
vaidotas
Posts: 5
Joined: Thu Oct 16, 2003 11:05 am

Re: Great

Post by vaidotas »

Problem with Graph tree view, Single Pane mode:

you need to change line 561 in file lib/tree_view.php

Code: Select all

$now = time();
print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img align='middle' alt='$graph_title'
src='graph_image.php?local_graph_id=$local_graph_id&rra_id=$rra_id&graph_start=" . -(db_fetch_cell("select timespan from rra where id=$rra_id")) . "&graph_end=" . $now . '&graph_height=' .
read_graph_config_option("default_height") . '&graph_width=' . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0'></a></td>\n";
Bisonlux
Cacti User
Posts: 79
Joined: Wed Jul 23, 2003 4:35 pm
Location: Luxembourg

Bonsai 0.3 is out !

Post by Bisonlux »

Bonsai 0.3 is out !

The new version corrects some bugs and is now Netscape/Mozilla compatible.

Here the full changelog file:
Changelog for Bonsai

------------------
[Feb 22st, 2004]

0.3-085
0.3-084
------------------

What's New:
- Now compatible with Netscape 7.1 (Win32)
- Now compatible with Mozilla 1.2.1 (Linux) and 1.6 (Win32)

Bugfixes:
- Broken graph in preview mode [Phil]
- Broken graph in tree mode [vaidotas]
- When zooming, the wrong RRDTool command is displayed (Source link)
- Missing graph title in the navigation text

Minor Changes:
- Elimination of syntax errors in zoom.php [moonman]
- Removed undefined rra variable in zoom.php [moonman, vaidotas]
- White gap suppressed at the end of the graph



------------------
[Feb 15st, 2004]

0.2-084
0.2-085
------------------

What's New:
- First release of Bonsai
Greetings from Luxembourg,

- Eric
Attachments
bonsai-0.3-085.tar.gz
(38.73 KiB) Downloaded 762 times
bonsai-0.3-084.tar.gz
(39.96 KiB) Downloaded 527 times
moonman
Cacti User
Posts: 101
Joined: Sat Sep 06, 2003 10:25 am

work

Post by moonman »

The new version work great for me without any problem in the install

btw
i want to know how increasing the size of rrd will influence on the preformence of the server when opening graph and when update rrd with cactid

Thanks
eljuanchete
Posts: 4
Joined: Mon Jan 12, 2004 5:50 am

Problem with Bonsai 0.3-0.8.5

Post by eljuanchete »

I just installed bonsai-0.3-085 (I have cacti 0.8.5) and when I click on zoom I can´t see the graph (neither can I select the zone in the previous graph) and get the error:
Notice: Undefined variable: local_graph_id in /var/www/html/cacti-0.8.5/zoom.php on line 90
Can you help me? Do you need any further information?
Bisonlux
Cacti User
Posts: 79
Joined: Wed Jul 23, 2003 4:35 pm
Location: Luxembourg

Post by Bisonlux »

Try this ...

In zoom.php file replace at line 90:

Code: Select all

where graph_templates_graph.local_graph_id=" . $local_graph_id);
with

Code: Select all

where graph_templates_graph.local_graph_id=" . $_GET["local_graph_id"]);
- Eric
Guest

undefined variable on line 90

Post by Guest »

I am having the same issue as above. New cacti 0.8.5 install, no other addtional scripts but bonsai. any ideas?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests