[rrd-users] Re: Newbie rrdtool fetch question

Leif Neland leif at neland.dk
Thu Oct 6 07:17:11 MEST 2005


Gary Danko wrote:
>
> I want to grab some of the information using rrdtool fetch and process
> it in a script but the output comes to me as:
>
> 1128534300: 1.6889052210e+07 5.1873403241e+07
> 1128534600: 1.6173097071e+07 5.1518386446e+07

> What I want to know is... How do I translate something like
> 5.4227032121e+07 into Kb/s or Mb/s?

It's 'floating point, 'scientific' or 'exponential' notation. What comes 
after the e is the power of 10 the number should be multiplied with, or the 
number of places the decimal point should be shifted right.

So 5.4227032121e+07 is 54227032.121 b/s or 54.227032121 Mb/s

To print the numbers as decimal, use printf, either in shellscripts or perl

# printf "%12.2f\n" 5.4227032121e+07
 54227032.12

bash can only do integer arithmetic, so you can't convert it to 54.2Mb/s, 
you have to do it in perl if you want to have numbers with decimals.

In bash:
expr `printf %.0f 5,4227032121e+07` / 1000000
The printf is important, it converts the floating point number to decimal.

In perl you could just use printf "%5.2f Mb/s\n" $value /1000000;

Leif




>
> Thanks in advance!
> Gary
>
> --
> 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 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

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