X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=bin%2Fkhatus_parse_ip_addr;h=b1b2ecd8110163b3fc5762ac866e8867fee601e1;hb=e46c8cdd6749c2eac359d746e5aea0d890614362;hp=bc833b27244f1a5b2e4f88c74a28223bbf47ee75;hpb=0819928a2ed96fc0d56613ae16169489972fa5b3;p=khatus.git diff --git a/bin/khatus_parse_ip_addr b/bin/khatus_parse_ip_addr index bc833b2..b1b2ecd 100755 --- a/bin/khatus_parse_ip_addr +++ b/bin/khatus_parse_ip_addr @@ -1,17 +1,22 @@ #! /usr/bin/awk -f +BEGIN { + OFS = msg_fs ? msg_fs : "|" + Kfs = key_fs ? key_fs : ":" +} + /^[0-9]+:/ { sub(":$", "", $1) sub(":$", "", $2) sequence = $1 interface = $2 - interfaces[sequence] = interface + Interfaces[sequence] = interface } /^ +inet [0-9]/ { sub("/[0-9]+", "", $2) addr = $2 - addrs[interface] = addr + Addrs[interface] = addr } /^ +RX: / {transfer_direction = "r"} @@ -23,15 +28,21 @@ END { for (seq=1; seq<=sequence; seq++) { - interface = interfaces[seq] + interface = Interfaces[seq] label = substr(interface, 1, 1) - addr = addrs[interface] + addr = Addrs[interface] if (addr) { - curr_read = io[interface, "r"] - curr_write = io[interface, "w"] - print(interface, addr, curr_write, curr_read) + bytes_read = io[interface, "r"] + bytes_written = io[interface, "w"] } else { - print(interface) + bytes_read = "" + bytes_written = "" } + output["addr" Kfs interface] = addr + output["bytes_read" Kfs interface] = bytes_read + output["bytes_written" Kfs interface] = bytes_written + } + for (key in output) { + print(key, output[key]) } }