rrdtool-1.x
rrdtool-1.x copied to clipboard
SVG output includes "junk after document element"
Describe the bug SVG output seems to include extra text after the svg document is completed causing it not to render in Firefox. I noticed this when attempting to port the pnp4nagios integration to use SVG, however I'm unable to get RRDtool to produce a valid SVG. Even when using the command line directly.
To Reproduce Using a command line like the following:
echo ' graph --daemon=unix:/omd/sites/default/tmp/run/rrdcached.sock - --slope-mode --color BACK#FFF --color SHADEA#FFF --color SHADEB#FFF --width=680 --height=200 --imgformat SVG --start 1598366187 --end 1598380587 --vertical-label "RTA" --title "Ping times" DEF:var1=/omd/sites/default/var/pnp4nagios/perfdata/hostname/_HOST__rta.rrd:1:AVERAGE CDEF:var1minimum=var1,var1,- CDEF:var230e20=var1,var1minimum,-,20,/,20,*,var1minimum,+ CDEF:var230e19=var1,var1minimum,-,20,/,19,*,var1minimum,+ CDEF:var230e18=var1,var1minimum,-,20,/,18,*,var1minimum,+ CDEF:var230e17=var1,var1minimum,-,20,/,17,*,var1minimum,+ CDEF:var230e16=var1,var1minimum,-,20,/,16,*,var1minimum,+ CDEF:var230e15=var1,var1minimum,-,20,/,15,*,var1minimum,+ CDEF:var230e14=var1,var1minimum,-,20,/,14,*,var1minimum,+ CDEF:var230e13=var1,var1minimum,-,20,/,13,*,var1minimum,+ CDEF:var230e12=var1,var1minimum,-,20,/,12,*,var1minimum,+ CDEF:var230e11=var1,var1minimum,-,20,/,11,*,var1minimum,+ CDEF:var230e10=var1,var1minimum,-,20,/,10,*,var1minimum,+ CDEF:var230e9=var1,var1minimum,-,20,/,9,*,var1minimum,+ CDEF:var230e8=var1,var1minimum,-,20,/,8,*,var1minimum,+ CDEF:var230e7=var1,var1minimum,-,20,/,7,*,var1minimum,+ CDEF:var230e6=var1,var1minimum,-,20,/,6,*,var1minimum,+ CDEF:var230e5=var1,var1minimum,-,20,/,5,*,var1minimum,+ CDEF:var230e4=var1,var1minimum,-,20,/,4,*,var1minimum,+ CDEF:var230e3=var1,var1minimum,-,20,/,3,*,var1minimum,+ CDEF:var230e2=var1,var1minimum,-,20,/,2,*,var1minimum,+ CDEF:var230e1=var1,var1minimum,-,20,/,1,*,var1minimum,+ AREA:var230e20#FFDC00:"Round Trip Times" AREA:var230e19#FFD600 AREA:var230e18#FFCF00 AREA:var230e17#FFC900 AREA:var230e16#FFC200 AREA:var230e15#FFBC00 AREA:var230e14#FFB600 AREA:var230e13#FFAF00 AREA:var230e12#FFA900 AREA:var230e11#FFA200 AREA:var230e10#FF9C00 AREA:var230e9#FF9600 AREA:var230e8#FF8F00 AREA:var230e7#FF8900 AREA:var230e6#FF8200 AREA:var230e5#FF7C00 AREA:var230e4#FF7600 AREA:var230e3#FF6F00 AREA:var230e2#FF6900 AREA:var230e1#FF6200 GPRINT:var1:LAST:"%6.2lf ms Last" GPRINT:var1:MAX:"%6.2lf ms Max" GPRINT:var1:AVERAGE:"%6.2lf ms Average\l" LINE1:var1#000000:"" HRULE:1500.000000#FFFF00:"Warning 1500.000000ms\n" HRULE:2000.000000#FF0000:"Critical 2000.000000ms\n" ' | /omd/sites/default/bin/rrdtool -
under RRDtool 1.5.4 produces a SVG, then there are 2 lines on the end:
777x301
OK u:0.03 s:0.01 r:0.04
It appears that the first is related to the size of the graph and the second may be related to the GPRINT or similiar.
Expected behavior
The SVG output should finish at the </svg> tag and no more data should be present
Screenshots

Desktop (please complete the following information):
- OS: Debian 9.x + OMD3.30
- Browser Firefox/bash
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
At the end of creation of a SVG graphic its size is given to stdout (or stderr?). Write the output of rrdtool to a file This will not contain the size. The size is very useful to use it in dynamically created html pages
Hmm, feels a bit weird to have something return stdout which is in the wrong format. I guess if it was in XML comments it'd be valid, that'd be easier for tools to work with.