vdstatus/plugins/mem.py

20 lines
615 B
Python
Raw Normal View History

2016-10-22 19:27:28 +03:00
import psutil
import plugins
2016-10-22 19:27:28 +03:00
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, config):
defaults = {'problem': 85}
super(PluginThread, self).__init__(config, defaults)
2016-10-22 19:27:28 +03:00
def main(self):
mem_stat = psutil.virtual_memory()
if mem_stat.percent > self.conf['problem']:
self.hide = False
self.status['urgent'] = True
else:
self.hide = True
self.status['urgent'] = False
mem_available = str(round(mem_stat.available / 2**30, 2))
self.status['full_text'] = 'RAM: ' + str(mem_available) + 'G'