mongoprof updates
This commit is contained in:
		
							parent
							
								
									b354eec7a0
								
							
						
					
					
						commit
						df246a8067
					
				
					 2 changed files with 7 additions and 5 deletions
				
			
		
							
								
								
									
										10
									
								
								mongoprof.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								mongoprof.py
									
									
									
									
									
								
							|  | @ -1,5 +1,5 @@ | ||||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||||
| __version__ = '0.1.0' | __version__ = '0.2.0' | ||||||
| 
 | 
 | ||||||
| import time | import time | ||||||
| import datetime | import datetime | ||||||
|  | @ -13,10 +13,10 @@ from termcolor import colored | ||||||
| quit = False | quit = False | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def watch(dbname, refresh): | def watch(dbname, refresh, slowms=0): | ||||||
|     global quit |     global quit | ||||||
|     db = getattr(Connection('localhost'), dbname) |     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() |     last_ts = datetime.datetime.utcnow() | ||||||
|     exclude_name = '{0}.system.profile'.format(dbname) |     exclude_name = '{0}.system.profile'.format(dbname) | ||||||
| 
 | 
 | ||||||
|  | @ -74,8 +74,10 @@ def watch(dbname, refresh): | ||||||
| def main(): | def main(): | ||||||
|     parser = argparse.ArgumentParser(description='watch mongo queries') |     parser = argparse.ArgumentParser(description='watch mongo queries') | ||||||
|     parser.add_argument('dbname', help='name of database to watch') |     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() |     args = parser.parse_args() | ||||||
|     watch(args.dbname, 0.1) |     watch(args.dbname, 0.1, args.slowms) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							|  | @ -2,7 +2,7 @@ from distutils.core import setup | ||||||
| 
 | 
 | ||||||
| setup( | setup( | ||||||
|     name='mongoprof', |     name='mongoprof', | ||||||
|     version='0.1.0', |     version='0.2.0', | ||||||
|     author='James Turk', |     author='James Turk', | ||||||
|     author_email='jturk@sunlightfoundation.com', |     author_email='jturk@sunlightfoundation.com', | ||||||
|     url='http://github.com/sunlightlabs/mongoprof', |     url='http://github.com/sunlightlabs/mongoprof', | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 James Turk
						James Turk