Consider the RRD database file prova.rrd. It contains two data sources:
total
, always reporting about 4 M of "something" (kbyte RAM)used
, showing an increase from about 200 k to about 2 M over a 10-years period.
There are aggregation at multiple levels, one over the span of 10 years.
The stand-alone graph for used
is the following, showing the increase over time:
The graph above was generated with the following command:
rrdtool graph prova-used.png \
--start $start \
--end $end \
--step $step \
--width $rows \
--height $height \
--disable-rrdtool-tag \
--title "prova" \
--vertical-label bytes \
--lower-limit 0 \
"DEF:used=$db:used:$cf" \
"DEF:total=$db:total:$cf" \
"CDEF:available=total,used,-" \
AREA:used#770000#CC0000:used\\c:STACK
From total
and used
we can calculate how much is available
and graph it:
rrdtool graph prova-available.png \
--start $start \
--end $end \
--step $step \
--width $rows \
--height $height \
--disable-rrdtool-tag \
--title "prova" \
--vertical-label bytes \
--lower-limit 0 \
"DEF:used=$db:used:$cf" \
"DEF:total=$db:total:$cf" \
"CDEF:available=total,used,-" \
AREA:available#007700#00CC00:available\\c:STACK
This is the result, showing a decrease in time:
It is possible to stack the two, here we have used
over available
and
everything goes fine:
rrdtool graph prova-used-over-available.png \
--start $start \
--end $end \
--step $step \
--width $rows \
--height $height \
--disable-rrdtool-tag \
--title "prova" \
--vertical-label bytes \
--lower-limit 0 \
"DEF:used=$db:used:$cf" \
"DEF:total=$db:total:$cf" \
"CDEF:available=total,used,-" \
AREA:available#007700#00CC00:available\\c:STACK \
AREA:used#770000#CC0000:used\\c:STACK
On the other hand, stacking available
over user
does not produce something meaningful:
rrdtool graph prova-available-over-user.png \
--start $start \
--end $end \
--step $step \
--width $rows \
--height $height \
--disable-rrdtool-tag \
--title "prova" \
--vertical-label bytes \
--lower-limit 0 \
"DEF:used=$db:used:$cf" \
"DEF:total=$db:total:$cf" \
"CDEF:available=total,used,-" \
AREA:used#770000#CC0000:used\\c:STACK \
AREA:available#007700#00CC00:available\\c:STACK
This was tested with:
rrdtool -v
RRDtool 1.7.2 Copyright by Tobias Oetiker <[email protected]>
Compiled Jul 28 2021 15:46:00
Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore,
last, lastupdate, first, info, list, fetch, tune,
resize, xport, flushcached
RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org/copyleft/gpl.html)
For more information read the RRD manpages
It seems that the bug depends on shading with a gradient. This:
rrdtool graph prova-available-over-user.png \
--start $start \
--end $end \
--step $step \
--width $rows \
--height $height \
--disable-rrdtool-tag \
--title "prova" \
--vertical-label bytes \
--lower-limit 0 \
"DEF:used=$db:used:$cf" \
"DEF:total=$db:total:$cf" \
"CDEF:available=total,used,-" \
AREA:used#CC0000:used\\c:STACK \
AREA:available#00CC00:available\\c:STACK
produces the expected graph: