rrdtool-1.x icon indicating copy to clipboard operation
rrdtool-1.x copied to clipboard

removing NaN items from legend?

Open rlanyi opened this issue 4 years ago • 1 comments

Hi,

I'm using https://github.com/manuelkasper/AS-Stats/ to show some network graphs and I have rrdtool commands like the one below. The logic here is that I have to pass many RRD files (network links) to the command but not all of them will have valid data for this time period.

What I'd like to achieve is to remove the data from the graph (more specifically from the legend) if it is NaN. (In real life there are hundreds of these network links and it makes the legend and color associations unusable.)

So given the command below (RRDtool 1.7.2) what should I do to have only Conn2 and Conn3 in the legend and not the others with NaN values?

/usr/bin/rrdtool graph - --slope-mode --alt-autoscale -u 0 -l 0 --imgformat=PNG --base=1000 --height=295 --width=519 --color BACK#ffffffff --color SHADEA#ffffff00 --color SHADEB#ffffff00 --title 'AS9009 - M247 - IPV4' --start 1582942552 --end 1583538712 DEF:router1_74_in="/data/as-stats/rrd/31/9009.rrd":router1_74_in:AVERAGE DEF:router1_74_out="/data/as-stats/rrd/31/9009.rrd":router1_74_out:AVERAGE DEF:router1_82_in="/data/as-stats/rrd/31/9009.rrd":router1_82_in:AVERAGE DEF:router1_82_out="/data/as-stats/rrd/31/9009.rrd":router1_82_out:AVERAGE DEF:router1_95_in="/data/as-stats/rrd/31/9009.rrd":router1_95_in:AVERAGE DEF:router1_95_out="/data/as-stats/rrd/31/9009.rrd":router1_95_out:AVERAGE DEF:router1_65_in="/data/as-stats/rrd/31/9009.rrd":router1_65_in:AVERAGE DEF:router1_65_out="/data/as-stats/rrd/31/9009.rrd":router1_65_out:AVERAGE CDEF:router1_74_in_bits=router1_74_in,8,* CDEF:router1_74_out_bits=router1_74_out,-8,* CDEF:router1_82_in_bits=router1_82_in,8,* CDEF:router1_82_out_bits=router1_82_out,-8,* CDEF:router1_95_in_bits=router1_95_in,8,* CDEF:router1_95_out_bits=router1_95_out,-8,* CDEF:router1_65_in_bits=router1_65_in,8,* CDEF:router1_65_out_bits=router1_65_out,-8,* AREA:router1_74_in_bits#8A4EB8:"Conn1" AREA:router1_82_in_bits#DC22E3:"Conn2":STACK AREA:router1_95_in_bits#3A9790:"Conn3":STACK AREA:router1_65_in_bits#076C42:"Conn4":STACK AREA:router1_74_out_bits#8A4EB8: AREA:router1_82_out_bits#DC22E3::STACK AREA:router1_95_out_bits#3A9790::STACK AREA:router1_65_out_bits#076C42::STACK COMMENT:' \n' GPRINT:router1_74_in_bits:LAST:'Current\:%8.2lf %s' GPRINT:router1_74_in_bits:AVERAGE:'Average\:%8.2lf %s' GPRINT:router1_74_in_bits:MAX:'Maximum\:%8.2lf %s\n' GPRINT:router1_82_in_bits:LAST:'Current\:%8.2lf %s' GPRINT:router1_82_in_bits:AVERAGE:'Average\:%8.2lf %s' GPRINT:router1_82_in_bits:MAX:'Maximum\:%8.2lf %s\n' GPRINT:router1_95_in_bits:LAST:'Current\:%8.2lf %s' GPRINT:router1_95_in_bits:AVERAGE:'Average\:%8.2lf %s' GPRINT:router1_95_in_bits:MAX:'Maximum\:%8.2lf %s\n' GPRINT:router1_65_in_bits:LAST:'Current\:%8.2lf %s' GPRINT:router1_65_in_bits:AVERAGE:'Average\:%8.2lf %s' GPRINT:router1_65_in_bits:MAX:'Maximum\:%8.2lf %s\n' HRULE:0#00000080

gengraph

Please note that the GPRINT lines are only for debugging.

Thank you!

rlanyi avatar Mar 07 '20 00:03 rlanyi

As far as I'm aware, there's no conditional logic for graph items built into rrdtool. But it's probably better solved by customising whatever builds your graph commands.

For example, first use PRINT elements to return values without a graph. Then write your own conditional logic to build a similar command as a graph, filtering out any GPRINTS you don't want.

yrebrac avatar Jan 31 '21 13:01 yrebrac