[rrd-users] How to generate nicely formatted columns in the legend graph?

Jacques du Toit jacquesd at irisns.com
Sat Apr 15 22:39:45 CEST 2017


>> Quick question, how can I create nice columns that won't mess up the layout if numbers increment or decrements? Something like this: http://martybugs.net/linux/rrdtool/images/traffic_detail.png
>> 
>> I'm not trying stuff like here below, but it doesn't handle changing values, the columns shift position then...
> 
> As you've found out ... it's tricky sometimes.
> Make sure that your labels are all the same length - so pad out "User" and "System" so they are the same length as "User (nice)". Then make sure that all your value formats are of sufficient length that all values you might see will fit in the given size of display format. Between them, I find that these will line up the columns nicely, except ...
> 
> The biggest problem I find is getting the column headers to line up. I end up using trial and error to get the column headers "near enough" as no matter what I do, I have never managed to get them to line up exactly - as there's no label (like there is for the data lines), that throws the origin of the text off and the rest goes off as well.


In addition to padding out the the text you should use Pango markup (you might have to specify arg for this) and make all the GRPINT output use fixed-width font by adding <tt> tags...

 57       "LINE1:cpu_user_avg$RED:<tt>User\:    </tt> "\
 58       "GPRINT:cpu_user_avg:AVERAGE:<tt>%3.1lf</tt>" \                                     

You can also pad to the left of the numbers by increasing the number eg %8.1f will leave quite a large space to the left of the value allowing you to make your columns consistent. A bit of trial and error, but play around and see what looks nice.

Cheers,
  Jacques



 


More information about the rrd-users mailing list