Ticket #275 (reopened enhancement)

Opened 18 months ago

Last modified 18 months ago

Right axis formatting problem and crash

Reported by: human Owned by: oetiker
Priority: minor Milestone:
Component: rrd_graph Version: 1.5dev
Keywords: Cc:

Description

Hello I am using rrdtool to draw various graphs in a system one of which is utilisation of a network link.

First I use the following command to generate the graph.

#!/bin/bash

rrdtool graph '/var/tmp/jc.png'\

--font TITLE:8:/rtnc/backend/lib/perl/includes/mrtg_graphs/routines/Arial.ttf\ --title 'Link Utilisation Link1_WAN'\ --vertical-label 'Percent %'\ --right-axis 19840:0\ --right-axis-label 'Usage (bps)'\ --units-exponent 0\ --alt-y-grid\ --end 1282575378\ --start 1282488978\ --step 300\ --width 550\ --height 200\ --color BACK#ffffff\ --color SHADEA#ffffff\ --color SHADEB#ffffff\ --slope-mode\ --interlaced\

'DEF:in=/var/tmp/jc.rrd:ds0:AVERAGE'\ 'DEF:out=/var/tmp/jc.rrd:ds1:AVERAGE'\ 'CDEF:inbits=in,8,*'\ 'CDEF:outbits=out,8,*'\ 'CDEF:ingraph=in,8,*,1984000,/,100,*'\ 'CDEF:outgraph=out,8,*,1984000,/,100,*'\ 'CDEF:totval=ingraph,outgraph,+'\ 'VDEF:inmaxg=ingraph,MAXIMUM'\ 'VDEF:inming=ingraph,MINIMUM'\ 'VDEF:outmaxg=outgraph,MAXIMUM'\ 'VDEF:outming=outgraph,MINIMUM'\ 'VDEF:inaveg=ingraph,AVERAGE'\ 'VDEF:outaveg=outgraph,AVERAGE'\ 'VDEF:inmax=inbits,MAXIMUM'\ 'VDEF:outmax=outbits,MAXIMUM'\ 'VDEF:inmin=inbits,MINIMUM'\ 'VDEF:outmin=outbits,MINIMUM'\ 'VDEF:inave=inbits,AVERAGE'\ 'VDEF:outave=outbits,AVERAGE'\ 'COMMENT:(1984000 bps)\s'\ 'COMMENT:\s'\ 'LINE0.3:inmaxg#FF0000'\ 'LINE0.3:outmaxg#0000FF'\ 'LINE1:inaveg#660000'\ 'LINE1:outaveg#000066'\ 'LINE1:ingraph#FF0000:Inbound Traffic '\ 'GPRINT:inmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:inmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:inave:(Avg\:%3.2lf%Sbps)'\ 'COMMENT:\s'\ 'COMMENT:\s'\ 'LINE1:outgraph#0000FF:Outbound Traffic'\ 'GPRINT:outmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:outmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:outave:(Avg\:%3.2lf%Sbps)\s'

However the user viewing the graph has complained that the right axis is wrong (see attachment jc.png), as it shows 0M,1M,1M,2M,2M (some of the values are repeated). I assume this is rounding and not sure if this is a bug or not.

To resolve it, I tried adding the --right-axis-format value so the script now looks like this (the addition of --right-axis-format is the only change).

#!/bin/bash

rrdtool graph '/var/tmp/jc1.png'\

--font TITLE:8:/rtnc/backend/lib/perl/includes/mrtg_graphs/routines/Arial.ttf\ --title 'Link Utilisation Link1_WAN'\ --vertical-label 'Percent %'\ --right-axis 19840:0\ --right-axis-label 'Usage (bps)'\ --right-axis-format %3.2lf\ --units-exponent 0\ --alt-y-grid\ --end 1282575378\ --start 1282488978\ --step 300\ --width 550\ --height 200\ --color BACK#ffffff\ --color SHADEA#ffffff\ --color SHADEB#ffffff\ --slope-mode\ --interlaced\

