Beispiel #1
0
    def flare(cls, config, case_id):
        email = input('Please enter your contact email address: ').lower()
        case_id = int(case_id) if case_id else None
        myflare = Flare(version=AGENT_VERSION, case_id=case_id, email=email)
        myflare.add_path(config.get('conf_path'))
        myflare.add_path(config.get_loaded_config())
        myflare.add_path(config.get('logging').get('agent_log_file'))
        myflare.add_path(config.get('logging').get('dogstatsd_log_file'))
        myflare.add_path(config.get('additional_checksd'))

        flarepath = myflare.create_archive(
            status=cls.status(config, to_screen=False))

        print('The flare is going to be uploaded to Datadog')
        choice = input('Do you want to continue [Y/n]? ')
        if choice.strip().lower() not in ['yes', 'y', '']:
            print('Aborting (you can still use {0})'.format(flarepath))
            sys.exit(0)

        success, case_id = myflare.submit()
        if success:
            if case_id:
                print(
                    'Your flare was uploaded successfully, this is your case id: {}'
                    .format(case_id))
            else:
                print(
                    'Your flare was uploaded successfully, but a case id could not be retrieved.'
                )

            myflare.cleanup()
Beispiel #2
0
def init_config(do_log=True):
    # init default search path
    config.add_search_path("/etc/datadog-agent")
    config.add_search_path(os.path.join(DEFAULT_PATH, "etc/datadog-agent"))
    config.add_search_path("./etc/datadog-agent")
    config.add_search_path(".")
    try:
        config.load()
    except Exception:
        if do_log:
            initialize_logging('agent')
        raise

    # init log
    if do_log:
        initialize_logging('agent')

    # add file provider
    file_provider = FileConfigProvider()
    file_provider.add_place(
        os.path.join(os.path.dirname(config.get_loaded_config()), 'conf.d'))
    file_provider.add_place(os.path.join(config.get('conf_path'), 'conf.d'))
    file_provider.add_place(config.get('additional_checksd'))
    config.add_provider('file', file_provider)

    # FIXME: perhaps do this elsewhere
    config.collect_check_configs()
    def flare(cls, case_id):
        email = input('Please enter your contact email address: ').lower()
        case_id = int(case_id) if case_id else None
        myflare = Flare(case_id=case_id, email=email)
        myflare.add_path(config.get('conf_path'))
        myflare.add_path(config.get_loaded_config())
        myflare.add_path(config.get('logging').get('agent_log_file'))
        myflare.add_path(config.get('logging').get('dogstatsd_log_file'))
        myflare.add_path(config.get('additional_checksd'))

        flarepath = myflare.create_archive()

        print('The flare is going to be uploaded to Datadog')
        choice = input('Do you want to continue [Y/n]? ')
        if choice.strip().lower() not in ['yes', 'y', '']:
            print('Aborting (you can still use {0})'.format(flarepath))
            sys.exit(0)

        if myflare.submit():
            myflare.cleanup()