1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/python
import os
import sys
from time import time
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "python-debian"))
import icommon
conn = icommon.get_sqlite_connection(icommon.sqlite_file)
c = conn.cursor()
try:
rows = c.execute('select count(*), type from %s where active=1 '
'group by type' % icommon.StatusDatabase.JOBS_TABLE).fetchall()
sum = 0
for row in rows:
sum += row[0]
timestamp = int(time())
print "queue_length:%d@%d" % (sum, timestamp)
rows = c.execute('select * from %s'
% icommon.StatusDatabase.FAILURES_TABLE).fetchall()
print "failures:%d@%d" % (len(rows), timestamp)
running = 0
for row in rows:
if row[1] == icommon.running_sentinel:
running += 1
print "running_approximation:%d@%d" % (running, timestamp)
except:
conn.rollback()
raise
finally:
c.close()
|