diff --git a/mongoprof.py b/mongoprof.py index d4336ee..37a9f81 100644 --- a/mongoprof.py +++ b/mongoprof.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -__version__ = '0.1.0' +__version__ = '0.2.0' import time import datetime @@ -13,10 +13,10 @@ from termcolor import colored quit = False -def watch(dbname, refresh): +def watch(dbname, refresh, slowms=0): global quit db = getattr(Connection('localhost'), dbname) - db.set_profiling_level(2) + db.set_profiling_level(1 if slowms else 2, slowms or 100) last_ts = datetime.datetime.utcnow() exclude_name = '{0}.system.profile'.format(dbname) @@ -74,8 +74,10 @@ def watch(dbname, refresh): def main(): parser = argparse.ArgumentParser(description='watch mongo queries') parser.add_argument('dbname', help='name of database to watch') + parser.add_argument('--slowms', type=int, default=0, + help='only show transactions slower than ms') args = parser.parse_args() - watch(args.dbname, 0.1) + watch(args.dbname, 0.1, args.slowms) if __name__ == '__main__': diff --git a/setup.py b/setup.py index 62dcf3b..1ef69d8 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from distutils.core import setup setup( name='mongoprof', - version='0.1.0', + version='0.2.0', author='James Turk', author_email='jturk@sunlightfoundation.com', url='http://github.com/sunlightlabs/mongoprof',