forked from Boerderij/Varken
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsan.py
36 lines (32 loc) · 1.1 KB
/
san.py
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
import platform
import psutil
from datetime import datetime, timezone
from influxdb import InfluxDBClient
mount_points = ['/mnt/raid6-a', '/mnt/raid6-b']
# Do not edit below this line #
influx_payload = []
devices = {
'mount_points': {}
}
for mount in mount_points:
devices['mount_points'][mount] = {
'usage': psutil.disk_usage(mount)
}
influx_payload.append(
{
"measurement": "Storage Servers",
"tags": {
"server": platform.uname()[1],
"mount_point": mount
},
"time": datetime.now(timezone.utc).astimezone().isoformat(),
"fields": {
"bytes Used": devices['mount_points'][mount]['usage'].used,
"bytes Free": devices['mount_points'][mount]['usage'].free,
"bytes Total": devices['mount_points'][mount]['usage'].total,
"Utilization": devices['mount_points'][mount]['usage'].percent
}
}
)
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'storage_server')
influx.write_points(influx_payload)