[SOLVED] Ratio Graphs

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

Moderators: Developers, Moderators

Post Reply
dS_Jeffrey
Posts: 16
Joined: Thu Nov 08, 2007 5:33 pm

[SOLVED] Ratio Graphs

Post by dS_Jeffrey »

Im having a hard time understanding how to create a ratio graph with 2 or more inputs.

I want a graph that takes 2 numbers.

i.e. [x:3][y:7]

and the graph is obviously 100%, so x should take up the bottom 30% and y should take up the upper 70%.

Code: Select all

y
y
y
y
y
y
y
x
x
x
Im sure this should be doable through cdefs, just im not understanding how to use them.

Any help would be appreciated.

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

Post by gandalf »

Write a script, that produces the following output

Code: Select all

prompt> script <hostname>
var1:123   var2:234
where 123 represents x and 234 represents y.
See first link of my signature to learn how to add all this to cacti. Create a Graph Template (discussed in full detail), using an AREA for x and a STACK for y. That's it
Reinhard
dS_Jeffrey
Posts: 16
Joined: Thu Nov 08, 2007 5:33 pm

Post by dS_Jeffrey »

Hi gandalf,

I know how to get data into cacti and how to create templates (data/graph/host).

What I am trying to do is make a graph out of any number of values with a total of 100%. But the hard part which i am having trouble with is the fact that i am trying to accomplish this task without having to create more data sets. Instead i would like to use the already implemented data sets and create a percentile graph from it.

so if i have 3 values, [12,5,6]

$total = 12 + 5 + 6 = 23;

$precent1 = 12 / 23 = 0.522 * 100 = 52.2%
$precent2 = 5 / 23 = 0.217 * 100 = 21.7%
$precent3 = 6 / 23 = 0.261 * 100 = 26.1%

so in the end i want to graph the given percentages (always equal to 100%)

I am fully capable of doing this with the given data using server side scripts to perform these calculations, but from what i understand using cdef's will allow me to perform these calculations without having to create these extra data templates, and instead using the data i already have gathered.

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

Post by gandalf »

Yes, that's perfectly ok. You will need a single CDEF only. Assuming, the DEFs are named a, b, c, respectively, you will end up with a CDEF

Code: Select all

CDEF=CURRENT_DATA_SOURCE,a,b,c,+,+,/,100,*
If a,b,c are the only datasource of that Graph Template, you may use

Code: Select all

CDEF=CURRENT_DATA_SOURCE,ALL_DATA_SOURCES_NODUPS,/,100,*
instead (at least in theory)
Reinhard
dS_Jeffrey
Posts: 16
Joined: Thu Nov 08, 2007 5:33 pm

Post by dS_Jeffrey »

Thank you gandalf, this was very useful.

This did the trick and seems to be more dynamic
CDEF=CURRENT_DATA_SOURCE,ALL_DATA_SOURCES_NODUPS,/,100,*
I didn't quite understand the syntax at first, so i decided to do some research, I found the man pages via Oetiker's RRDTool homepage.

A couple of good links for anyone looking to use CDEFs:
http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html
http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html

Thanks again :)
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests