Hi,
I'm looking for the most efficient way to obtain WiFI status information from the command line or in a shell script. By that I mean two things:
-
Query whether my wifi interfaces (2.4G and 5G) are up.
I'm aware that
ubus call network.wireless status
holds this information in JSON format. I have been trying to mangle this by piping it to sed/awk/grep in order to only get the information whether my two interfaces are up. This worked (via a somewhat ugly and long pipe sequence of sed, awk and grep), but it wasn't really efficient (the command took 2-3s to complete on my device). -
Count the number of connected clients per interface.
This seems to be easily done via
iwinfo <interface> assoclist | grep -cE '^([0-9A-F]{2}:){5}[0-9A-F]{2}'
which is already faster than the first command. But is this really the most efficient way?
The reason I'm asking for the quickest and most efficient way is that I'd like to monitor and log the Wi-Fi status with a script that is exectued in regular intervals. Hence I would like to keep the overhead of this as low as possbile.
Any hints are appreciated! Thanks!