X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=v2%2Fsrc%2Fawk%2Fexe%2Fparse_iwconfig.awk;fp=v2%2Fsrc%2Fawk%2Fexe%2Fparse_iwconfig.awk;h=95eedd1517fc76f08dea53c4cdb42b7f41bc89cd;hb=53d24ad688ea39892dbf3c748c1e40514eeb2763;hp=0000000000000000000000000000000000000000;hpb=0c4f892ec9d0cd7dc87c83c01b52259d0aed1ae3;p=khatus.git diff --git a/v2/src/awk/exe/parse_iwconfig.awk b/v2/src/awk/exe/parse_iwconfig.awk new file mode 100644 index 0000000..95eedd1 --- /dev/null +++ b/v2/src/awk/exe/parse_iwconfig.awk @@ -0,0 +1,35 @@ +# Example iwconfig output: +# ----------------------- +# $ iwconfig wlp3s0 +# wlp3s0 IEEE 802.11 ESSID:"BPLUNWIRED" +# Mode:Managed Frequency:5.785 GHz Access Point: E2:55:2D:C0:64:B8 +# Bit Rate=135 Mb/s Tx-Power=15 dBm +# Retry short limit:7 RTS thr:off Fragment thr:off +# Power Management:on +# Link Quality=59/70 Signal level=-51 dBm +# Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 +# Tx excessive retries:0 Invalid misc:0 Missed beacon:0 +# +# +# USAGE: khatus_parse_iwconfig -v requested_interface="$wifi_interface" + +/^[a-z0-9]+ +IEEE 802\.11 +ESSID:/ { + interface = $1 + split($4, essid_parts, ":") + essid[interface] = essid_parts[2] + gsub("\"", "", essid[interface]) +} + +/^ +Link Quality=[0-9]+\/[0-9]+ +Signal level=/ { + split($2, lq_parts_eq, "=") + split(lq_parts_eq[2], lq_parts_slash, "/") + cur = lq_parts_slash[1] + max = lq_parts_slash[2] + link[interface] = cur / max * 100 +} + +END { + i = requested_interface + status = link[i] ? sprintf("%s:%d%%", essid[i], link[i]) : "--:--%" + print("status" Kfs i, status) +}