GC-5502: #resolved - Added code to handle lack of permissions.

This commit is contained in:
acepace 2016-03-02 15:38:51 +02:00
parent 6160556a3c
commit 3afbd6b93f
1 changed files with 13 additions and 1 deletions

View File

@ -49,10 +49,22 @@ class InfoCollector(object):
def get_process_list(self): def get_process_list(self):
processes = {} processes = {}
for process in psutil.process_iter(): for process in psutil.process_iter():
try:
processes[process.pid] = {"name": process.name(), processes[process.pid] = {"name": process.name(),
"pid": process.pid, "pid": process.pid,
"ppid": process.ppid(), "ppid": process.ppid(),
"cmdline": " ".join(process.cmdline()), "cmdline": " ".join(process.cmdline()),
"full_image_path": process.exe(), "full_image_path": process.exe(),
} }
except psutil.AccessDenied:
#we may be running as non root
#and some processes are impossible to acquire in Windows/Linux
#in this case we'll just add what we can
processes[process.pid] = {"name": "null",
"pid": process.pid,
"ppid": process.ppid(),
"cmdline": "ACCESS DENIED",
"full_image_path": "null",
}
pass
self.info['process_list'] = processes self.info['process_list'] = processes