Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import os
  4. from munin import MuninPlugin
  5.  
  6. class LoadAVGPlugin(MuninPlugin):
  7. title = "Load average"
  8. args = "--base 1000 -l 0"
  9. vlabel = "load"
  10. scale = False
  11. category = "system"
  12.  
  13. @property
  14. def fields(self):
  15. warning = os.environ.get('load_warn', 10)
  16. critical = os.environ.get('load_crit', 120)
  17. return [("load", dict(
  18. label = "load",
  19. info = 'The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").',
  20. type = "GAUGE",
  21. min = "0",
  22. warning = str(warning),
  23. critical = str(critical)))]
  24.  
  25. def execute(self):
  26. if os.path.exists("/proc/loadavg"):
  27. loadavg = open("/proc/loadavg", "r").read().strip().split(' ')
  28. else:
  29. from subprocess import Popen, PIPE
  30. output = Popen(["uptime"], stdout=PIPE).communicate()[0]
  31. loadavg = output.rsplit(':', 1)[1].strip().split(' ')[:3]
  32. return dict(load=loadavg[1])
  33.  
  34. if __name__ == "__main__":
  35. LoadAVGPlugin().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement