-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathversionbar.py
More file actions
54 lines (45 loc) · 1.23 KB
/
versionbar.py
File metadata and controls
54 lines (45 loc) · 1.23 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
#!/usr/bin/env python3
# vim: ts=4 sw=4 expandtab:
import hashlib
import json
import matplotlib as mpl
import matplotlib.pyplot as plt
import os
import os.path
import psycopg2
import sys
HOST = 'localhost'
DBNAME = 'telemetry'
USER = 'postgres'
PASSPATH = os.path.join(os.environ['HOME'], '.pgpass')
PASSWORD = open(PASSPATH, "r").read().strip().split(':')[-1]
def main():
conn = psycopg2.connect(host=HOST, dbname=DBNAME, user=USER, password=PASSWORD)
cur = conn.cursor()
cur.execute('''
with cleanver as
(select regexp_replace(version, 'ceph version (([0-9.]+|Dev)).*', '\\1')
as ver from cluster_version)
select ver, count(ver) from cleanver
group by ver
order by ver
''')
versions = list()
counts = list()
for row in cur.fetchall():
versions.append(row[0])
counts.append(row[1])
conn.close()
fig, ax = plt.subplots(
subplot_kw=dict(xlabel='Ceph version', ylabel='Number of daemons')
)
ax.bar(
range(0, len(versions)),
counts,
tick_label=versions,
)
ax.tick_params(axis='x', labelrotation=90)
fig.subplots_adjust(bottom=0.2)
plt.savefig('versions.png')
if __name__ == '__main__':
sys.exit(main())