[HOWTO] How can I make SUM of graphs

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

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

Post by raX »

atrocity wrote:ehm, excuse my stupid question, but this summation, is it IN the graphs ?
If yes, then it's ok ... it's working.
But what i really want, is the possibility to put tables, with the summary of the trafic in numbers...
I have a nice PHP script, that can summarize the trafic. You can choose to see the results for a period of days, or for a whole mounth, also a year if you collected the data... Really, i will appreciate if something like that can be done in Cacti, because actually i continue to use MRTG, only for that feature ....
I will be more then happy to share this script, if someone think that it can be used / converted to and for Cacti ;)
Jean
I actually wrote a very similar feature for an ISP/colo that I was doing some work for. It is a pretty cool idea; my biggest concern is where to put it in the UI ;-) I could write an option whether to turn it on or off depending on how many users would benefit from such a feature. Thoughts?

-Ian
atrocity
Posts: 18
Joined: Tue Aug 26, 2003 10:04 am

Post by atrocity »

It can be simply under the detailed graph pages, no ?
Or, if it's possible, create a brand new feature in cacti....
Can you send me that script, to compare it with my one ?
Thanks
Jean
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

Yeah, that's definitely one place it could go. I would send you the work I did previously, but it is not an isolated script and fairly tied into Cacti itself. What I did for them was basically create a table that gave GB transfered for each month for each user that logged in.

-Ian
atrocity
Posts: 18
Joined: Tue Aug 26, 2003 10:04 am

Post by atrocity »

I think that if there are 2 tables, under the detailed graphs pages, it can be enough.... Something like :

Current mounth traffic : xyz Gb total
(then the last mounths like)
08 : xyz Gb total
07 : xyz Gb total
06 : xyz Gb total
05 : xyz Gb total
04 : xyz Gb total
03 : xyz Gb total
02 : xyz Gb total
01 : xyz Gb total

But, like that, it's not really easy to manage...
Will it not be a better idea, to make a new link appear in the detailed graphs, going to a page with a form, and the user can chose what he want to see ?
Like that, you can put the 'Current mounth traffic' ;)
Jean
atrocity
Posts: 18
Joined: Tue Aug 26, 2003 10:04 am

Post by atrocity »

Currently, i'm only interested to see this stats for each of the switch ports that i monitor... But feel free to extend it ;)
Jean
mike_tcis
Posts: 12
Joined: Wed Jul 17, 2002 8:46 am
Location: Tulsa, OK
Contact:

Post by mike_tcis »

raX wrote:Yeah, that's definitely one place it could go. I would send you the work I did previously, but it is not an isolated script and fairly tied into Cacti itself. What I did for them was basically create a table that gave GB transfered for each month for each user that logged in.

-Ian
Yea, something like that would be very useful. Right now, the summation feature works fine on the graphs themselves, but I'm still forced to use MRTS to get traffic sum data for specific time periods, e.g. per day, week, month, with the ability to go back several months.

--Mike
skt
Posts: 14
Joined: Thu Nov 06, 2003 10:23 am

XLM File

Post by skt »

Anyone have an XML file for doing the graph sums. Just upgraded to 0.8.4 and would like to inport this feature.

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

Post by raX »

I attached the total bandwidth in bits and bytes that comes with new versions of Cacti.

-Ian
Attachments
cacti_graph_template_interface_traffic_bitssec_total_bandwidth.xml
Interface - Traffic (bits/sec, Total Bandwidth)
(14.77 KiB) Downloaded 1115 times
cacti_graph_template_interface_traffic_bytessec_total_bandwidth.xml
Interface - Traffic (bytes/sec, Total Bandwidth)
(13.79 KiB) Downloaded 1227 times
User avatar
egarnel
Cacti Pro User
Posts: 708
Joined: Thu Nov 21, 2002 8:55 am
Location: Austin, TX

trying out the new templates

Post by egarnel »

I imported the new templates into Cacti (.084 from upgrade) and selected 1 interface from a polling host as a test using the bits_sec_total template.

I can see the top level graph fine. It appears to be working correctly. I do not get graphs when I drill down on the graph in question.
Given the fact that the top level graph works, am I just being impatient and the other graphs will show up in a while?

Here is the source:
ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source
ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source

