DIRACGrid/DIRAC — Issue #332: Servers and Agents not reporting Memory Usage
Author: graciani
Created: 2011-11-30 00:54:05+00:00
State: open
Labels: Bug

MemStat module always report 0:

```python
def VmB( vmKey ):
__memScale = {'kB': 1024.0, 'mB': 1024.0 * 1024.0, 'KB': 1024.0, 'MB': 1024.0 * 1024.0}
if vmKey not in __memScale:
return 0
procFile = '/proc/%d/status' % os.getpid()
# get pseudo file /proc//status
try:
myFile = open( procFile )
value = myFile.read()
myFile.close()
except:
return 0.0 # non-Linux?
# get vmKey line e.g. 'VmRSS: 9999 kB\n ...'
i = value.index( vmKey )
value = value[i:].split( None, 3 ) # whitespace
if len( value ) < 3:
return 0.0 # invalid format?
# convert Vm value to bytes
return float( value[1] ) * __memScale[value[2]]
```

it misses

```python
import os
```

and vmKey should be in:

VmPeak:	230620 kB
VmSize:	229004 kB
VmLck:	0 kB
VmHWM:	20564 kB
VmRSS:	19316 kB
VmData:	75632 kB
VmStk:	224 kB
VmExe:	1304 kB
VmLib:	7320 kB
VmPTE:	336 kB