Skip to content

Instantly share code, notes, and snippets.

@remh
Created September 18, 2014 14:41
Show Gist options
  • Save remh/99163b7205fdcbdf2789 to your computer and use it in GitHub Desktop.
Save remh/99163b7205fdcbdf2789 to your computer and use it in GitHub Desktop.
per_cpu.py
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)]
)
@remh
Copy link
Author

remh commented Sep 18, 2014

per_cpu.yaml

init_config:

instances:
    - foo: bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment