blob: 9823fac080c1de706eaff6d4a281ab9653acb185 [file] [log] [blame]
koder aka kdanilova639e0a2015-03-17 15:30:36 +02001import json
2
3
4query = """
5select value from "{series}"
6where $timeFilter and
7host='{host}' and device='{device}'
8order asc
9"""
10
11
12def make_dashboard_file(config):
13 series = ['writes_completed', 'sectors_written']
14 dashboards = []
15
16 for serie in series:
17 dashboard = dict(title=serie, type='graph',
18 span=12, fill=1, linewidth=2,
19 tooltip={'shared': True})
20
21 targets = []
22
23 for ip, devs in config.items():
24 for device in devs:
25 params = {
26 'series': serie,
27 'host': ip,
28 'device': device
29 }
30
31 target = dict(
32 target="disk io",
33 query=query.replace("\n", " ").format(**params).strip(),
34 interval="",
35 alias="{0} io {1}".format(ip, device),
36 rawQuery=True
37 )
38 targets.append(target)
39
40 dashboard['targets'] = targets
41 dashboards.append(dashboard)
42
43 fc = open("grafana_template.js").read()
44 return fc % (json.dumps(dashboards),)
45
46
47print make_dashboard_file({'192.168.0.104': ['sda1', 'rbd1']})