[rrd-users] rrdgraph: Negative values with --logarithmic

Christian Garbs mitch at cgarbs.de
Sun Oct 16 21:31:18 CEST 2016


Hi there,

looking through the mailing list archive, I found several requests
like mine over the last years:

"Why won't negative values show up in my graph when I use --lograrithmic?"

The answer was mostly that a logarithm is not defined for negative
numbers.

What I want to achieve (and what I think those other proponents also
had in mind) is that I essentially have some of my data mirrored at
the x-axis for better readability (don't draw two values on top of
each other).

For example I plot outgoing packets on my network as a positive values
while I plot the incoming packets via CDEF:output=0,outputx,- as
negative values.  So the outgoing rate is shown above the x-axis and
the incoming rate below the x-axis.

To tame network spikes somewhat I want to change the graph mode to
logarithmic.  This works for the positive values, but the negative
values simply vanish.  I just want the same transormation that happens
to the positive values applied 'mirrored' the the negative values.

Think of something like a "display-logarithm" function defined like
this:


double disp_log(double y)
{
	if (y == 0) {
		return 0;
	} else if (y > 0) {
		return log(y);
	} else {
		return -log(-y);
	}
}


While "-log(-y)" might look weird in a mathematical context I think that
it makes sense in describing "do the same as for positive values, only
in the other direction".


I have had a look at rrdgraph.c and think that I found the calculation
of the final y value for a given data point in the ytr() method.  But
I did not yet fully figure out how im->minval is computed (im->minval
seems to be the reason for negative values to be cut off).

(And if this makes sense at all, it should be probably be controlled
 by a commandline parametera and I have not yet started to look what
 else needs to be changed then: commandline parsing, internal
 configuration state, manpages, documentation...)


What do you think of this?
Would the be a useful feature?
Could this somehow be implemented?


Regards
Christian
-- 
....Christian.Garbs....................................https://www.cgarbs.de

  _../|_
='__   _~-.
     \'  ~-`\._
            |/~`



More information about the rrd-users mailing list