2016-11-28 13:48:11 +02:00
|
|
|
import plugins
|
2016-10-23 01:53:02 +03:00
|
|
|
import psutil
|
|
|
|
|
|
|
|
|
2019-03-28 12:21:15 +02:00
|
|
|
DISK_DEFAULTS = {'partition': '/', 'problem': 80, 'freq': 15}
|
|
|
|
|
|
|
|
|
2016-11-28 13:48:11 +02:00
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
2019-03-28 12:21:15 +02:00
|
|
|
super(PluginThread, self).__init__(config, DISK_DEFAULTS)
|
2016-10-23 01:53:02 +03:00
|
|
|
|
|
|
|
def main(self):
|
2017-12-16 01:55:28 +02:00
|
|
|
du_stat = psutil.disk_usage(self.conf['partition'])
|
|
|
|
if du_stat.percent >= self.conf['problem']:
|
2016-10-31 14:10:30 +02:00
|
|
|
self.hide = False
|
|
|
|
self.status['urgent'] = True
|
|
|
|
else:
|
|
|
|
self.hide = True
|
|
|
|
self.status['urgent'] = False
|
2016-10-23 01:53:02 +03:00
|
|
|
du_free = str(round(du_stat.free / 2**30, 2))
|
2017-12-16 01:55:28 +02:00
|
|
|
disk_usage = self.conf['partition'] + ': ' + du_free + 'G'
|
|
|
|
self.status['full_text'] = disk_usage
|