You may have data sources where you want to graph data you don't log, but that is based out of two other probes that you do log.
For instance, you may want:
House electricity use = PG&E counter + Photovoltaic Production counter
You don't have a probe that shows you house electricity use, but it's
trivial to compute by looking at current going to/from your electricity
provider, adding electricity that you produced with your solar panels.
There are two ways of doing this. Cacti 0.8.8 will support the COMPUTE keyword from rrdtool, but this would only work if your data sources to are all in the same RRD (in one of my cases, they were not).
The other solution is to use a hack with CDEF where you pick a random data source item as something to graph and set the CDEF field to a hardcoded operation on other source items you do have in your RRD (in the example below, you defined a new CDEF as 'cdefa,cdefb,+' (in graph management/CDEF) and refer to that CDEF name in your graph item which is called 'House Power Use' below.
As an example, this is the output from cacti in graph debug mode:
http://graphs.merlins.org/graphs/g.php? ... 1279990447
DEF:a="/var/lib/cacti/rra/houseecm1_25.rrd":PGE:AVERAGE \
DEF:b="/var/lib/cacti/rra/houseecm1_25.rrd":PV:AVERAGE \
CDEF:cdefa=a,3.6,* \
CDEF:cdefb=b,3.6,* \
CDEF:cdefc=cdefa,cdefb,+ \
LINE2:cdefa#F51D30FF:"" \
LINE2:cdefb#7EE600FF:"" \
AREA:cdefc#0000FFB2:"House Power Use" \
GPRINT:cdefc:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefc:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefc:MIN:"Minimum\:%8.2lf %s" \
GPRINT:cdefc:MAX:"Maximum\:%8.2lf %s\n"
Note that, I actually had to hardcode cdefa,cdefb in my cacti created CDEF, and got those values by looking at graph debug. It does break if you modify your graph to move items around.
Now, you can also create the same graph without having to show the values you computed from:
http://graphs.merlins.org/graphs/graph. ... 1279990794
The trick is to switch the first 2 data source items to 'comment', so they show up in the definition and are there to compute the CDEF you care about, but they don't get graphed:
DEF:a="/var/lib/cacti/rra/houseecm1_25.rrd":PGE:AVERAGE \
DEF:b="/var/lib/cacti/rra/houseecm1_25.rrd":PV:AVERAGE \
CDEF:cdefa=a,3.6,* \
CDEF:cdefb=b,3.6,* \
CDEF:cdefc=cdefa,cdefb,+ \
\
\
AREA:cdefc#0000FFFF:"House Power Use" \
GPRINT:cdefc:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefc:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefc:MIN:"Minimum\:%8.2lf %s" \
GPRINT:cdefc:MAX:"Maximum\:%8.2lf %s\n"
Then, if you want to go more hardcore, I was able to use gandalf's aggregate plugin to create a fancier graph like this one:
https://graphs.merlins.org/graphs/g.php ... nt_size=12
This one has 2 values computed via CDEF: "Unmonitored House Use" and "Total House Use".
I'll be honest in saying that it's a bit cumbersome because for each graph, the CDEF letters you pull from change, so I have to make a new CDEF to compute my missing data from it, and once I've made something like the "House Power Use" graph, I can't reuse it to compute something else like "Unmonitored House Use": I actually need to redefine everything from scratch in each graph but eh, it works :)
Howto: Graphing Data Source Items computed from other Items.
Moderators: Developers, Moderators
-
- Cacti User
- Posts: 86
- Joined: Mon Oct 12, 2009 3:11 pm
Howto: Graphing Data Source Items computed from other Items.
Last edited by marcmerlin on Fri Aug 13, 2010 11:54 pm, edited 1 time in total.
-
- Cacti User
- Posts: 86
- Joined: Mon Oct 12, 2009 3:11 pm
Err, right, that's exactly what I wrote in the howto.lynn1221 wrote:There are two ways of doing this. Cacti 0.8.8 will support the COMPUTE keyword from rrdtool, but this would only work if your data sources to are all in the same RRD (in one of my cases, they were not).
The other solution is to use a hack with CDEF where you pick a random data source item as something to graph and set the CDEF field to a hardcoded operation on other source items you do have in your RRD (in the example below, you defined a new CDEF as 'cdefa,cdefb,+' (in graph management/CDEF) and refer to that CDEF name in your graph item which is called 'House Power Use' below.
At least we agree
Marc
edited due to spam
R.
Who is online
Users browsing this forum: No registered users and 1 guest