vdstatus/plugins/disk.py

20 lines
640 B
Python

import plugins
import psutil
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, section, config):
super(PluginThread, self).__init__(section, config)
self.part = config.get(section, 'part')
def main(self):
du_stat = psutil.disk_usage(self.part)
if du_stat.percent >= self.problem_value:
self.hide = False
self.status['urgent'] = True
else:
self.hide = True
self.status['urgent'] = False
du_free = str(round(du_stat.free / 2**30, 2))
du = self.part + ': ' + du_free + 'G'
self.status['full_text'] = du