Created
October 5, 2015 15:39
-
-
Save BastinRobin/8076831e19341607b805 to your computer and use it in GitHub Desktop.
Get Process Memory Data + Head
This file contains hidden or 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
| 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