monitoring.py/monitors/hdd.py

18 lines
596 B
Python
Raw Normal View History

2019-12-30 15:18:42 +00:00
import os
import psutil
class HDD:
interval = 10;
loopCount = 0
def __init__(self, exporter):
self.exporter = exporter
def run(self):
discs = psutil.disk_partitions()
for disc in discs:
name = disc.device.split("/")[-1]
usage = psutil.disk_usage(disc.mountpoint)
self.exporter.gauge("hdd."+name+".total", usage.total)
self.exporter.gauge("hdd."+name+".used", usage.used)
self.exporter.gauge("hdd."+name+".free", usage.free)
self.exporter.gauge("hdd."+name+".percent", usage.percent)