[rrd-users] Can this script be optimised ?
Pablo Sanchez
pablo at blueoakdb.com
Wed Nov 28 15:32:11 CET 2012
[ Comments below, in-line ]
On 11/28/2012 07:23 AM, Simon Hobson wrote:
> [ trimmed ]
>
> this script seems to take a fair bit of resource, can anyone see any
> optimisation I've missed ?
Hi Simon,
When I do any optimization, I always instrument and prioritize the
slowest area of code.
Looking at the shell script below, there appear to be two areas of
optimization that you can change:
1) The while conditional check, and/or
2) The setting of UpdateVal
I'll assume the `rrdtool' can't be changed (e.g. the disk the .rrd is
on isn't the bottleneck.
Given the above, where's the slowness? Is it 1) or 2)?
>
>
> #!/bin/bash
> # Get traffic count from interface counters of global interface
>
> EndTime=$(( `/bin/date +%s` + 58 ))
> HostName=$( /usr/bin/head -1 /etc/hostname )
> while [ $( /bin/date +%s ) -lt ${EndTime} ]
> do
> UpdateVal=$( /sbin/ifconfig ethext | \
> /bin/grep 'RX bytes' | \
> /bin/sed -r -e 's/^.*RX bytes:([0-9]+) .* TX bytes:([0-9]+) .*$/\1:\2/' )
> /usr/bin/rrdtool update ${HostName}/global.rrd --daemon w.x.y.z
> "N:${UpdateVal}"
> sleep 2
> done
>
>
Cheers,
--
Pablo Sanchez - Blueoak Database Engineering, Inc
Ph: 819.459.1926 Blog: http://pablo.blog.blueoakdb.com
Fax: 760.860.5225 (US)
More information about the rrd-users
mailing list