tart / motop

"Top" clone for MongoDB
67 stars 24 forks source link

Support sharded enviroments #14

Closed julman99 closed 10 years ago

julman99 commented 11 years ago

It would be super cool if motop could be configured to connect to a mongos instance. This way it would be super easy to monitor queries accross a cluster.

Right now it crashes with the following message:

Traceback (most recent call last):
  File "/usr/local/bin/motop", line 5, in <module>
    pkg_resources.run_script('motop==3.1', 'motop')
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg/pkg_resources.py", line 1245, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/site-packages/motop-3.1-py2.7.egg/EGG-INFO/scripts/motop", line 4, in <module>
    motop.run()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/motop-3.1-py2.7.egg/libmotop/motop.py", line 98, in run
    queryScreen.action()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/motop-3.1-py2.7.egg/libmotop/queryscreen.py", line 296, in action
    block.reset()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/motop-3.1-py2.7.egg/libmotop/queryscreen.py", line 42, in reset
    status = server.status()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/motop-3.1-py2.7.egg/libmotop/server.py", line 108, in status
    values['activeClients'] = Value(status['globalLock']['activeClients']['total'])
KeyError: 'globalLock'
hasegeli commented 10 years ago

Recently added column for locks caused the KeyError. I tried to fix this and other errors caused by missing data from server. I have not upload it to PyPi yet. Can you test in on the master?

julman99 commented 10 years ago

Hi!

This is what I get from the master branch

Traceback (most recent call last):
  File "./motop", line 4, in <module>
    motop.run()
  File "/tmp/motop/libmotop/motop.py", line 95, in run
    queryScreen.action()
  File "/tmp/motop/libmotop/queryscreen.py", line 306, in action
    block.reset()
  File "/tmp/motop/libmotop/queryscreen.py", line 59, in reset
    cells.append([v * 10**6 for v in status.deepget('mem', ('resident', 'mapped'))])
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
hasegeli commented 10 years ago

I fixed it. Can you test it again?

hasegeli commented 10 years ago

I released version 4.0 anyway. Thank you for the bug report. I want to support sharded environments and replica sets in the future.

julman99 commented 10 years ago

Sorry for not anwering, I totally forgot! I will test this toughly during the holidays and maybe do a pull request supporting sharded environments.

Thanks!