This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| 093f0737 » | mojombo | 2007-06-16 | 1 | module God | |
| 2 | module System | ||||
| 3 | |||||
| 4 | class Process | ||||
| b1caa7a6 » | eric | 2009-10-25 | 5 | def self.fetch_system_poller | |
| 6 | @@poller ||= if SlashProcPoller.usable? | ||||
| 7 | SlashProcPoller | ||||
| 8 | else | ||||
| 9 | PortablePoller | ||||
| 10 | end | ||||
| 11 | end | ||||
| 12 | |||||
| 093f0737 » | mojombo | 2007-06-16 | 13 | def initialize(pid) | |
| 14 | @pid = pid.to_i | ||||
| b1caa7a6 » | eric | 2009-10-25 | 15 | @poller = self.class.fetch_system_poller.new(@pid) | |
| 093f0737 » | mojombo | 2007-06-16 | 16 | end | |
| 17 | |||||
| 18 | # Return true if this process is running, false otherwise | ||||
| 19 | def exists? | ||||
| 886f2815 » | mojombo | 2008-02-12 | 20 | !!::Process.kill(0, @pid) rescue false | |
| 093f0737 » | mojombo | 2007-06-16 | 21 | end | |
| 22 | |||||
| 23 | # Memory usage in kilobytes (resident set size) | ||||
| 24 | def memory | ||||
| 4bd50122 » | kevinclark | 2008-05-13 | 25 | @poller.memory | |
| 093f0737 » | mojombo | 2007-06-16 | 26 | end | |
| 27 | |||||
| 28 | # Percentage memory usage | ||||
| 29 | def percent_memory | ||||
| 4bd50122 » | kevinclark | 2008-05-13 | 30 | @poller.percent_memory | |
| 093f0737 » | mojombo | 2007-06-16 | 31 | end | |
| 32 | |||||
| 33 | # Percentage CPU usage | ||||
| 34 | def percent_cpu | ||||
| 4bd50122 » | kevinclark | 2008-05-13 | 35 | @poller.percent_cpu | |
| 093f0737 » | mojombo | 2007-06-16 | 36 | end | |
| 37 | |||||
| 38 | private | ||||
| 39 | |||||
| 466dbc34 » | kevinclark | 2008-05-13 | 40 | def fetch_system_poller | |
| b6f9cad5 » | raggi | 2008-06-16 | 41 | if SlashProcPoller.usable? | |
| 466dbc34 » | kevinclark | 2008-05-13 | 42 | SlashProcPoller | |
| 43 | else | ||||
| 44 | PortablePoller | ||||
| 45 | end | ||||
| 093f0737 » | mojombo | 2007-06-16 | 46 | end | |
| 47 | end | ||||
| 48 | |||||
| 49 | end | ||||
| b1caa7a6 » | eric | 2009-10-25 | 50 | end | |








