forked from Boerderij/Varken
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsan.py
39 lines (31 loc) · 1022 Bytes
/
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
37
38
import subprocess
import requests
import re
import psutil
from datetime import datetime, timezone
from influxdb import InfluxDBClient
# noinspection PyUnresolvedReferences
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# noinspection PyUnresolvedReferences
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
current_time = datetime.now(timezone.utc).astimezone().isoformat()
raid6 = psutil.disk_usage('/media/usb')
influx_payload = [
{
"measurement": "Storage Servers",
"tags": {
"server": "SAN3"
},
"time": current_time,
"fields": {
"Name": '/mnt',
"bytes Used": raid6.used,
"bytes Free": raid6.free,
"bytes Total": raid6.total,
"Utilization": raid6.percent,
"IO_Wait": psutil.cpu_times_percent().iowait
}
}
]
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'storage_server')
influx.write_points(influx_payload)