[rrd-users] Re: How to put commas in gprint numbers

Alex van den Bogaerdt alex at ergens.op.het.net
Mon Dec 5 22:31:27 MET 2005


On Mon, Dec 05, 2005 at 11:55:42AM -0900, Colht, Charles wrote:
> I figured out a crude method to get thousands seperators in my graph
> numbers:
> 
> Fetch the last values directly from the rrd
> Add the commas
> Use COMMENT instead of GPRINT
> 
> I came up with this bit of perl:
> sub commafy {
>     my $text = reverse $_[0];
>     $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
>     return scalar reverse $text;
> }
> 
> I wrote this along time ago but couldn't figure out how to make rrd use
> it. There is a Number::Format module that is much more flexible but this
> gets the job done for me. 
> 
> Is there a way to get the values of DEFs and CDEFs without doing an
> external fetch or maybe have rrd call my sub within a CDEF?

Use PRINT in stead of GPRINT.  Then do as you do know.

On the comma's in (G)PRINT: is there a standard way of printing this?
If so, use that in stead of "%6.2lf".  I don't think there is a standard
way but if it works for you, why not.  Google for "manual printf"

-- 
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list