forked from p15670423/monkey
GC-3598: #resolved added process list
This commit is contained in:
parent
e5d809e7aa
commit
471fede2fe
|
@ -1,4 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
import socket
|
||||||
|
import psutil
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
||||||
__author__ = 'uri'
|
__author__ = 'uri'
|
||||||
|
@ -32,3 +34,25 @@ class SystemInfoCollector(object):
|
||||||
return OperatingSystem.Windows
|
return OperatingSystem.Windows
|
||||||
else:
|
else:
|
||||||
return OperatingSystem.Linux
|
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
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import socket
|
from . import InfoCollector
|
||||||
|
|
||||||
__author__ = 'uri'
|
__author__ = 'uri'
|
||||||
|
|
||||||
|
|
||||||
class LinuxInfoCollector(object):
|
class LinuxInfoCollector(InfoCollector):
|
||||||
"""
|
"""
|
||||||
System information collecting module for Linux operating systems
|
System information collecting module for Linux operating systems
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.info = {}
|
super(LinuxInfoCollector, self).__init__()
|
||||||
|
|
||||||
def collect(self):
|
|
||||||
self.info['hostname'] = socket.gethostname()
|
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
self.collect()
|
self.get_hostname()
|
||||||
|
self.get_process_list()
|
||||||
return self.info
|
return self.info
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
import socket
|
from . import InfoCollector
|
||||||
|
|
||||||
__author__ = 'uri'
|
__author__ = 'uri'
|
||||||
|
|
||||||
|
|
||||||
class WindowsInfoCollector(object):
|
class WindowsInfoCollector(InfoCollector):
|
||||||
"""
|
"""
|
||||||
System information collecting module for Windows operating systems
|
System information collecting module for Windows operating systems
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.info = {}
|
super(WindowsInfoCollector, self).__init__()
|
||||||
|
|
||||||
def collect(self):
|
|
||||||
self.info['hostname'] = socket.gethostname()
|
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
self.collect()
|
self.get_hostname()
|
||||||
|
self.get_process_list()
|
||||||
return self.info
|
return self.info
|
||||||
|
|
Loading…
Reference in New Issue