Created
September 18, 2014 14:41
-
-
Save remh/99163b7205fdcbdf2789 to your computer and use it in GitHub Desktop.
per_cpu.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil | |
from checks import AgentCheck | |
class CPUTimes(AgentCheck): | |
def check(self, instance): | |
cpu_times = psutil.cpu_times(percpu=True) | |
for i, cpu in enumerate(cpu_times): | |
for key, value in cpu._asdict().iteritems(): | |
self.rate( | |
"system.per_cpu.{0}".format(key), | |
100.0 * value, | |
tags=["cpu:{0}".format(i)] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
per_cpu.yaml