removed non-needed imports
This commit is contained in:
parent
0530a23a7c
commit
b47c845f6d
1 changed files with 28 additions and 27 deletions
55
san.py
55
san.py
|
@ -1,36 +1,37 @@
|
||||||
import requests
|
|
||||||
import psutil
|
|
||||||
import mdstat
|
import mdstat
|
||||||
|
import platform
|
||||||
from datetime import datetime, timezone, timedelta
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from influxdb import InfluxDBClient
|
from influxdb import InfluxDBClient
|
||||||
|
|
||||||
# noinspection PyUnresolvedReferences
|
mount_points = ['/mnt/raid6-a', '/mnt/raid6-b']
|
||||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
|
||||||
|
|
||||||
raid6 = psutil.disk_usage('/mnt')
|
# Do not edit below this line #
|
||||||
|
influx_payload = []
|
||||||
|
devices = {
|
||||||
|
'md': mdstat.parse()['devices'].keys(),
|
||||||
|
'mount_points': {}
|
||||||
|
}
|
||||||
|
|
||||||
influx_payload = [
|
for mount in mount_points:
|
||||||
{
|
devices['mount_points'][mount] = {
|
||||||
"measurement": "Storage Servers",
|
'usage': psutil.disk_usage(mount)
|
||||||
"tags": {
|
|
||||||
"server": "SAN2"
|
|
||||||
},
|
|
||||||
"time": datetime.now(timezone.utc).astimezone().isoformat(),
|
|
||||||
"fields": {
|
|
||||||
"Name": '/mnt',
|
|
||||||
"bytes Used": raid6.used,
|
|
||||||
"bytes Free": raid6.free,
|
|
||||||
"bytes Total": raid6.total,
|
|
||||||
"Utilization": raid6.percent,
|
|
||||||
"Non Degraded Disks": mdstat.parse()['devices']['md127']['status']['raid_disks'] / mdstat.parse()['devices']['md127']['status']['non_degraded_disks'] * 100,
|
|
||||||
"IO_Wait": psutil.cpu_times_percent().iowait
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
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 = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'storage_server')
|
||||||
influx.write_points(influx_payload)
|
influx.write_points(influx_payload)
|
||||||
|
|
Loading…
Reference in a new issue