Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- from munin import MuninPlugin
- class LoadAVGPlugin(MuninPlugin):
- title = "Load average"
- args = "--base 1000 -l 0"
- vlabel = "load"
- scale = False
- category = "system"
- @property
- def fields(self):
- warning = os.environ.get('load_warn', 10)
- critical = os.environ.get('load_crit', 120)
- return [("load", dict(
- label = "load",
- info = 'The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").',
- type = "GAUGE",
- min = "0",
- warning = str(warning),
- critical = str(critical)))]
- def execute(self):
- if os.path.exists("/proc/loadavg"):
- loadavg = open("/proc/loadavg", "r").read().strip().split(' ')
- else:
- from subprocess import Popen, PIPE
- output = Popen(["uptime"], stdout=PIPE).communicate()[0]
- loadavg = output.rsplit(':', 1)[1].strip().split(' ')[:3]
- return dict(load=loadavg[1])
- if __name__ == "__main__":
- LoadAVGPlugin().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement