Skip to content

Instantly share code, notes, and snippets.

@mgor
Created March 2, 2017 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgor/1158505c12b594ff4b98a5f3dc1886cc to your computer and use it in GitHub Desktop.
Save mgor/1158505c12b594ff4b98a5f3dc1886cc to your computer and use it in GitHub Desktop.
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