root / util / analyze.py @ 04733cdb
History | View | Annotate | Download (607 Bytes)
1 |
from gevent.pool import Pool |
---|---|
2 |
from gevent.timeout import Timeout |
3 |
from django.core.cache import cache |
4 |
|
5 |
def analyze(luns): |
6 |
results = [] |
7 |
graphs = [] |
8 |
for l in luns: |
9 |
graphs.extend(l.getGraphs()) |
10 |
p = Pool(30)
|
11 |
|
12 |
def _analyze_graphs(graph): |
13 |
t = Timeout(5)
|
14 |
t.start() |
15 |
try:
|
16 |
results.extend(graph.analyze_graph()) |
17 |
except (Timeout):
|
18 |
pass
|
19 |
finally:
|
20 |
t.cancel() |
21 |
|
22 |
p.imap(_analyze_graphs, graphs) |
23 |
res = sorted(results, key=lambda k: k['dev'], reverse=True) |
24 |
cache.set('lun:stats', res, 600) |
25 |
return res
|