Created
October 5, 2014 17:14
-
-
Save ross-nordstrom/c8f6583de4d1db3f87d0 to your computer and use it in GitHub Desktop.
Get a breakdown of wifi protocol usage. Assumes wireless interface accessible at "wlan0".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
wifi = `iwlist wlan0 scan` | |
pieces2ghz = wifi.split("Cell ")[1..-1] | |
data = pieces2ghz.map{ |x| [ (x.split('Protocol:')[1].split("\n")[0] rescue '[UNKNOWN]') ] } | |
protocols = data.reduce({}) do |protocols, x| | |
protocols[x[0]] = protocols[x[0]] ? protocols[x[0]] + 1 : 1 | |
protocols | |
end | |
puts protocols.to_json.gsub(/"/, "'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment