Skip to content

Instantly share code, notes, and snippets.

@acidprime
Last active July 31, 2017 07:45
Show Gist options
  • Save acidprime/a4b2949bee99444822c7854a4725c052 to your computer and use it in GitHub Desktop.
Save acidprime/a4b2949bee99444822c7854a4725c052 to your computer and use it in GitHub Desktop.
FIrst stab at listing, then eventually replacing unifi names in the database.
#!/usr/bin/env ruby
require 'mongo'
begin
conn = Mongo::Connection.new('localhost', 27117,{})
db = conn['ace']
db.collections.each do |collection|
if collection.name == 'user'
#puts collection.find(name: 1).inspect
collection.find().each do |doc|
puts doc['hostname'] unless doc['hostname'].nil?
puts doc['mac']
puts doc['oui'] unless doc['oui'].nil?
end
end
end
conn.close
rescue StandardError => err
puts('Error: ')
puts(err)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment