How to generate nicely formatted columns in the legend graph?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to generate nicely formatted columns in the legend graph?

K. de Jong
Hi,


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...

 40       "DEF:cpu_user_avg=$RRDCOLLECT/stat_cpu.rrd:cpu_user:AVERAGE" \             
 41       "DEF:cpu_nice_avg=$RRDCOLLECT/stat_cpu.rrd:cpu_nice:AVERAGE" \             
 42       "DEF:cpu_system_avg=$RRDCOLLECT/stat_cpu.rrd:cpu_system:AVERAGE" \         
 43       "DEF:cpu_iowait_avg=$RRDCOLLECT/stat_cpu.rrd:cpu_iowait:AVERAGE" \         
 44       "DEF:cpu_user_min=$RRDCOLLECT/stat_cpu.rrd:cpu_user:MIN" \                 
 45       "DEF:cpu_nice_min=$RRDCOLLECT/stat_cpu.rrd:cpu_nice:MIN" \                 
 46       "DEF:cpu_system_min=$RRDCOLLECT/stat_cpu.rrd:cpu_system:MIN" \             
 47       "DEF:cpu_iowait_min=$RRDCOLLECT/stat_cpu.rrd:cpu_iowait:MIN" \             
 48       "DEF:cpu_user_max=$RRDCOLLECT/stat_cpu.rrd:cpu_user:MAX" \                 
 49       "DEF:cpu_nice_max=$RRDCOLLECT/stat_cpu.rrd:cpu_nice:MAX" \                 
 50       "DEF:cpu_system_max=$RRDCOLLECT/stat_cpu.rrd:cpu_system:MAX" \             
 51       "DEF:cpu_iowait_max=$RRDCOLLECT/stat_cpu.rrd:cpu_iowait:MAX" \             
 52       "DEF:cpu_user_last=$RRDCOLLECT/stat_cpu.rrd:cpu_user:LAST" \               
 53       "DEF:cpu_nice_last=$RRDCOLLECT/stat_cpu.rrd:cpu_nice:LAST" \               
 54       "DEF:cpu_system_last=$RRDCOLLECT/stat_cpu.rrd:cpu_system:LAST" \           
 55       "DEF:cpu_iowait_last=$RRDCOLLECT/stat_cpu.rrd:cpu_iowait:LAST" \           
 56       "TEXTALIGN:left" \                                                         
 57       "LINE1:cpu_user_avg$RED:User\:  " \                                        
 58       "GPRINT:cpu_user_avg:AVERAGE:%3.1lf" \                                     
 59       "GPRINT:cpu_user_min:MIN:%3.1lf" \                                         
 60       "GPRINT:cpu_user_max:MAX:%3.1lf" \                                         
 61       "GPRINT:cpu_user_last:LAST:%3.1lf" \                                       
 62       "LINE1:cpu_nice_avg$GREEN:User (nice)\:" \                                 
 63       "GPRINT:cpu_nice_avg:AVERAGE:%3.1lf" \                                     
 64       "GPRINT:cpu_nice_min:MIN:%3.1lf" \                                         
 65       "GPRINT:cpu_nice_max:MAX:%3.1lf" \                                         
 66       "GPRINT:cpu_nice_last:LAST:%3.1lf" \                                       
 67       "COMMENT:\n" \                                                             
 68       "LINE1:cpu_system_avg$BLUE:System\:" \                                     
 69       "GPRINT:cpu_system_avg:AVERAGE:%3.1lf" \                                   
 70       "GPRINT:cpu_system_min:MIN:%3.1lf" \                                       
 71       "GPRINT:cpu_system_max:MAX:%3.1lf" \                                       
 72       "GPRINT:cpu_system_last:LAST:%3.1lf" \                                     
 73       "LINE1:cpu_iowait_avg$MAGENTA:I/O\:       " \                              
 74       "GPRINT:cpu_iowait_avg:AVERAGE:%3.1lf" \                                   
 75       "GPRINT:cpu_iowait_min:MIN:%3.1lf" \                                       
 76       "GPRINT:cpu_iowait_max:MAX:%3.1lf" \                                       
 77       "GPRINT:cpu_iowait_last:LAST:%3.1lf" 


--
Kind regards,
Kees de Jong  |  OpenPGP fingerprint: 0x0E45C98AB51428E6

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to generate nicely formatted columns in the legend graph?

Simon Hobson
K. de Jong <[hidden email]> wrote:

> 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.

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to generate nicely formatted columns in the legend graph?

Jacques du Toit
>> 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



 
_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Loading...