Skip to content

Instantly share code, notes, and snippets.

@pixie79
Created March 13, 2013 12:21
Show Gist options
  • Save pixie79/5151597 to your computer and use it in GitHub Desktop.
Save pixie79/5151597 to your computer and use it in GitHub Desktop.
Trigger for working our cpu alert levels needed for sensu or nagios
#!/usr/bin/env python
# CPU Alert levels - based on number of CPU in machine
from __future__ import division
import multiprocessing
cpu = multiprocessing.cpu_count()
if cpu <= 2:
cpu = 3
# Warnings
w1cpu = ((cpu / 100) * 150)
w10cpu = ((cpu / 100) * 120)
w15cpu = ((cpu / 100) * 110)
# Critical
c1cpu = ((cpu / 100) * 200)
c10cpu = ((cpu / 100) * 150)
c15cpu = ((cpu / 100) * 120)
print "-w %s,%s,%s" % (w1cpu, w10cpu, w15cpu),
print "-c %s,%s,%s" % (c1cpu, c10cpu, c15cpu),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment