vdstatus/plugins/load.py

23 lines
558 B
Python
Raw Permalink Normal View History

import os
import plugins
LOAD_DEFAULTS = {'title': 'LOAD', 'freq': 20, 'problem': 1}
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, config):
super(PluginThread, self).__init__(config, LOAD_DEFAULTS)
def main(self):
loads = os.getloadavg()
if loads[0] >= self.conf['problem']:
2016-10-31 14:20:07 +02:00
self.hide = False
urgent = True
2016-10-31 14:20:07 +02:00
else:
self.hide = True
urgent = False
status = '{:.2f} {:.2f} {:.2f}'.format(*loads)
self.format_status(status, urgent)