ff5e9c7d7c
Remove windows related code as we do not support running on windows Remove the idea of check status as it was added code and complexity that we did not gain much from. Remove some functions at the AgentCheck level that either added another layer of complexity that we did not get any functionality from or functions that we didnt use like events Change-Id: I4b6bc4f9d38e6b4f4fe5c632f885b84aaff7fd08
33 lines
933 B
Python
33 lines
933 B
Python
import sys
|
|
import inspect
|
|
import os
|
|
import signal
|
|
|
|
from monasca_agent.collector.checks import AgentCheck
|
|
from monasca_agent.common.util import Paths
|
|
|
|
|
|
def kill_subprocess(process_obj):
|
|
try:
|
|
process_obj.terminate()
|
|
except AttributeError:
|
|
os.kill(process_obj.pid, signal.SIGKILL)
|
|
|
|
|
|
def get_check(name, config_str):
|
|
checksd_path = Paths().get_checksd_path()
|
|
if checksd_path not in sys.path:
|
|
sys.path.append(checksd_path)
|
|
check_module = __import__(name)
|
|
check_class = None
|
|
classes = inspect.getmembers(check_module, inspect.isclass)
|
|
for name, clsmember in classes:
|
|
if AgentCheck in clsmember.__bases__:
|
|
check_class = clsmember
|
|
break
|
|
if check_class is None:
|
|
raise Exception(
|
|
"Unable to import check %s. Missing a class that inherits AgentCheck" % name)
|
|
|
|
return check_class.from_yaml(yaml_text=config_str, check_name=name)
|