-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
62 lines (43 loc) · 1.75 KB
/
Copy pathserver.py
File metadata and controls
62 lines (43 loc) · 1.75 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
from bottle import route, run, template, request, static_file
from string import capwords
import ibm_db_dbi as dbi
conn = dbi.connect(dsn=None, database='*LOCAL',
user=None, password=None)
# Route for serving static files
@route('/static/<filename:path>')
def serve_static(filename):
return static_file(filename, root='./static')
@route('/', method=('GET', 'POST'))
def root():
reset = request.forms.get('reset') == 'true'
reset_parm = 'YES' if reset else 'NO'
sorting = request.forms.get('sorting') or '""'
show_cols = (
'JOB_NAME', 'AUTHORIZATION_NAME', 'JOB_TYPE', 'FUNCTION_TYPE',
'FUNCTION', 'JOB_STATUS', 'ELAPSED_INTERACTION_COUNT',
'ELAPSED_TOTAL_RESPONSE_TIME', 'ELAPSED_TOTAL_DISK_IO_COUNT',
'ELAPSED_ASYNC_DISK_IO_COUNT', 'ELAPSED_SYNC_DISK_IO_COUNT',
'ELAPSED_CPU_PERCENTAGE',
'ELAPSED_PAGE_FAULT_COUNT')
hide_cols = ('ELAPSED_TIME', )
all_cols = show_cols + hide_cols
headers = [titlePretty(col) for col in show_cols]
column_string = ', '.join(all_cols)
query = "select %s from table(qsys2.active_job_info(RESET_STATISTICS => ?)) x" % column_string
cur = conn.cursor()
cur.execute(query, (reset_parm, ))
elapsed_time = 0
row_data = []
for row in cur:
row_data.append(row[0: len(show_cols)])
elapsed_time = row[-1]
return template('./static/root', rows=row_data, headers=headers, elapsed_time=elapsed_time, sorting=sorting)
def titlePretty(column):
title = column.replace('_', ' ')
return capwords(title)
@route('<path:re:/.*\.(js|css|gif)>')
def static_assets(path):
with open(path[1:], "rb") as f:
return f.read()
run(host='0.0.0.0', port=3636, debug=True, reloader=True)