Skip to content

Instantly share code, notes, and snippets.

@BastinRobin
Created October 5, 2015 15:39
Show Gist options
  • Select an option

  • Save BastinRobin/0d8e2e7724010fd76a02 to your computer and use it in GitHub Desktop.

Select an option

Save BastinRobin/0d8e2e7724010fd76a02 to your computer and use it in GitHub Desktop.
Get Process Memory Data + Head
import time
def get_memory(sajith):
start = time.time()
f = open(sajith)
for line in f.readlines():
a = line.split(':')
a[1] = a[1].strip()
if(a[0] == 'VmData'):
data = int(a[1].split()[0])
elif (a[0] == 'VmStk'):
stack = int(a[1].split()[0])
end = time.time()
return {
'VmData' : data,
'VmStk' : stack,
'time_taken' : (end - start)
}
p = 17803
sajith = get_memory('/proc/'+str(p)+'/status')
print sajith['VmData'] + sajith['VmStk']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment