longqueries.py
changeset 73 390376b9e70f
parent 44 4fe39c59c515
child 83 515fadd3d286
--- a/longqueries.py	Tue Mar 05 11:27:34 2013 +0100
+++ b/longqueries.py	Tue Mar 05 13:47:32 2013 +0100
@@ -7,12 +7,13 @@
 class LongQueriesTool(toolbase.SimpleTool):
     def __init__(self):
         toolbase.SimpleTool.__init__(self, name='longqueries', desc='List long queries.')
+        self.parser.add_argument('--age', default='1m', help='How long must be the query running to be listed.')
         self.init()
 
     def main(self):
         stats = pgstats.PgStats(self.pgm.get_conn('target'))
 
-        for ln in stats.list_long_queries('1m'):
+        for ln in stats.list_long_queries(self.args.age):
             print(highlight(1),
                   'backend PID: ', ln['procpid'],
                   ', query_start: ', ln['query_start'].strftime('%F %T'),