summaryrefslogtreecommitdiffabout
path: root/trafsum/traflog.awk
Unidiff
Diffstat (limited to 'trafsum/traflog.awk') (more/less context) (ignore whitespace changes)
-rw-r--r--trafsum/traflog.awk45
1 files changed, 45 insertions, 0 deletions
diff --git a/trafsum/traflog.awk b/trafsum/traflog.awk
new file mode 100644
index 0000000..7792fb9
--- a/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 301736
22
23BEGIN {
24 divisor = 1048576
25 maxtraf = 4294960000
26}
27
28NF==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
39END {
40 for (ip in inbytes) {
41 print ip " " inbytes[ip] / divisor " " outbytes[ip] / divisor
42 }
43}
44
45

Return to:

Send suggestions and report system problems to the System administrator.