Redesign component interfaces
[khatus.git] / bin / khatus_parse_ip_addr
1 #! /usr/bin/awk -f
2
3 BEGIN {
4 OFS = msg_fs ? msg_fs : "|"
5 Kfs = key_fs ? key_fs : ":"
6 }
7
8 /^[0-9]+:/ {
9 sub(":$", "", $1)
10 sub(":$", "", $2)
11 sequence = $1
12 interface = $2
13 Interfaces[sequence] = interface
14 }
15
16 /^ +inet [0-9]/ {
17 sub("/[0-9]+", "", $2)
18 addr = $2
19 Addrs[interface] = addr
20 }
21
22 /^ +RX: / {transfer_direction = "r"}
23 /^ +TX: / {transfer_direction = "w"}
24
25 /^ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ *$/ {
26 io[interface, transfer_direction] = $1;
27 }
28
29 END {
30 for (seq=1; seq<=sequence; seq++) {
31 interface = Interfaces[seq]
32 label = substr(interface, 1, 1)
33 addr = Addrs[interface]
34 if (addr) {
35 bytes_read = io[interface, "r"]
36 bytes_written = io[interface, "w"]
37 } else {
38 bytes_read = ""
39 bytes_written = ""
40 }
41 output["addr" Kfs interface] = addr
42 output["bytes_read" Kfs interface] = bytes_read
43 output["bytes_written" Kfs interface] = bytes_written
44 }
45 for (key in output) {
46 print(key, output[key])
47 }
48 }
This page took 0.04304 seconds and 4 git commands to generate.