diff --git a/mongoprof.py b/mongoprof.py index df81d1f..88a659b 100644 --- a/mongoprof.py +++ b/mongoprof.py @@ -9,8 +9,10 @@ import argparse from pymongo import Connection from termcolor import colored +# global quit monitor quit = False + def watch(dbname, refresh): global quit db = getattr(Connection('localhost'), dbname) @@ -41,7 +43,8 @@ def watch(dbname, refresh): elif e['op'] == 'update': output.append(colored('update {query}'.format(**e), 'green')) elif e['op'] == 'getmore': - output.append(colored('getmore {0}'.format(e.get('query', '')), 'grey')) + output.append(colored('getmore {0}'.format(e.get('query', '')), + 'grey')) elif e['op'] == 'command': output.append(colored('{command}'.format(**e), 'cyan')) else: @@ -64,6 +67,7 @@ def watch(dbname, refresh): last_ts = e['ts'] time.sleep(refresh) + def main(): parser = argparse.ArgumentParser(description='watch mongo queries') parser.add_argument('dbname', help='name of database to watch')