Skip to content

Instantly share code, notes, and snippets.

@enricruiz
Created November 15, 2011 20:14
Show Gist options
  • Save enricruiz/1368187 to your computer and use it in GitHub Desktop.
Save enricruiz/1368187 to your computer and use it in GitHub Desktop.
List defects on vsm redis db
require "redis"
redis = Redis.new(:host => "localhost", :port => 6379)
# Search duplicated vm's in pm's cache
keys = redis.keys("VirtualMachinesCache:cache:*")
keys.each do |key|
pms = redis.smembers(key)
vm_id = key.split(":")[2]
hosts = []
pms.each do |pm_id|
hosts.push(redis.hgetall("PhysicalMachine:#{pm_id}")["address"])
end
if hosts.size > 1
puts "Virtual machine #{vm_id} is cached in #{hosts.join(", ")}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment