From 3afbd6b93feea5077b84caf36339acf41321251b Mon Sep 17 00:00:00 2001 From: acepace Date: Wed, 2 Mar 2016 15:38:51 +0200 Subject: [PATCH] GC-5502: #resolved - Added code to handle lack of permissions. --- chaos_monkey/system_info/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/chaos_monkey/system_info/__init__.py b/chaos_monkey/system_info/__init__.py index a4e82a23a..ed4005595 100644 --- a/chaos_monkey/system_info/__init__.py +++ b/chaos_monkey/system_info/__init__.py @@ -49,10 +49,22 @@ class InfoCollector(object): def get_process_list(self): processes = {} for process in psutil.process_iter(): - processes[process.pid] = {"name": process.name(), + try: + processes[process.pid] = {"name": process.name(), "pid": process.pid, "ppid": process.ppid(), "cmdline": " ".join(process.cmdline()), "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