class Perus::Pinger::Process
Public Instance Methods
run()
click to toggle source
# File lib/perus/pinger/metrics/process.rb, line 12 def run path = options.process_path.gsub("/", "\\/") cpu, mem = shell("ps aux | awk '/#{path}/ {cpu += $3; mem += $4} END {print cpu, mem;}'").split if darwin? core_count = shell('sysctl -n hw.ncpu') else core_count = shell("cat /proc/cpuinfo | grep processor | awk '{count += 1} END {print count}'") end { "cpu_#{options.name}" => cpu.to_f / core_count.to_i, "mem_#{options.name}" => mem.to_f } end