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