2016-10-23 01:53:02 +03:00
|
|
|
import os
|
2016-11-28 13:48:11 +02:00
|
|
|
import plugins
|
2016-10-23 01:53:02 +03:00
|
|
|
|
|
|
|
|
2019-10-28 14:55:35 +02:00
|
|
|
LOAD_DEFAULTS = {'title': 'LOAD', 'freq': 20, 'problem': 1}
|
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, LOAD_DEFAULTS)
|
2016-10-23 01:53:02 +03:00
|
|
|
|
|
|
|
def main(self):
|
|
|
|
loads = os.getloadavg()
|
2017-12-16 01:55:28 +02:00
|
|
|
if loads[0] >= self.conf['problem']:
|
2016-10-31 14:20:07 +02:00
|
|
|
self.hide = False
|
2019-07-05 18:24:46 +03:00
|
|
|
urgent = True
|
2016-10-31 14:20:07 +02:00
|
|
|
else:
|
2017-01-13 13:00:37 +02:00
|
|
|
self.hide = True
|
2019-07-05 18:24:46 +03:00
|
|
|
urgent = False
|
|
|
|
status = '{:.2f} {:.2f} {:.2f}'.format(*loads)
|
2019-07-08 14:19:05 +03:00
|
|
|
|
|
|
|
self.format_status(status, urgent)
|