Class: Mongo::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/cubicle/support.rb

Instance Method Summary collapse

Instance Method Details

#slave_lagObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cubicle/support.rb', line 60

def slave_lag
  args = BSON::OrderedHash.new
  args["serverStatus"] = 1
  args["repl"] = 1
  result = self["admin"].command(args)
  local_time = result["localTime"]
  sources = {}
  result["repl"]["sources"].each do |source|
    sync_time = source["syncedTo"]["time"]
    sources[source["host"]] = local_time - sync_time
  end
  sources     
end