[rrd-users] Re: using grep on snmp collected data

Alex van den Bogaerdt alex at ergens.op.het.net
Mon Nov 17 23:24:43 MET 2003

On Mon, Nov 17, 2003 at 09:26:26PM +0100, Serge Maandag wrote:
> Put these lines in a file called "bla" and for the sum of all entries between 10 and 14 try:
> cat bla | grep ' 1[0123]:'|awk '{s += $10}END{print "sum is", s, " average is", s/NR}'

In addition to the "useles use of cat award", this also qualifies
for the "useles use of grep award" :)

To save cpu cycles, file descriptors and what more:

<bla awk '/ 1[0123]:/{s+=$10}END{print "sum is",s," average is ",s/NR}'

This, by the way, selects " 10:" which probably stands for the
timeframe "09:55:00 .. 10:00:00".  After all, a rate is not known
until the time has passed; the entry at 10:00 should thus describe
the past, not the future.  Similarly 14:00:00 is not selected while
it probably should.


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://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-users mailing list