monitoring.py/monitors/ram.py
2019-12-30 16:18:42 +01:00

25 lines
1 KiB
Python

from psutil import virtual_memory, swap_memory
class Ram:
interval = 10;
loopCount = 0
def __init__(self, exporter):
self.exporter = exporter
def run(self):
mem = virtual_memory()
self.exporter.gauge("ram.total", mem.total)
self.exporter.gauge("ram.available", mem.available)
self.exporter.gauge("ram.percent", mem.percent)
self.exporter.gauge("ram.used", mem.used)
self.exporter.gauge("ram.free", mem.free)
self.exporter.gauge("ram.active", mem.active)
self.exporter.gauge("ram.inactive", mem.inactive)
self.exporter.gauge("ram.buffers", mem.buffers)
self.exporter.gauge("ram.cached", mem.cached)
self.exporter.gauge("ram.shared", mem.shared)
self.exporter.gauge("ram.slab", mem.slab)
mem = swap_memory()
self.exporter.gauge("swap.total", mem.total)
self.exporter.gauge("swap.percent", mem.percent)
self.exporter.gauge("swap.used", mem.used)
self.exporter.gauge("swap.free", mem.free)