Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created August 31, 2010 05:12
Show Gist options
  • Save cablehead/558584 to your computer and use it in GitHub Desktop.
Save cablehead/558584 to your computer and use it in GitHub Desktop.
import pymongo
import time
servers = ['mongo1', 'mongo2']
master = pymongo.Connection(servers)
print "MASTER is: %s" % master.host
slave = pymongo.Connection(
[x for x in servers if x != master.host][0], slave_okay=True)
master.monitor.lag.save({'_id':'marker', 'now': time.time()})
print slave.admin.command(
pymongo.son.SON([('serverStatus', 1), ('repl', 2)])
)['repl']['sources'][0]['lagSeconds']
print master.monitor.lag.find_one()
print slave.monitor.lag.find_one()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment