Discussion:
[rrd-users] GPRINT string formating
Iñaki Martínez
2002-06-18 10:06:37 UTC
Permalink
Hi!!!!

I want to format the number in the following GPRINT:

GPRINT:used:MAX:" Max\: %9.0lf"
GPRINT:used:AVERAGE:"Current\: %9.0lf\c"


This print the following:

MAX: 12345678 Current: 12345678

but i want to see the following:

MAX: 12.345.678 Current: 12.345.678

is this posible???? how????


NOTE: number 12345678 is not real value.


--
Unsubscribe mailto:rrd-users-***@list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-***@list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
Alex van den Bogaerdt
2002-06-18 10:24:32 UTC
Permalink
Post by Iñaki Martínez
%9.0lf
MAX: 12345678 Current: 12345678
MAX: 12.345.678 Current: 12.345.678
is this posible???? how????
I don't think it is possible. RRDtool uses your OS's
printf implementation *and* it does some syntax checking.
So, even *if* your OS's printf could display it as such
then still RRDtool will complain (I think).

However, if you write a (part of a) front end that generates
a string in the format you want then of course you can display
this.

You'd have to use a three-step process:
1) calculate the numbers using "rrdtool graph /dev/null" and no
graphing options (ie use "PRINT", not "GPRINT")
2) format the numbers generated by (1) to your liking
3) generate a graph and use the strings generated by (2) inside
the label (ie "LINE1:target#color:$label"

HTH
--
__________________________________________________________________
/ ***@slot.hollandcasino.nl ***@ergens.op.het.net \
| work private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. |
+----------------------------------------------------------------------+
| http://faq.mrtg.org/ |
| http://rrdtool.eu.org --> tutorial |
+----------------------------------------------------------------------+

--
Unsubscribe mailto:rrd-users-***@list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-***@list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
Iñaki Martínez
2002-06-26 14:15:53 UTC
Permalink
Kaixo Alex van den Bogaerdt!!!
Post by Alex van den Bogaerdt
Post by Iñaki Martínez
%9.0lf
MAX: 12345678 Current: 12345678
MAX: 12.345.678 Current: 12.345.678
is this posible???? how????
I don't think it is possible. RRDtool uses your OS's
printf implementation *and* it does some syntax checking.
So, even *if* your OS's printf could display it as such
then still RRDtool will complain (I think).
OK.... i read the printf man .... look at this...

The following flags can be used to modify the behavior:

`-' Left-justify the result in the field. Normally the result is right-justified.

`+' Always include a plus or minus sign in the result.

` ' If the result doesn't start with a plus or minus sign, prefix it with a space instead. Since the `+' flag ensures that the result includes a sign, this flag is ignored if you supply both of them.

`#' Specifies that the result should always include a decimal point, even if no digits follow it. For the `%g' and `%G' conversions, this also forces trailing zeros after the decimal point to be left in place where they would otherwise be removed.

`'' Separate the digits of the integer part of the result into groups as specified by the locale specified for the LC_NUMERIC category; see section 7.6.1.1 Generic Numeric Formatting Parameters. This flag is a GNU extension.

`0' Pad the field with zeros instead of spaces; the zeros are placed after any sign. This flag is ignored if the `-' flag is also specified.


OK.... ALL of this works except `'' (what i want) that does not work..... :-(


%-9.0lf -> |123456 |
%+9.0lf -> | +123456|
%09.0lf -> |000123456|

How to use `'' or similar?????
Post by Alex van den Bogaerdt
However, if you write a (part of a) front end that generates
a string in the format you want then of course you can display
this.
I use rrdcgi........ in this case.......


Thanks...





--
Unsubscribe mailto:rrd-users-***@list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-***@list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
Alex van den Bogaerdt
2002-06-26 16:33:11 UTC
Permalink
Post by Iñaki Martínez
OK.... i read the printf man .... look at this...
You read *a* printf man.
Post by Iñaki Martínez
`'' Separate the digits of the integer part of the result into groups as specified by the locale specified for the LC_NUMERIC category; see section 7.6.1.1 Generic Numeric Formatting Parameters. This flag is a GNU extension.
RRDtool does some checking on the formatter string as well. I don't
know if it does something special with this single quote (didn't
check the code) but if it does, printf will never see it.

What could also happen is that the quote needs to be escaped.

HTH
--
__________________________________________________________________
/ ***@slot.hollandcasino.nl ***@ergens.op.het.net \
| work private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. |
+----------------------------------------------------------------------+
| http://faq.mrtg.org/ |
| http://rrdtool.eu.org --> tutorial |
+----------------------------------------------------------------------+

--
Unsubscribe mailto:rrd-users-***@list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-***@list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
Loading...