Update longqueries tool: add --age parameter.
authorRadek Brich <radek.brich@devl.cz>
Tue, 05 Mar 2013 13:47:32 +0100
changeset 73 390376b9e70f
parent 72 539c2dd47f3b
child 74 d4306261ddfb
Update longqueries tool: add --age parameter.
longqueries.py
--- 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'),