Ejemplo n.º 1
0
def main(args_str=None):
    global _zookeeper_client

    if not args_str:
        args_str = ' '.join(sys.argv[1:])
    args = parse_args(args_str)
    if args.cluster_id:
        client_pfx = args.cluster_id + '-'
        zk_path_pfx = args.cluster_id + '/'
    else:
        client_pfx = ''
        zk_path_pfx = ''

    # initialize discovery client
    discovery_client = None
    if args.disc_server_ip and args.disc_server_port:
        dss_kwargs = {}
        if args.disc_server_ssl:
            if args.disc_server_cert:
                dss_kwargs.update({'cert': args.disc_server_cert})
            if args.disc_server_key:
                dss_kwargs.update({'key': args.disc_server_key})
            if args.disc_server_cacert:
                dss_kwargs.update({'cacert': args.disc_server_cacert})
        discovery_client = client.DiscoveryClient(
            args.disc_server_ip, args.disc_server_port,
            ModuleNames[Module.SVC_MONITOR], **dss_kwargs)
    # Initialize logger
    sm_logger = ServiceMonitorLogger(discovery_client,
                                     args,
                                     http_server_port=-1)

    # Initialize AMQP handler then close it to be sure remain queue of a
    # precedent run is cleaned
    vnc_amqp = VncAmqpHandle(sm_logger,
                             DBBaseSM,
                             REACTION_MAP,
                             'svc_monitor',
                             args=args)
    vnc_amqp.establish()
    vnc_amqp.close()
    sm_logger.debug("Removed remained AMQP queue")

    # Waiting to be elected as master node
    _zookeeper_client = ZookeeperClient(client_pfx + "svc-monitor",
                                        args.zk_server_ip)
    sm_logger.notice("Waiting to be elected as master...")
    _zookeeper_client.master_election(zk_path_pfx + "/svc-monitor",
                                      os.getpid(), run_svc_monitor, sm_logger,
                                      args)
Ejemplo n.º 2
0
def main(args_str=None):
    global _zookeeper_client

    if not args_str:
        args_str = ' '.join(sys.argv[1:])
    args = parse_args(args_str)
    if args.cluster_id:
        client_pfx = args.cluster_id + '-'
        zk_path_pfx = args.cluster_id + '/'
    else:
        client_pfx = ''
        zk_path_pfx = ''

    # randomize collector list
    args.random_collectors = args.collectors
    if args.collectors:
        args.random_collectors = random.sample(args.collectors,
                                               len(args.collectors))

    # Initialize logger without introspect thread
    sm_logger = ServiceMonitorLogger(args, http_server_port=-1)

    # Initialize AMQP handler then close it to be sure remain queue of a
    # precedent run is cleaned
    try:
        vnc_amqp = VncAmqpHandle(sm_logger,
                                 DBBaseSM,
                                 REACTION_MAP,
                                 'svc_monitor',
                                 args=args)
        vnc_amqp.establish()
        vnc_amqp.close()
    except Exception:
        pass
    finally:
        sm_logger.debug("Removed remained AMQP queue")

    # Waiting to be elected as master node
    _zookeeper_client = ZookeeperClient(client_pfx + "svc-monitor",
                                        args.zk_server_ip)
    sm_logger.notice("Waiting to be elected as master...")
    _zookeeper_client.master_election(zk_path_pfx + "/svc-monitor",
                                      os.getpid(), run_svc_monitor, sm_logger,
                                      args)
Ejemplo n.º 3
0
def main(args_str=None):
    global _zookeeper_client

    if not args_str:
        args_str = ' '.join(sys.argv[1:])
    args = parse_args(args_str)
    if args.cluster_id:
        client_pfx = args.cluster_id + '-'
        zk_path_pfx = args.cluster_id + '/'
    else:
        client_pfx = ''
        zk_path_pfx = ''

    # randomize collector list
    args.random_collectors = args.collectors
    if args.collectors:
        args.random_collectors = random.sample(args.collectors,
                                               len(args.collectors))

    # Initialize logger without introspect thread
    sm_logger = ServiceMonitorLogger(args, http_server_port=-1)

    # Initialize AMQP handler then close it to be sure remain queue of a
    # precedent run is cleaned
    rabbitmq_cfg = get_rabbitmq_cfg(args)
    try:
        vnc_amqp = VncAmqpHandle(sm_logger._sandesh, sm_logger, DBBaseSM,
                                 REACTION_MAP, 'svc_monitor', rabbitmq_cfg,
                                 args.trace_file)
        vnc_amqp.establish()
        vnc_amqp.close()
    except Exception:
        pass
    finally:
        sm_logger.debug("Removed remained AMQP queue")

    # Waiting to be elected as master node
    _zookeeper_client = ZookeeperClient(
        client_pfx+"svc-monitor", args.zk_server_ip)
    sm_logger.notice("Waiting to be elected as master...")
    _zookeeper_client.master_election(zk_path_pfx+"/svc-monitor", os.getpid(),
                                      run_svc_monitor, sm_logger, args)