2
|
1 |
#!/usr/bin/env python3.2
|
|
2 |
|
|
3 |
from pgtools import pgstats
|
5
|
4 |
from toolbase import SimpleTool
|
2
|
5 |
|
|
6 |
|
5
|
7 |
class LongQueriesTool(SimpleTool):
|
2
|
8 |
def __init__(self):
|
5
|
9 |
SimpleTool.__init__(self, name='longqueries', desc='List long queries.')
|
2
|
10 |
self.init()
|
|
11 |
|
|
12 |
def main(self):
|
|
13 |
stats = pgstats.PgStats(self.pgm.get_conn('target'))
|
|
14 |
|
|
15 |
for ln in stats.list_long_queries():
|
|
16 |
print(ln['query'])
|
|
17 |
print(' ', 'query_start:', ln['query_start'].strftime('%F %T'))
|
5
|
18 |
print()
|
2
|
19 |
|
|
20 |
|
|
21 |
tool = LongQueriesTool()
|
|
22 |
tool.main()
|
|
23 |
|