Created
November 24, 2009 17:47
-
-
Save arya/242053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bluepill | |
module ProcessConditions | |
class ProcMemUsage < MemUsage | |
def run(pid) | |
begin | |
total = 0 | |
File.read("/proc/#{pid}/smaps").split("\n").each do |line| | |
line =~ /^(Private)_Dirty: +(\d+)/ | |
if $2 | |
total += $2.to_i | |
end | |
end | |
if total == 0 | |
return nil | |
else | |
return total | |
end | |
rescue Errno::EACCES, Errno::ENOENT | |
return nil | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment