Skip to content

Instantly share code, notes, and snippets.

@meise
Created January 18, 2013 00:28
Show Gist options
  • Save meise/4561220 to your computer and use it in GitHub Desktop.
Save meise/4561220 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
require 'json'
batctl = `sudo batctl vd json -n`
access_points, clients = [], []
batctl.each_line do |line|
json = JSON.parse(line)
if json['label'] =~ /^TT$/
clients << json['gateway']
end
if json['router']
access_points << json['router']
end
end
ap_without_exits = access_points.uniq.count-2 # fastd3, fastd1
puts "APs: #{ap_without_exits}"
puts "Clients: #{clients.uniq.count-(ap_without_exits*2)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment