def __init__(self, args=None): self._args = args # initialize discovery client self._disc = None if self._args.disc_server_ip and self._args.disc_server_port: self._disc = client.DiscoveryClient( self._args.disc_server_ip, self._args.disc_server_port, ModuleNames[Module.SVC_MONITOR]) # initialize logger self.logger = ServiceMonitorLogger(self._disc, args) # rotating log file for catchall errors self._err_file = self._args.trace_file self._svc_err_logger = logging.getLogger('SvcErrLogger') self._svc_err_logger.setLevel(logging.ERROR) try: with open(self._err_file, 'a'): handler = logging.handlers.RotatingFileHandler(self._err_file, maxBytes=64 * 1024, backupCount=2) self._svc_err_logger.addHandler(handler) except IOError: self.logger.warning("Failed to open trace file %s" % self._err_file) # init cassandra self._cassandra = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._cassandra) # init rabbit connection self.rabbit = RabbitConnection(self.logger, args) self.rabbit._connect_rabbit()
def __init__(self, args=None): self._args = args # create database and logger self.db = ServiceMonitorDB(args) # initialize discovery client self._disc = None if self._args.disc_server_ip and self._args.disc_server_port: self._disc = client.DiscoveryClient( self._args.disc_server_ip, self._args.disc_server_port, ModuleNames[Module.SVC_MONITOR]) # initialize logger self.logger = ServiceMonitorLogger(self.db, self._disc, args) self.db.add_logger(self.logger) self.db.init_database() # rotating log file for catchall errors self._err_file = self._args.trace_file self._svc_err_logger = logging.getLogger('SvcErrLogger') self._svc_err_logger.setLevel(logging.ERROR) try: with open(self._err_file, 'a'): handler = logging.handlers.RotatingFileHandler(self._err_file, maxBytes=64 * 1024, backupCount=2) self._svc_err_logger.addHandler(handler) except IOError: self.logger.log("Failed to open trace file %s" % self._err_file)
def __init__(self, args=None): self._args = args # initialize logger self.logger = ServiceMonitorLogger(args) # rotating log file for catchall errors self._err_file = self._args.trace_file self._svc_err_logger = logging.getLogger('SvcErrLogger') self._svc_err_logger.setLevel(logging.ERROR) try: with open(self._err_file, 'a'): handler = logging.handlers.RotatingFileHandler(self._err_file, maxBytes=64 * 1024, backupCount=2) self._svc_err_logger.addHandler(handler) except IOError: self.logger.warning("Failed to open trace file %s" % self._err_file) # init object_db self._object_db = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._object_db) # init rabbit connection self.rabbit = VncAmqpHandle(self.logger, DBBaseSM, REACTION_MAP, 'svc_monitor', args=self._args) self.rabbit.establish()
def __init__(self, args=None): self._args = args # create database and logger self.db = ServiceMonitorDB(args) # initialize discovery client self._disc = None if self._args.disc_server_ip and self._args.disc_server_port: self._disc = client.DiscoveryClient(self._args.disc_server_ip, self._args.disc_server_port, client_type='Service Monitor') # initialize logger self.logger = ServiceMonitorLogger(self.db, self._disc, args) self.db.add_logger(self.logger) # rotating log file for catchall errors self._err_file = '/var/log/contrail/svc-monitor.err' self._tmp_file = '/var/log/contrail/svc-monitor.tmp' try: with open(self._err_file, 'a'): pass with open(self._tmp_file, 'a'): pass except IOError: self._err_file = './svc-monitor.err' self._tmp_file = './svc-monitor.tmp' self._svc_err_logger = logging.getLogger('SvcErrLogger') self._svc_err_logger.setLevel(logging.ERROR) handler = logging.handlers.RotatingFileHandler( self._err_file, maxBytes=64*1024, backupCount=2) self._svc_err_logger.addHandler(handler)
def __init__(self, sm_logger=None, args=None): self._args = args self._args.analytics_api_ssl_params = analytics_api_ssl_params(args) # initialize logger if sm_logger is not None: self.logger = sm_logger else: # Initialize logger self.logger = ServiceMonitorLogger(args) # init object_db self._object_db = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._object_db) # init rabbit connection rabbitmq_cfg = get_rabbitmq_cfg(args) if 'host_ip' in self._args: host_ip = self._args.host_ip else: host_ip = socket.gethostbyname(socket.getfqdn()) self.rabbit = VncAmqpHandle(self.logger._sandesh, self.logger, DBBaseSM, REACTION_MAP, 'svc_monitor', rabbitmq_cfg, host_ip, self._args.trace_file) self.rabbit.establish()
def __init__(self, sm_logger=None, args=None): self._args = args # initialize discovery client self._disc = None if self._args.disc_server_ip and self._args.disc_server_port: dss_kwargs = {} if self._args.disc_server_ssl: if self._args.disc_server_cert: dss_kwargs.update({'cert': self._args.disc_server_cert}) if self._args.disc_server_key: dss_kwargs.update({'key': self._args.disc_server_key}) if self._args.disc_server_cacert: dss_kwargs.update( {'cacert': self._args.disc_server_cacert}) self._disc = client.DiscoveryClient( self._args.disc_server_ip, self._args.disc_server_port, ModuleNames[Module.SVC_MONITOR], **dss_kwargs) # initialize logger if sm_logger is not None: self.logger = sm_logger else: # Initialize logger self.logger = ServiceMonitorLogger(self._disc, args) # rotating log file for catchall errors self._err_file = self._args.trace_file self._svc_err_logger = logging.getLogger('SvcErrLogger') self._svc_err_logger.setLevel(logging.ERROR) try: with open(self._err_file, 'a'): handler = logging.handlers.RotatingFileHandler(self._err_file, maxBytes=64 * 1024, backupCount=2) self._svc_err_logger.addHandler(handler) except IOError: self.logger.warning("Failed to open trace file %s" % self._err_file) # init cassandra self._cassandra = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._cassandra) # init rabbit connection self.rabbit = VncAmqpHandle(self.logger, DBBaseSM, REACTION_MAP, 'svc_monitor', args=self._args) self.rabbit.establish()
def __init__(self, sm_logger=None, args=None): self._args = args # initialize logger if sm_logger is not None: self.logger = sm_logger else: # Initialize logger self.logger = ServiceMonitorLogger(args) # init object_db self._object_db = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._object_db) # init rabbit connection rabbitmq_cfg = get_rabbitmq_cfg(args) self.rabbit = VncAmqpHandle(self.logger._sandesh, self.logger, DBBaseSM, REACTION_MAP, 'svc_monitor', rabbitmq_cfg, self._args.trace_file) self.rabbit.establish()
def _connect_rabbit(self): rabbit_server = self._args.rabbit_server rabbit_port = self._args.rabbit_port rabbit_user = self._args.rabbit_user rabbit_password = self._args.rabbit_password rabbit_vhost = self._args.rabbit_vhost rabbit_ha_mode = self._args.rabbit_ha_mode self._db_resync_done = gevent.event.Event() q_name = 'svc_mon.%s' % (socket.gethostname()) self._vnc_kombu = VncKombuClient(rabbit_server, rabbit_port, rabbit_user, rabbit_password, rabbit_vhost, rabbit_ha_mode, q_name, self._vnc_subscribe_callback, self.logger.log) self._cassandra = ServiceMonitorDB(self._args, self.logger) DBBaseSM.init(self, self.logger, self._cassandra)