Module: Collectd::ProcStats
- Included in:
- Plugin
- Defined in:
- lib/collectd/proc_stats.rb
Overview
Included by Interface
Instance Method Summary collapse
- #process_status(field) ⇒ Object
- #with_full_proc_stats ⇒ Object
- #with_polled_cpu ⇒ Object
- #with_polled_memory ⇒ Object
Instance Method Details
#process_status(field) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/collectd/proc_stats.rb', line 5 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 |
#with_full_proc_stats ⇒ Object
41 42 43 44 |
# File 'lib/collectd/proc_stats.rb', line 41 def with_full_proc_stats with_polled_memory with_polled_cpu end |
#with_polled_cpu ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/collectd/proc_stats.rb', line 32 def with_polled_cpu cpu('user').polled_counter do (Process::times.utime * 100).to_i end cpu('system').polled_counter do (Process::times.stime * 100).to_i end end |
#with_polled_memory ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/collectd/proc_stats.rb', line 21 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 |