Skip to content

Instantly share code, notes, and snippets.

@rickhull
Created November 15, 2017 02:22
Show Gist options
  • Save rickhull/1d27886e99907bab5657ab8eb706ea55 to your computer and use it in GitHub Desktop.
Save rickhull/1d27886e99907bab5657ab8eb706ea55 to your computer and use it in GitHub Desktop.
group "cpu" do
File.readlines("/proc/stat").grep(/^cpu/).each do |l|
name, user, nice, csystem, idle, iowait, irq, softirq = l.split(/\s+/).map(&:to_i)
total = busy + idle
counter "busy", value: busy, mute: true
counter "total", value: total, mute: true
gauge "usage" do
value("busy") / value("total") * 100
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment