Last active
July 31, 2017 07:45
-
-
Save acidprime/a4b2949bee99444822c7854a4725c052 to your computer and use it in GitHub Desktop.
FIrst stab at listing, then eventually replacing unifi names in the database.
This file contains 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 '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