| 1 | # Example iwconfig output: |
| 2 | # ----------------------- |
| 3 | # $ iwconfig wlp3s0 |
| 4 | # wlp3s0 IEEE 802.11 ESSID:"BPLUNWIRED" |
| 5 | # Mode:Managed Frequency:5.785 GHz Access Point: E2:55:2D:C0:64:B8 |
| 6 | # Bit Rate=135 Mb/s Tx-Power=15 dBm |
| 7 | # Retry short limit:7 RTS thr:off Fragment thr:off |
| 8 | # Power Management:on |
| 9 | # Link Quality=59/70 Signal level=-51 dBm |
| 10 | # Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 |
| 11 | # Tx excessive retries:0 Invalid misc:0 Missed beacon:0 |
| 12 | # |
| 13 | # |
| 14 | # USAGE: khatus_parse_iwconfig -v requested_interface="$wifi_interface" |
| 15 | |
| 16 | /^[a-z0-9]+ +IEEE 802\.11 +ESSID:/ { |
| 17 | interface = $1 |
| 18 | split($4, essid_parts, ":") |
| 19 | essid[interface] = essid_parts[2] |
| 20 | gsub("\"", "", essid[interface]) |
| 21 | } |
| 22 | |
| 23 | /^ +Link Quality=[0-9]+\/[0-9]+ +Signal level=/ { |
| 24 | split($2, lq_parts_eq, "=") |
| 25 | split(lq_parts_eq[2], lq_parts_slash, "/") |
| 26 | cur = lq_parts_slash[1] |
| 27 | max = lq_parts_slash[2] |
| 28 | link[interface] = cur / max * 100 |
| 29 | } |
| 30 | |
| 31 | END { |
| 32 | i = requested_interface |
| 33 | print("status" Kfs i, link[i] ? sprintf("%s:%d%%", essid[i], link[i]) : "--") |
| 34 | print("essid" Kfs i, link[i] ? essid[i] : "--") |
| 35 | print("link" Kfs i, link[i] ? link[i] : "--") |
| 36 | } |