1

I have a RRD database with data:

    "DS:pkts_transmitted:GAUGE:120:0:U",
    "DS:pkts_received:GAUGE:120:0:U",
    "DS:pkts_lost:GAUGE:120:0:U",
    "DS:rtt_min:GAUGE:120:0:U",
    "DS:rtt_avg:GAUGE:120:0:U",
    "DS:rtt_max:GAUGE:120:0:U",

And I want that the Avg line change colour if I lose any package.

For example, if I lose 5 packets make the line blue, if I lose 10 make it red.

enter image description here

I see people doing it but I read the documentation and I can't find how to do this.

Radu Radu
  • 177
  • 16

1 Answers1

3

The way to do this is to actually have multiple lines defined (one of each colour) and hide the ones you don't want to see at any time, using calculations.

For example, say we have an RRD with two DSs:

DS:x:GAUGE:60:0:U
DS:y:GAUGE:60:0:1

Now, we want to show the line for x in red if y is 0, and blue if it is 1. To do this, we create two calculated values, x1 and x2.

CDEF:x1=y,0,EQ,x,UNKN,IF
CDEF:x2=y,1,EQ,x,UNKN,IF

Thus, x1 is active if y=0 and x2 if y=1. Yes, this could be simplified, but I'm showing it like this for the example.

Now, we can make lines using these:

LINE:x1#ff0000:MyLine
LINE:x2#0000ff

Note that the second line doesn't need a legend. Now, the line will appear to change colour depending on the value of the y metric, since at any time the other line will be UNKN and therefore not displayed.

You can extend this, of course, to have multiple colours and more complex thresholds.

Steve Shipway
  • 3,754
  • 3
  • 22
  • 39
  • Thanks you, I done more or less the same. I have 7 item defs and with the poller just put the value in the position I need to colour and the other ones nan value. – Radu Radu Nov 22 '16 at 06:59