Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
wifi_interface="$(nmcli d | awk '$2 ~ /wifi/ {print $1}')"
description="${1:-${wifi_interface}}"
sudo true
samples=10
sequences=($(seq 1 ${samples}))
total_link=0
total_level=0
for _ in "${sequences[@]}"
do
# shellcheck disable=SC2016
values=($(sudo awk '$1 ~ /'"${wifi_interface}"'/ {print $3" "$4}' /proc/net/wireless | sed 's/\.//g'))
link="${values[0]}"
level="${values[1]}"
total_link=$((total_link+link))
total_level=$((total_level+level))
echo "${description};${link};${level}"
sleep 10
done
average_link=$((total_link/samples))
average_level=$((total_level/samples))
echo "${description};${average_link};${average_level}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.