GC-3598: #resolved added process list

This commit is contained in:
urihershgc 2015-12-09 16:33:44 +02:00
parent e5d809e7aa
commit 471fede2fe
3 changed files with 36 additions and 14 deletions

View File

@ -1,4 +1,6 @@
import sys
import socket
import psutil
from enum import IntEnum
__author__ = 'uri'
@ -32,3 +34,25 @@ class SystemInfoCollector(object):
return OperatingSystem.Windows
else:
return OperatingSystem.Linux
class InfoCollector(object):
"""
Generic Info Collection module
"""
def __init__(self):
self.info = {}
def get_hostname(self):
self.info['hostname'] = socket.gethostname()
def get_process_list(self):
processes = {}
for process in psutil.process_iter():
processes[process.pid] = {"name": process.name(),
"pid": process.pid,
"ppid": process.ppid(),
"cmdline": " ".join(process.cmdline()),
"full_image_path": process.exe(),
}
self.info['process_list'] = processes

View File

@ -1,19 +1,18 @@
import socket
from . import InfoCollector
__author__ = 'uri'
class LinuxInfoCollector(object):
class LinuxInfoCollector(InfoCollector):
"""
System information collecting module for Linux operating systems
"""
def __init__(self):
self.info = {}
def collect(self):
self.info['hostname'] = socket.gethostname()
super(LinuxInfoCollector, self).__init__()
def get_info(self):
self.collect()
self.get_hostname()
self.get_process_list()
return self.info

View File

@ -1,18 +1,17 @@
import socket
from . import InfoCollector
__author__ = 'uri'
class WindowsInfoCollector(object):
class WindowsInfoCollector(InfoCollector):
"""
System information collecting module for Windows operating systems
"""
def __init__(self):
self.info = {}
def collect(self):
self.info['hostname'] = socket.gethostname()
super(WindowsInfoCollector, self).__init__()
def get_info(self):
self.collect()
self.get_hostname()
self.get_process_list()
return self.info