]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/env python |
2 | ||
3 | import json | |
4 | import os | |
5 | import re | |
6 | import subprocess | |
7 | ||
8 | disks = json.loads(subprocess.check_output("ceph-disk list --format json", shell=True)) | |
9 | used = 0 | |
10 | ||
11 | for disk in disks: | |
12 | for partition in disk.get('partition', []): | |
13 | if partition.get('type') == 'data': | |
14 | df = subprocess.check_output("df --output=used " + partition['path'], shell=True) | |
15 | used += int(re.findall('\d+', df)[0]) | |
16 | ||
17 | facts_file = os.environ.get("CEPH_FACTS_FILE", "/etc/rhsm/facts/ceph_usage.facts") | |
18 | open(facts_file, 'w').write("""\ | |
19 | { | |
20 | "band.storage.usage": {used} | |
21 | } | |
22 | """.replace('{used}', str(int(used/(1024*1024*1024))))) |