/usr/local/rrdtool/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--title="Monitor2 BigBrother/Nedi Server - Traffic - 172.20.1.204 (eth1)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bits per second" \
DEF:a="/usr/local/cacti/rra/monitor2_bigbrothernmis_server_traffic_in_952.rrd":traffic_in:AVERAGE \
DEF:b="/usr/local/cacti/rra/monitor2_bigbrothernmis_server_traffic_in_952.rrd":traffic_out:AVERAGE \
CDEF:cdefa=a,8,* \
CDEF:cdeff=b,8,* \
CDEF:cdefi=a,8,* \
AREA:cdefa#00CF00:"Inbound" \
GPRINT:cdefa:LAST:" Current\:%8.2lf %s" \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s" \
COMMENT:"Total In: 0 bytes\n" \
LINE1:cdeff#002A97:"Outbound" \
GPRINT:cdeff:LAST:"Current\:%8.2lf %s" \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefi:MAX:"Maximum\:%8.2lf %s" \
COMMENT:"Total Out: 0 bytes"
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Re: trying out the new templates

Post by raX »

egarnel wrote:Here is the source:
ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source
ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source
If you see this error, it probably means that your RRD file does not exist. Double check to make sure you have a file at /usr/local/cacti/rra/monitor2_bigbrothernmis_server_traffic_in_952.rrd.

-Ian
User avatar
egarnel
Cacti Pro User
Posts: 708
Joined: Thu Nov 21, 2002 8:55 am
Location: Austin, TX

Files present

Post by egarnel »

The file does indeed exist. The weird thing is that the top level graph shows up and seems to be accurate. This is on a box that has been upgraded to 0.8.4 and has had the modification previously mentioned in this thread.
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

Typically when the graph looks fine at the top level, but not in detail, it indicates a problem with the graph legend. When a graph is drawn as a top level graph, Cacti doesn't even bother with the graph legend code. Since your bandwidth summation items are both COMMENT types, they both reside on the legend.

In the spirit of debugging, try replacing your 'lib/rrd.php' file with the following:

http://www.raxnet.net/downloads/patches ... rd.php.txt

Then show me what you get after clicking "view source" for the broken summation graph.

-Ian
User avatar
egarnel
Cacti Pro User
Posts: 708
Joined: Thu Nov 21, 2002 8:55 am
Location: Austin, TX

results of debug

Post by egarnel »

FETCH ARRAY:

ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source
FETCH ARRAY:

ERROR: no rrdtool fetch output, you probably forgot to pass a valid data source

/usr/local/rrdtool/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--title="Monitor2 BigBrother/Nedi Server - Traffic - 172.20.1.204 (eth1)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bits per second" \
DEF:a="/usr/local/cacti/rra/monitor2_bigbrothernmis_server_traffic_in_952.rrd":traffic_in:AVERAGE \
DEF:b="/usr/local/cacti/rra/monitor2_bigbrothernmis_server_traffic_in_952.rrd":traffic_out:AVERAGE \
CDEF:cdefa=a,8,* \
CDEF:cdeff=b,8,* \
CDEF:cdefi=a,8,* \
AREA:cdefa#00CF00:"Inbound" \
GPRINT:cdefa:LAST:" Current\:%8.2lf %s" \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s" \
COMMENT:"Total In: 0 bytes\n" \
LINE1:cdeff#002A97:"Outbound" \
GPRINT:cdeff:LAST:"Current\:%8.2lf %s" \
GPRINT:cdeff:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefi:MAX:"Maximum\:%8.2lf %s" \
COMMENT:"Total Out: 0 bytes"
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

I have a feeling that your problem is a result of not having a data source selected for the two COMMENT graph items.

Go to "Graph Templates" and select "Interface - Traffic (bits/sec, Total Bandwidth)". Click "Inbound Data Source", make sure that item #5 is selected, and click "Save". Now click "Outbound Data Source", make sure that item #10 is selected, and click "Save".

Let me know if this helps.

-Ian
sini
Cacti User
Posts: 91
Joined: Mon Nov 24, 2003 10:22 am
Location: Hungary

graph summ

Post by sini »

Hi,

On graph summation I mean the throughput summation.
Imagine that you buy internet from two different ISP and want to monitor the
sum of its in/out traffic to see what the max peak of it.

A tried to operate with CDEF creating a CDEF grap1+grap2-in/out:(cdef=current_data_source,current_data_source,+) but not worked...:evil:
Finally I done manually but I can't print out the summ of current/aver/max
values with gprint although the graph lines are in correct places showing the
sum of values.
I attached a graph to see the result.

Q:Is there a template for it?
Attachments
graph_sum.png
graph_sum.png (9.89 KiB) Viewed 21376 times
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests