OpenCue
OpenCue copied to clipboard
Incorrect indices retrieved from /proc/[PID]/statm
Note that _getStatFields returns a list with [None, None] as its first two values:
https://github.com/AcademySoftwareFoundation/OpenCue/blob/e7c38c6bf5a39eec650a1f7a3851dabcc10d6f48/rqd/rqd/rqmachine.py#L217-L219
So the following lines are running a regex against None, which results in a TypeError:
https://github.com/AcademySoftwareFoundation/OpenCue/blob/e7c38c6bf5a39eec650a1f7a3851dabcc10d6f48/rqd/rqd/rqmachine.py#L275-L282
Reviewing the output of man proc suggests that we do want the first two values returned by the /proc/[PID]/statm file:
/proc/[pid]/statm
Provides information about memory usage, measured in pages. The columns are:
size (1) total program size
(same as VmSize in /proc/[pid]/status)
resident (2) resident set size
(same as VmRSS in /proc/[pid]/status)
share (3) shared pages (i.e., backed by a file)
text (4) text (code)
lib (5) library (unused in Linux 2.6)
data (6) data + stack
dt (7) dirty pages (unused in Linux 2.6)
So the correct indices should be 2 and 3:
child_statm_fields = self._getStatFields(
rqd.rqconstants.PATH_PROC_PID_STATM.format(pid))
pids[pid]['statm_size'] = \
int(re.search(r"\d+", child_statm_fields[2]).group()) \
if re.search(r"\d+", child_statm_fields[2]) else -1
pids[pid]['statm_rss'] = \
int(re.search(r"\d+", child_statm_fields[3]).group()) \
if re.search(r"\d+", child_statm_fields[3]) else -1
fao @DiegoTavares