[rrd-users] Re: PERCENT question
rodrigo.santos at quantiza.com
rodrigo.santos at quantiza.com
Wed Dec 28 17:52:50 MET 2005
My script:
rrdtool graph totals.png --imgformat "PNG" \
DEF:total_out_bytes=/total.rrd:out_bytes:AVERAGE \
DEF:total_in_bytes=/total.rrd:in_bytes:AVERAGE \
CDEF:total_bytes=total_out_bytes,total_in_bytes,+ \
CDEF:total_Mbps=total_bytes,.000008,* \
DEF:subnet_out_bytes=/subnet.rrd:out_bytes:AVERAGE \
DEF:subnet_in_bytes=/subnet.rrd:in_bytes:AVERAGE \
CDEF:subnet_bytes=subnet_out_bytes,subnet_in_bytes,+ \
CDEF:subnet_Mbps=subnet_bytes,.000008,* \
'CDEF:subnet_in_bytes_pct=subnet_in_bytes' \
'CDEF:subnet_out_bytes_pct=subnet_out_bytes' \
'CDEF:subnet_bytes_pct=subnet_bytes' \
'CDEF:subnet_Mbps_pct=subnet_Mbps' \
'CDEF:total_Mbps_pct=total_Mbps' \
'CDEF:div_Mbps_pct=subnet_Mbps,total_Mbps,/' \
'CDEF:subnet_pct=subnet_Mbps,100,*,total_Mbps,/' \
AREA:subnet_pct:AVERAGE:'subnet %.1lf%%' \
GPRINT:subnet_in_bytes_pct:AVERAGE:'subnet IN BYTES %lf' \
GPRINT:subnet_out_bytes_pct:AVERAGE:'subnet OUT BYTES %lf' \
GPRINT:subnet_bytes_pct:AVERAGE:'subnet BYTES (IN+OUT) %lf' \
GPRINT:subnet_Mbps_pct:AVERAGE:'subnet Mbps (BYTES*0.000008) %lf' \
GPRINT:total_Mbps_pct:AVERAGE:'total Mbps %lf' \
GPRINT:div_Mbps_pct:AVERAGE:'DIV (subnet/TOTAL)Mbps %lf'
**The results:**
subnet_in_bytes = 3.2090625
subnet_out_bytes= 3.2090625
subnet_bytes = 6.418125 (IN+OUT) - OK
subnet_Mbps = 0.051345 (BYTES*0.000008) - OK
TOTAL_Mbps = 0.143296
div_Mbps = 0.272552 (subnet_Mbps/TOTAL_Mbps) <========== error
using a calculator, subnet/TOTAL is 0.358314, but using the RPN
expression:
subnet/TOTAL - 0.171951
subnet/0.143296- 0.358314 OK
0.051345/TOTAL - 2.863422 ???
using a shell command for testing the ksh, worked fine:
$ echo 0.051345 0.143296 | nawk '{printf("%0.6f\n", $1/$2);}'
0.358314
using a perl script for testing the perl, worked too:
$ perl -e "print 0.051345/0.143296"
0.358314258597588
Thanks,
Rodrigo
Leif Neland wrote:
> ---- Original Message ----
> From: <rodrigo.santos at quantiza.com>
> To: "Leif Neland" <leif at neland.dk>
> Cc: <rrd-users at list.ee.ethz.ch>
> Sent: Wednesday, December 28, 2005 2:08 PM
> Subject: [rrd-users] Re: PERCENT question
>
>> Yes, this is my question: "How many percent is the subnet traffic of
>> the total?"
>>
>> using RPN expressions, I have:
>>
>> subnet = 0.059110
>> total = 0.176248
>> using RPN expression 100,subnet,*,total,/ i have 12.02%
>>
>> but using a calculator, where:
>> 100 * subnet = 5.911 / total = 33.53%
>> subnet / total = 0.3353 * 100 = 33.53%
>>
>> What is the problem with RPN expressions??
>>
> I did a "constant" CDEF:
> CDEF:t=t4,t4,-,100,0.059110,*,0.176248,/,+
> GPRINT:t:LAST:%5.2lf
>
> It gives correctly 33.54, as expected.
>
> ( t4,t4,- (equals zero) is just a quick trick to avoid the message:
> ERROR: Cannot parse vname from 'CDEF:100,0.059110,*,0.176248,/ )
>
> Post the entire script using the RRD.
>
> Leif
>
>
>
>
>
--
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