'DEF:in=/var/tmp/jc.rrd:ds0:AVERAGE'\ 'DEF:out=/var/tmp/jc.rrd:ds1:AVERAGE'\ 'CDEF:inbits=in,8,*'\ 'CDEF:outbits=out,8,*'\ 'CDEF:ingraph=in,8,*,1984000,/,100,*'\ 'CDEF:outgraph=out,8,*,1984000,/,100,*'\ 'CDEF:totval=ingraph,outgraph,+'\ 'VDEF:inmaxg=ingraph,MAXIMUM'\ 'VDEF:inming=ingraph,MINIMUM'\ 'VDEF:outmaxg=outgraph,MAXIMUM'\ 'VDEF:outming=outgraph,MINIMUM'\ 'VDEF:inaveg=ingraph,AVERAGE'\ 'VDEF:outaveg=outgraph,AVERAGE'\ 'VDEF:inmax=inbits,MAXIMUM'\ 'VDEF:outmax=outbits,MAXIMUM'\ 'VDEF:inmin=inbits,MINIMUM'\ 'VDEF:outmin=outbits,MINIMUM'\ 'VDEF:inave=inbits,AVERAGE'\ 'VDEF:outave=outbits,AVERAGE'\ 'COMMENT:(1984000 bps)\s'\ 'COMMENT:\s'\ 'LINE0.3:inmaxg#FF0000'\ 'LINE0.3:outmaxg#0000FF'\ 'LINE1:inaveg#660000'\ 'LINE1:outaveg#000066'\ 'LINE1:ingraph#FF0000:Inbound Traffic '\ 'GPRINT:inmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:inmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:inave:(Avg\:%3.2lf%Sbps)'\ 'COMMENT:\s'\ 'COMMENT:\s'\ 'LINE1:outgraph#0000FF:Outbound Traffic'\ 'GPRINT:outmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:outmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:outave:(Avg\:%3.2lf%Sbps)\s'

This outputs the correct values (see jc1.png) but the values are so long that they over-write the key to the right-axis which looks ugly. So I tried to add %S on the end to use the suffixes as used later for the GPRINT statements in the same script. The documentation says you can use the same format string as you use for PRINT and GPRINT in the --right-axis-format. So I set the script to the following:-

#!/bin/bash

rrdtool graph '/var/tmp/jc2.png'\

--font TITLE:8:/rtnc/backend/lib/perl/includes/mrtg_graphs/routines/Arial.ttf\ --title 'Link Utilisation Link1_WAN'\ --vertical-label 'Percent %'\ --right-axis 19840:0\ --right-axis-label 'Usage (bps)'\ --right-axis-format %3.2lf%S\ --units-exponent 0\ --alt-y-grid\ --end 1282575378\ --start 1282488978\ --step 300\ --width 550\ --height 200\ --color BACK#ffffff\ --color SHADEA#ffffff\ --color SHADEB#ffffff\ --slope-mode\ --interlaced\

'DEF:in=/var/tmp/jc.rrd:ds0:AVERAGE'\ 'DEF:out=/var/tmp/jc.rrd:ds1:AVERAGE'\ 'CDEF:inbits=in,8,*'\ 'CDEF:outbits=out,8,*'\ 'CDEF:ingraph=in,8,*,1984000,/,100,*'\ 'CDEF:outgraph=out,8,*,1984000,/,100,*'\ 'CDEF:totval=ingraph,outgraph,+'\ 'VDEF:inmaxg=ingraph,MAXIMUM'\ 'VDEF:inming=ingraph,MINIMUM'\ 'VDEF:outmaxg=outgraph,MAXIMUM'\ 'VDEF:outming=outgraph,MINIMUM'\ 'VDEF:inaveg=ingraph,AVERAGE'\ 'VDEF:outaveg=outgraph,AVERAGE'\ 'VDEF:inmax=inbits,MAXIMUM'\ 'VDEF:outmax=outbits,MAXIMUM'\ 'VDEF:inmin=inbits,MINIMUM'\ 'VDEF:outmin=outbits,MINIMUM'\ 'VDEF:inave=inbits,AVERAGE'\ 'VDEF:outave=outbits,AVERAGE'\ 'COMMENT:(1984000 bps)\s'\ 'COMMENT:\s'\ 'LINE0.3:inmaxg#FF0000'\ 'LINE0.3:outmaxg#0000FF'\ 'LINE1:inaveg#660000'\ 'LINE1:outaveg#000066'\ 'LINE1:ingraph#FF0000:Inbound Traffic '\ 'GPRINT:inmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:inmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:inave:(Avg\:%3.2lf%Sbps)'\ 'COMMENT:\s'\ 'COMMENT:\s'\ 'LINE1:outgraph#0000FF:Outbound Traffic'\ 'GPRINT:outmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:outmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:outave:(Avg\:%3.2lf%Sbps)\s'

However this causes a crash:-

line 56: 11753 Segmentation fault

This looks like a bug to me. I would also appreciate your feedback on whether the scaling so the right-hand axis has duplicate values is also a bug?

I attached the RRD file in question. I am using v1.4.2 on CentOS 5.4 (Linux version 2.6.18-164.el5PAE)

Attachments

jc.rrd Download (102.7 KB) - added by human 18 months ago.
RRD file that causes crash
jc.png Download (37.2 KB) - added by human 18 months ago.
First graph output showing duplicate values in right hand y-axis
jc1.png Download (38.7 KB) - added by human 18 months ago.
Image showing actual bps speeds
jc3.png Download (40.4 KB) - added by human 18 months ago.
3rd graph without --alt-y-axis

