Sha256: f094f3aab030d2a64425b5523992adc8e3a0338a40c501d2cd5e52746a4c6c7a
Contents?: true
Size: 951 Bytes
Versions: 1
Compression:
Stored size: 951 Bytes
Contents
module Collectd ## # Included by Interface module ProcStats def process_status(field) fields = {} begin IO.readlines("/proc/#{$$}/status").each { |line| line.strip! if line =~ /^(.+?):\s+(.+)$/ fields[$1] = $2 end } rescue Errno::ENOENT nil else fields[field] end end def with_polled_memory memory('VmRSS').polled_gauge do v = process_status('VmRSS') ? v.to_i * 1024 : nil end memory('VmSize').polled_gauge do v = process_status('VmSize') ? v.to_i * 1024 : nil end self end def with_polled_cpu cpu('user').polled_counter do (Process::times.utime * 100).to_i end cpu('sys').polled_counter do (Process::times.stime * 100).to_i end end def with_full_proc_stats with_polled_memory with_polled_cpu end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
astro-collectd-0.0.8 | lib/collectd/proc_stats.rb |