diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-08-04 07:15:38 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-08-04 07:15:38 +0000 |
commit | 07bcede1f741ed4fac48427890f7fac912e6960b (patch) | |
tree | dabc11e89640e84ee3742c4c5fd75019184c9fc7 /trafsum/traflog.awk | |
parent | 557cc6a018232026c40e92cf1920431deb738b27 (diff) | |
download | ipacct-07bcede1f741ed4fac48427890f7fac912e6960b.tar.gz ipacct-07bcede1f741ed4fac48427890f7fac912e6960b.tar.bz2 |
The stuff was initially written somewhere around April-May 1999. The
subsequent modifications weren't considerable, and they were not documented
anyway. Somewhere I still keep the old RCS repository of the project but
it does not seem to be of any interest.
Diffstat (limited to 'trafsum/traflog.awk')
-rw-r--r-- | trafsum/traflog.awk | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/trafsum/traflog.awk b/trafsum/traflog.awk new file mode 100644 index 0000000..7792fb9 --- /dev/null +++ b/trafsum/traflog.awk | |||
@@ -0,0 +1,45 @@ | |||
1 | # $Id: traflog.awk,v 1.1 2005/08/04 07:15:38 gray Exp $ | ||
2 | # Copyright 2000, 2005 Sergey Poznyakoff | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 2, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program; if not, write to the Free Software | ||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | # MA 02110-1301, USA. | ||
18 | |||
19 | #Field assignment | ||
20 | # 1 2 3 4 5 6 7 8 | ||
21 | #Sun Jun 20 00:04:06 1999 208.244.48.32 30 1736 | ||
22 | |||
23 | BEGIN { | ||
24 | divisor = 1048576 | ||
25 | maxtraf = 4294960000 | ||
26 | } | ||
27 | |||
28 | NF==8 { | ||
29 | # Sanity check | ||
30 | if (0+$7 < 0 || 0+$8 < 0 || 0+$7 > maxtraf || 0+$8 > maxtraf) { | ||
31 | print NR ": Skipped (" $7 " " $8 ")" >"/dev/stderr" | ||
32 | next | ||
33 | } else { | ||
34 | inbytes[$6] += 0+$7 | ||
35 | outbytes[$6] += 0+$8 | ||
36 | } | ||
37 | } | ||
38 | |||
39 | END { | ||
40 | for (ip in inbytes) { | ||
41 | print ip " " inbytes[ip] / divisor " " outbytes[ip] / divisor | ||
42 | } | ||
43 | } | ||
44 | |||
45 | |||