Change History

Changed 18 months ago by human

RRD file that causes crash

Changed 18 months ago by human

First graph output showing duplicate values in right hand y-axis

Changed 18 months ago by human

Image showing actual bps speeds

comment:1 Changed 18 months ago by oetiker

the duplication is a side effect from using the alternative scaling options --alt*

the segfault comes from using a second formatting string in the axis format which is not supported ... I guess I would have to pre-parse the string to make sure people don't do this ...

cheers tobi

comment:2 Changed 18 months ago by oetiker

  • Status changed from new to closed
  • Resolution set to fixed

r2123 fixes the segfault ...

Changed 18 months ago by human

3rd graph without --alt-y-axis

comment:3 Changed 18 months ago by human

  • Status changed from closed to reopened
  • Resolution fixed deleted

Thank you for the response however I think there are still some problems. I tried removing all the "--alt" options, but I still get a problem with the graph. It now looks like the attached file "jc3.png". I've pasted the script I used below. Without the --alt-y-grid option I am still getting duplicates. In fact the problem seems to be worse, I know get 5 "1M".

Regarding the second problem the segfault I thought that --right-axis-format used the same syntax as PRINT and GPRINT where the same format string (%3.2lf%S) has been used without any problem.

So does that mean there is no way to get the right axis to use the same format but using the same units as in the print? As the same code is used for different links some of which report speeds in GB and others in KB, for example and the %S option works well here. It is a shame if it's not possible to use the same units on the right axis. If it is the case you can't use the same units on the right-axis perhaps you could consider it an enhancement request.

rrdtool graph '/var/tmp/jc3.png'\

--font TITLE:8:/rtnc/backend/lib/perl/includes/mrtg_graphs/routines/Arial.ttf\ --title 'Link Utilisation Link1_WAN'\ --vertical-label 'Percent %'\ --right-axis 19840:0\ --right-axis-label 'Usage (bps)'\ --units-exponent 0\ --end 1282575378\ --start 1282488978\ --step 300\ --width 550\ --height 200\ --color BACK#ffffff\ --color SHADEA#ffffff\ --color SHADEB#ffffff\ --slope-mode\ --interlaced\

'DEF:in=/var/tmp/jc.rrd:ds0:AVERAGE'\ 'DEF:out=/var/tmp/jc.rrd:ds1:AVERAGE'\ 'CDEF:inbits=in,8,*'\ 'CDEF:outbits=out,8,*'\ 'CDEF:ingraph=in,8,*,1984000,/,100,*'\ 'CDEF:outgraph=out,8,*,1984000,/,100,*'\ 'CDEF:totval=ingraph,outgraph,+'\ 'VDEF:inmaxg=ingraph,MAXIMUM'\ 'VDEF:inming=ingraph,MINIMUM'\ 'VDEF:outmaxg=outgraph,MAXIMUM'\ 'VDEF:outming=outgraph,MINIMUM'\ 'VDEF:inaveg=ingraph,AVERAGE'\ 'VDEF:outaveg=outgraph,AVERAGE'\ 'VDEF:inmax=inbits,MAXIMUM'\ 'VDEF:outmax=outbits,MAXIMUM'\ 'VDEF:inmin=inbits,MINIMUM'\ 'VDEF:outmin=outbits,MINIMUM'\ 'VDEF:inave=inbits,AVERAGE'\ 'VDEF:outave=outbits,AVERAGE'\ 'COMMENT:(1984000 bps)\s'\ 'COMMENT:\s'\ 'LINE0.3:inmaxg#FF0000'\ 'LINE0.3:outmaxg#0000FF'\ 'LINE1:inaveg#660000'\ 'LINE1:outaveg#000066'\ 'LINE1:ingraph#FF0000:Inbound Traffic '\ 'GPRINT:inmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:inmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:inave:(Avg\:%3.2lf%Sbps)'\ 'COMMENT:\s'\ 'COMMENT:\s'\ 'LINE1:outgraph#0000FF:Outbound Traffic'\ 'GPRINT:outmax:(Max\:%3.2lf%Sbps)'\ 'GPRINT:outmin:(Min\:%3.2lf%Sbps)'\ 'GPRINT:outave:(Avg\:%3.2lf%Sbps)\s'

comment:4 Changed 18 months ago by oetiker

  • Keywords crash segmentation fault removed
  • Priority changed from major to minor
  • Version changed from 1.4.2 to 1.5dev
  • Type changed from defect to enhancement

at the moment there is no magic scaling for the units of the right axis if you specify your own format ...

have a look at the code ... I'll be glad to integrate your patches if they work in a reasonable manner ...

I'll change this to an enhancement request and leave it open ...

cheers tobi

Note: See TracTickets for help on using tickets.

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.