mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-05-02 00:44:47 -04:00
guard against permission denied errors
reading from /proc/<pid>/smaps is not available inside of Docker container
This commit is contained in:
parent
04682335d4
commit
abe657dfce
1 changed files with 25 additions and 15 deletions
|
@ -86,12 +86,19 @@ def consume_mapping( map_lines, totals )
|
|||
return m
|
||||
end
|
||||
|
||||
def create_memstats_not_available( totals )
|
||||
Mapping::FIELDS.each do |field|
|
||||
totals[field] += Float::NAN
|
||||
end
|
||||
end
|
||||
|
||||
abort 'usage: memstats [pid]' unless ARGV.first
|
||||
pid = ARGV.shift.to_i
|
||||
totals = Hash.new(0)
|
||||
mappings = []
|
||||
|
||||
File.open( "/proc/#{pid}/smaps" ) do |smaps|
|
||||
begin
|
||||
File.open( "/proc/#{pid}/smaps" ) do |smaps|
|
||||
|
||||
map_lines = []
|
||||
|
||||
|
@ -111,6 +118,9 @@ File.open( "/proc/#{pid}/smaps" ) do |smaps|
|
|||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue
|
||||
create_memstats_not_available( totals )
|
||||
end
|
||||
|
||||
# http://rubyforge.org/snippet/download.php?type=snippet&id=511
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue