Project

General

Profile

Bug #3334 » iftop_parse.awk

Joshua Sign, 01/18/2019 06:17 PM

 
1
BEGIN {
2
        FS              = " " 
3
        numlist  = 0
4
	nblines  = 15
5
	printf "\n\n"
6
}
7
{
8
        if ( numlist == 1 && $1 == "--------------------------------------------------------------------------------------------" ) { 
9
        	exit
10
	}
11

    
12
        if ( numlist == 0 && $1 == "--------------------------------------------------------------------------------------------" ) { 
13
                numlist = 1 
14
                next
15
        }
16

    
17
        if ( numlist == 1 ) { 
18
                if ( $0 ~ "=>" && nblines > 0 ) {
19
                        SENDER = $2
20
                        STX = pfFormat($4)
21
                        getline
22
                        RECEIVER = $1
23
                        RTX = pfFormat($3)
24
			printf "%s;%s;%s\n", SENDER,RTX,STX
25
                        printf "%s;%s;%s\n", RECEIVER,STX,RTX
26
			nblines--
27
			if ( nblines < 1 ) {
28
				exit
29
			}
30
                }
31
                next
32
        }
33

    
34
}
35
END {
36
}
37

    
38
function pfFormat(str) {
39
	sub("b","",str)
40
	return str
41
}
42

    
(2-2/9)