[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

Magistrator

Post by Magistrator »

I wonder if it isn’t more practical to create new RRDs based
on the result of arithmetic operations over other existing RRDs.
This approach would simplify the graphic making process a lot. And
would relocate each processes, of “graphic making” and
“data treatment”, to different areas.

I work my ass out to create nice data summations of interfaces
and network traffic. With the above approach it would be much easier.

Cacti Rules!
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Hey Judgeman,

Please submit a feature request in Mantis so that we can track this. No promises.

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

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
TimmiT.nl

Post by TimmiT.nl »

Is it possible to sum the inbound and outbound traffic on one graph?

That is the online feature I would really like!
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

There is a CDEF for "Total of All Data Sources". You should consider this one.

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

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mafiaid
Posts: 1
Joined: Thu Jun 09, 2005 6:40 am

Post by mafiaid »

mike_tcis wrote:
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
sini
Cacti User
Posts: 91
Joined: Mon Nov 24, 2003 10:22 am
Location: Hungary

Take a look at this

Post by sini »

Finally I made what I (and all of this topic readers) was looking for.
First I `d like to say thank for Chad who send me great instructions on cacti list.
What I want is to graph two agregated interface in one graph.
Create new RRDs based aggregted graph on the result of arithmetic operations over other existing RRDs.
with the rrdtool command its looks like this.

rrdtool graph summ.png --title="Summ.png" \
DEF:in1="traffic_in_1.rrd":traffic_in:AVERAGE \
DEF:out1="traffic_in_1.rrd":traffic_out:AVERAGE \
DEF:in2="traffic_in_2.rrd":traffic_in:AVERAGE \
DEF:out2="traffic_in_2.rrd":traffic_out:AVERAGE \
CDEF:agginput=in1,in2,+,8,* \
CDEF:aggoutput=out1,out2,+,8,* \
AREA:agginput#00cc00:"Input Aggregate" \
GPRINT:agginput:LAST:" Current\:%8.2lf %s" \
GPRINT:agginput:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:agginput:MAX:"Maximum\:%8.2lf %s\n" \
LINE1:aggoutput#0000FF:"Output Aggregate" \
GPRINT:aggoutput:LAST:" Current\:%8.2lf %s" \
GPRINT:aggoutput:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:aggoutput:MAX:"Maximum\:%8.2lf %s\n" \

In this example the image shows the correct aggregated in/out traffic and also the agregated legend values.
In cacti it was a bit difficult to create a graph like that (to me). As I read over the forum everybody was operating with te stack graph item type. Including me. But with this I had some problem. No correct aggregated valus and, after zoom no graph generation. All of this works with this new method.
I attached a template for the new approach of this problem. And also a screenshot.
After import you have 2 custom CDEF ("combine 2 in" and "combine 2 out") and a new graph template "Aggregate 2 graph"
Take a look at it, try it out and write down your feelings.
Attachments
aggregate.png
aggregate.png (79.1 KiB) Viewed 40054 times
cacti_graph_template_aggregate_2_graph.xml
Exported from Cacti 0.8.6g
(17.07 KiB) Downloaded 5964 times
Sini
eberkut
Posts: 19
Joined: Wed Jul 19, 2006 4:15 am

Post by eberkut »

Has anybody got this template working ?

Would it be possible to get a screenshot of the Graph Template for those of us desesperate users stuck with an old non-upgradable Cacti version and with limited access to any CLI ?

Thanks.
firestarter
Posts: 1
Joined: Mon Aug 07, 2006 2:09 am
Contact:

summation help please

Post by firestarter »

I am a new cacti user and is really impressed about it. I want to configure it such a way that I can get the total bandwidth used embedded in the graphs.

I read all of the above posts, but could not create a template that will show something like the following. I need to show the total bandwidth used in mbits and sum of in+out or even in GB.

These will be SNMP enabled hosts not the router/switch interfaces.

Please advise me in details as I am a newbie here :cry:
Attachments
This is what I need to show
This is what I need to show
show_graph.png (22.28 KiB) Viewed 38826 times
superonline
Posts: 1
Joined: Thu Aug 10, 2006 2:25 am
Location: Turkey, Istanbul

Post by superonline »

Hi there,

I loved cacti first of all; but I couldnt find a easy way to do :

Directory[ttnet-total]: ttnet-total
Target[ttnet-total]: /195.xxx.51.206:xxx@212.xxx.5.180:::::2 + /212.xxx.230.198:xxx@212.xxx.5.122:::::2

in cacti.

All I saw is to do some workarounds in order to be able to do such graphs. But imagine ( which is the fact i have ) that you have thousands of such graphs, there should be a rational way to do such sum-up graphs in cacti, otherwise it will be very hard to use cacti for sysadms in big ISPs such as me :(

Levent Kurt
Superonline
SysAdm
sini
Cacti User
Posts: 91
Joined: Mon Nov 24, 2003 10:22 am
Location: Hungary

Post by sini »

eberkut wrote:Has anybody got this template working ?

Would it be possible to get a screenshot of the Graph Template for those of us desesperate users stuck with an old non-upgradable Cacti version and with limited access to any CLI ?

Thanks.
Yes, see attached file!
Attachments
aggregated.png
aggregated.png (95.57 KiB) Viewed 38306 times
Sini
kubilay
Posts: 2
Joined: Wed May 30, 2007 3:29 am
Location: Istanbul - Turkiye
Contact:

Post by kubilay »

Hi All,

I import the template run it succesfully.

What should I have to do to sum 3+ graphs.

I look at cdef Combine 2 IN and its value is a,b,+,8,*
What should I write for 3 graphs? a,b,c??

Thanks

Zeki Kubilay Akyol
kubilay
Posts: 2
Joined: Wed May 30, 2007 3:29 am
Location: Istanbul - Turkiye
Contact:

Post by kubilay »

I found it thanks anyway.

For 3 items; a,b,c,+,+,8,* in and d,e,f,+,+,8,*
For 4 items; a,b,c,d,+,+,+,8,* in and e,f,g,h,+,+,+,8,*
peppermint
Cacti User
Posts: 58
Joined: Fri May 11, 2007 1:11 pm
Location: NY

The sum for items more than 2+

Post by peppermint »

Hi,

I imported the templete from Sini, it worked great, thanks.

However, I then tried to get the sum out of 3 and 4 items by setting up CDEF as mentioned in kubilay's post,

-----
For 3 items; a,b,c,+,+,8,* in and d,e,f,+,+,8,*
For 4 items; a,b,c,d,+,+,+,8,* in and e,f,g,h,+,+,+,8,*
-----

then Outbound sum did not come out correctly, for example, the Avarage shoud be around 30M, but the Sum data became 270MB.

My questions is was the CDEF set up alright? Shall I change to the different forms?

Here are what Graph debug says:
----
RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-60 \
--title="Aggregated_SUM_3" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="bits per second" \
--slope-mode \
DEF:a="/var/www/html/cacti/rra/sw7_traffic_out_827.rrd":traffic_in:AVERAGE \
DEF:b="/var/www/html/cacti/rra/sw7_traffic_out_828.rrd":traffic_in:AVERAGE \
DEF:c="/var/www/html/cacti/rra/sw7_traffic_out_827.rrd":traffic_out:AVERAGE \
DEF:d="/var/www/html/cacti/rra/sw7_traffic_out_828.rrd":traffic_out:AVERAGE \
DEF:e="/var/www/html/cacti/rra/sw7_traffic_out_830.rrd":traffic_in:AVERAGE \
DEF:f="/var/www/html/cacti/rra/sw7_traffic_out_830.rrd":traffic_out:AVERAGE \
CDEF:cdefa=a,8,* \
CDEF:cdefb=b,8,* \
CDEF:cdefc=a,b,c,+,+,8,* \
CDEF:cdefg=c,8,* \
CDEF:cdefh=d,8,* \
CDEF:cdefi=d,e,f,+,+,8,* \
CDEF:cdefbc=e,8,* \
CDEF:cdefbd=f,8,* \
AREA:cdefa:"" \
AREA:cdefb:"" \
AREA:cdefc#6EA100:"Inbound" \
GPRINT:cdefc:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefc:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefc:MAX:"Maximum\:%8.2lf %s\n" \
LINE1:cdefg:"" \
LINE1:cdefh:"" \
LINE1:cdefi#4444FF:"Outbound" \
GPRINT:cdefi:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefi:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefi:MAX:"Maximum\:%8.2lf %s\n" \
AREA:cdefbc:"" \
LINE1:cdefbd:""

RRDTool Says:

OK
----------------

The 2nd thing I observed is I then set up the templetes for the sum out of 5+, 6+..items (because I eventually need sum out of 13 interfaces), what happens is after 7 items, the chart no longer shows Outbound info at the bottom of the graph, it only shows Inbound, does anyone ever set up sum for itemos more than 7?

Thanks!

Peppermint
peppermint
Cacti User
Posts: 58
Joined: Fri May 11, 2007 1:11 pm
Location: NY

The aggregation

Post by peppermint »

Actually there is a plugin called 'aggreation' available at:
http://forums.cacti.net/viewtopic.php?p=96774#96774

It'll require Plugin Architecture to be implemented though, I tested that out, everything worked pefect..

Peppermint
asdfg
Posts: 7
Joined: Sun Apr 11, 2010 5:10 am

Re: Take a look at this

Post by asdfg »

sini wrote:Finally I made what I (and all of this topic readers) was looking for.
First I `d like to say thank for Chad who send me great instructions on cacti list.
What I want is to graph two agregated interface in one graph.
Create new RRDs based aggregted graph on the result of arithmetic operations over other existing RRDs.
with the rrdtool command its looks like this.

rrdtool graph summ.png --title="Summ.png" \
DEF:in1="traffic_in_1.rrd":traffic_in:AVERAGE \
DEF:out1="traffic_in_1.rrd":traffic_out:AVERAGE \
DEF:in2="traffic_in_2.rrd":traffic_in:AVERAGE \
DEF:out2="traffic_in_2.rrd":traffic_out:AVERAGE \
CDEF:agginput=in1,in2,+,8,* \
CDEF:aggoutput=out1,out2,+,8,* \
AREA:agginput#00cc00:"Input Aggregate" \
GPRINT:agginput:LAST:" Current\:%8.2lf %s" \
GPRINT:agginput:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:agginput:MAX:"Maximum\:%8.2lf %s\n" \
LINE1:aggoutput#0000FF:"Output Aggregate" \
GPRINT:aggoutput:LAST:" Current\:%8.2lf %s" \
GPRINT:aggoutput:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:aggoutput:MAX:"Maximum\:%8.2lf %s\n" \

In this example the image shows the correct aggregated in/out traffic and also the agregated legend values.
In cacti it was a bit difficult to create a graph like that (to me). As I read over the forum everybody was operating with te stack graph item type. Including me. But with this I had some problem. No correct aggregated valus and, after zoom no graph generation. All of this works with this new method.
I attached a template for the new approach of this problem. And also a screenshot.
After import you have 2 custom CDEF ("combine 2 in" and "combine 2 out") and a new graph template "Aggregate 2 graph"
Take a look at it, try it out and write down your feelings.
Is possible sum for more interface?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests