Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple script that takes 10 samples of wifi signal quality and then calculates the average.
#!/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 index 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 "Sample ${index}: ${description};${link};${level}"
[[ "${index}" -lt "${samples}" ]] && sleep 10
done
average_link=$((total_link/samples))
average_level=$((total_level/samples))
echo ""
echo "Average:"
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.