Ticket #331 (closed defect: fixed)
Graph fails for labels ending backslash-space
| Reported by: | human | Owned by: | oetiker |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | rrd_graph | Version: | 1.4.6 |
| Keywords: | Cc: |
Description
Hello,
rrdgraph refuses to draw a graph that has a label ending in backslash-space. Zero or two spaces are OK. Double-escaping doesn't help.
Reproducer:
#!/bin/sh
RRD=backslash-space.rrd
BIN=rrdtool
T0=$(date +%s)
$BIN create $RRD \
--start $(($T0-3600)) \
--step=300 \
DS:42:GAUGE:600:U:U \
RRA:AVERAGE:0.5:1:12
$BIN update $RRD "$T0:1"
# only relevant difference is in LINE1
$BIN graph backslash-space.1.png \
"DEF:glabel=$RRD:42:AVERAGE" \
'LINE1:glabel#330099:usage \\' \
"GPRINT:glabel:LAST:%6.2lf%s" \
--start $(($T0 - 3600)) --end $T0
$BIN graph backslash-space.2.png \
"DEF:glabel=$RRD:42:AVERAGE" \
'LINE1:glabel#330099:usage \\ ' \
"GPRINT:glabel:LAST:%6.2lf%s" \
--start $(($T0 - 3600)) --end $T0
Expected: 481x155 (two times)
Got: Just one time, then
ERROR: Unknown control code at the end of ' usage XX '
(where XX is two backslashes, trac prefers to eat them)
This wasn't so bad if munin wouldn't attach a space to a label for padding. In other words, every plugin that has a field label ending in a backslash will not be drawn in munin.
Found in 1.4.3 (Debian squeeze) and 1.4.6 (compiled from source).
Regards,
Christoph
Change History
comment:2 Changed 4 months ago by human
Sorry, but that is not an acceptable solution. Doing this puts load onto the users of rrdgraph in a rather unusual way. Looking around in in the sources at leg_place I strongly suggest to re-write the escape character handling into a parsing from left to right. This would also allow literal '\t' sequences somewhere in the middle of a label, something not possible at the moment as in:
$BIN graph backslash-space.1.png \
"DEF:glabel=$RRD:42:AVERAGE" \
'LINE1:glabel#330099:usage C\:\\tmp' \
"GPRINT:glabel:LAST:%6.2lf%s" \
--start $(($T0 - 3600)) --end $T0
comment:3 Changed 4 months ago by oetiker
isn't it cool with opensource that you can get right to it, rectifying the unacceptable by writing an appropriate patch, supporting escape sequences throughout the string ... I agree, this would be a nice feature, note though that until now, backslashes inside the string had no special significance and were printed as-is ... so you would have to add some means to enable the new behavior, as it would probably break some existing uses.



The reason for this error is, that rrdtool now makes sure that only valid backslash escapes are used to terminate a string. There is curently no way of producing a string ending in backlash and a single character. You could have two spaces at end of the string.
In r2262 I added a \. control which acts as a nop ... so you can now do
cheers tobi