def post_init(setup_config): """ The post_init function of the monitoring plugin. If networking is enabled the global monitoring manager is tried to be initialized = setting up a network connection to another endpoint :param setup_config: :return: """ logger.info("Running post init of the monitoring plugin") global_network_config.load(path=setup_config['net_config_path']) if global_monitoring_manager.networking_enabled(): def initialize_monitoring_manager(): monitoring_manager_initialized = False try: while not monitoring_manager_initialized: logger.info( "Try to initialize the global monitoring manager and setup the connection to the server!" ) succeeded = global_monitoring_manager.initialize( setup_config) if succeeded: monitoring_manager_initialized = True except CannotListenError, e: logger.exception( "Cannot start rafcon as a server: Address already in use!") import threading init_thread = threading.Thread(target=initialize_monitoring_manager) init_thread.daemon = True init_thread.start()
def load_config(self, path): """ A method to reload the origin network_monitoring_config.YAML :param path: path to the config file :return: """ global_network_config.load(path=path) del self.config_list[:] self.set_config_value(None, None)
def check_if_ports_are_open(): import psutil from acknowledged_udp.config import global_network_config config_path = os.path.abspath( path=os.path.dirname(os.path.abspath(__file__)) + "/server") global_network_config.load(path=config_path) for connection in psutil.net_connections(): if int(global_network_config.get_config_value( "SERVER_UDP_PORT")) == connection.laddr[1]: return False return True