Skip to content

Instantly share code, notes, and snippets.

@tiagomatos
Created March 18, 2016 17:41
Show Gist options
  • Save tiagomatos/e910b36489e5e361a988 to your computer and use it in GitHub Desktop.
Save tiagomatos/e910b36489e5e361a988 to your computer and use it in GitHub Desktop.
method to output Linux memory use by server thread in an array
def self.memmory(app_name, url)
pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$PROCESS_ID}"`.strip.split.map(&:to_i)
size_in_mb = size / 1024.0
{ pid: pid, app: app_name, size: size_in_mb, url: url, server_time: Time.now }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment