2016-10-22 19:27:28 +03:00
|
|
|
import psutil
|
2016-11-28 13:48:11 +02:00
|
|
|
import plugins
|
2016-10-22 19:27:28 +03:00
|
|
|
|
|
|
|
|
2019-07-05 18:24:46 +03:00
|
|
|
MEM_DEFAULTS = {'title': 'RAM', 'problem': 85}
|
2019-03-28 12:21:15 +02:00
|
|
|
|
|
|
|
|
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, MEM_DEFAULTS)
|
2016-10-22 19:27:28 +03:00
|
|
|
|
|
|
|
def main(self):
|
|
|
|
mem_stat = psutil.virtual_memory()
|
2019-03-06 10:31:39 +02:00
|
|
|
if mem_stat.percent > self.conf['problem']:
|
|
|
|
self.hide = False
|
2019-07-05 18:24:46 +03:00
|
|
|
urgent = True
|
2019-03-06 10:31:39 +02:00
|
|
|
else:
|
|
|
|
self.hide = True
|
2019-07-05 18:24:46 +03:00
|
|
|
urgent = False
|
2019-07-08 14:19:05 +03:00
|
|
|
|
|
|
|
status = '{:.2f}G'.format(mem_stat.available / 2**30)
|
|
|
|
self.format_status(status, urgent)
|