[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to graph a CDEF? (for coloring nodes)



In each of our cities, we have two core routers. On our old weathermap, we
displayed each router as a single node. I'd like to combine each city's core
routers as a single node and color that node depending on the traffic going
between the cores. Here's the thing, I'd like to color the node based on
whichever value - in or out - is higher.

How about an example to help clarify?

if core1 is transmitting 2G to core2 and it's only 1G in the opposite
direction, I'd like to color the node with the 2G value.

Technically:

On my system, I have an rrd for each file. Let's call them core1.rrd and
core2.rrd.
Each rrd has input and output data source. I'll call those data-sources "in"
and "out" here. (By default these are often called ds0 and ds1)

Here's how I'd get the maximum value of the two in rrdgraph parlance:

# MAX here refers to the dataset, MAX or AVERAGE, in each RRD. It makes more
sense to use MAX here:
DEF:core1_in=path/to/core1.rrd:in:MAX
DEF:core1_out=path/to/core1.rrd:out:MAX

# MAXIMUM here is a function.
VDEF:core1_max=core1_in,core1_out,MAXIMUM

# VDEFs return a single value. If we want a series of data, that probably
looks like this (untested):
CDEF:core1_max=core1_in,core1_out,core1_in,core1_out,GT,IF

RPN is confusing to most. The above snippet is just:

for $i ( 0 .. scalar  @core1_in - 1) {
    if ( core1_in[i] > core1_out[i] ) {
        push @core1_max, $core1_in[i];
    }
    else {
        push @core1_max, $core1_out[i];
    }
}

The upshot is that it's not hard to get either a max scalar value or a list
of max values out of an RRD. The question is how do I hand this scalar or
list to weathermap so that it can color my nodes accordingly?

Thanks a bunch,
Joshua

Copyright 1994-2005, by Howard Jones. howie@thingy.com