Redesign component interfaces
[khatus.git] / bin / khatus_parse_ip_addr
CommitLineData
0819928a
SK
1#! /usr/bin/awk -f
2
75b23ff8
SK
3BEGIN {
4 OFS = msg_fs ? msg_fs : "|"
5 Kfs = key_fs ? key_fs : ":"
6}
7
0819928a
SK
8/^[0-9]+:/ {
9 sub(":$", "", $1)
10 sub(":$", "", $2)
11 sequence = $1
12 interface = $2
75b23ff8 13 Interfaces[sequence] = interface
0819928a
SK
14}
15
16/^ +inet [0-9]/ {
17 sub("/[0-9]+", "", $2)
18 addr = $2
75b23ff8 19 Addrs[interface] = addr
0819928a
SK
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
29END {
30 for (seq=1; seq<=sequence; seq++) {
75b23ff8 31 interface = Interfaces[seq]
0819928a 32 label = substr(interface, 1, 1)
75b23ff8 33 addr = Addrs[interface]
0819928a 34 if (addr) {
75b23ff8
SK
35 bytes_read = io[interface, "r"]
36 bytes_written = io[interface, "w"]
0819928a 37 } else {
75b23ff8
SK
38 bytes_read = ""
39 bytes_written = ""
0819928a 40 }
75b23ff8
SK
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])
0819928a
SK
47 }
48}
This page took 0.021976 seconds and 4 git commands to generate.