Sha256: 5013ef73a2dfc243793a527a29befc222d06e9c9a372b4d9fdbd452a0de60997
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
module Perus::Pinger class Process < Command description 'Measures percentage of RAM and CPU used by the process specified by "process_path". The results are returned to the server under 2 metrics called "cpu_{name}" and "mem_{name}". Valid values for "process_path" are contained in the pinger config file.' option :process_path, restricted: true option :name metric! def run path = options.process_path.gsub("/", "\\\\\\/") cpu, mem = `ps aux | awk '/#{path}/ {cpu += $3; mem += $4} END {print cpu, mem;}'`.split if `uname -s`.strip == 'Darwin' core_count = `sysctl -n hw.ncpu` else core_count = `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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
perus-0.1.2 | lib/perus/pinger/metrics/process.rb |
perus-0.1.1 | lib/perus/pinger/metrics/process.rb |
perus-0.1.0 | lib/perus/pinger/metrics/process.rb |