Re: date stuff


Subject: Re: date stuff
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Sun Apr 21 2002 - 17:55:43 AKDT


> What I'm trying to do is grab usage data for an interface and stick
> the data into a file. This is all in a bash script. I'm working on
> this so I can collect usage on an IPCop box. So far I have
> something that looks like this.
>
> #!/bin/sh
> DTE=`date +%y%m%d`.raw
> DTEa=`date +%y%m%d`.stats
> ifconfig eth0 > $DTE
> grep 'RX bytes' $DTE > $DTEa
> rm $DTE -f
> exit 0

Why not just chain them:

  ifconfig eth0 | grep -E [RT]X > `date +%y%m%d`.stats

which will alleviate using a temp file (or too many variables).
 
> >From here I want to reformat the $DTEa file so that it clearly displays
> usage for RX and TX. Then eventually I want to build a cgi
> interface that will display all this stuff through a web browser. I
> admit it's not the most elegant thing ever created, but it's a great
> learning tool for me.

BTW, the modification I made to grep above will capture both RX & TX lines.
What you have above will only catch RX lines.

> Arthur, I have searched for info on IP accounting with ipchains and
> iptables, but the man pages don't say much and Google has too much
> (but not enough specifics).

Basic accounting is kept for all chains and rules. To see that data, just do:

   iptables -L -v

Verbose modes will report that (first two columns are packets and bytes for
the rules). Set a few rules (even just ACCEPT rules, if you're not doing any
filtering), and grep/awk the data as necessary. :-)

--

--Arthur Corliss Bolverk's Lair -- http://arthur.corlissfamily.org/ Digital Mages -- http://www.digitalmages.com/ "Live Free or Die, the Only Way to Live" -- NH State Motto

--------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Mon Apr 22 2002 - 11:50:43 AKDT