当前位置: 首页>>代码示例>>Python>>正文


Python CollectorStatus.print_latest_status方法代码示例

本文整理汇总了Python中checks.check_status.CollectorStatus.print_latest_status方法的典型用法代码示例。如果您正苦于以下问题:Python CollectorStatus.print_latest_status方法的具体用法?Python CollectorStatus.print_latest_status怎么用?Python CollectorStatus.print_latest_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在checks.check_status.CollectorStatus的用法示例。


在下文中一共展示了CollectorStatus.print_latest_status方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _info_all

# 需要导入模块: from checks.check_status import CollectorStatus [as 别名]
# 或者: from checks.check_status.CollectorStatus import print_latest_status [as 别名]
 def _info_all(self):
     CollectorStatus.print_latest_status(verbose=True)
     DogstatsdStatus.print_latest_status(verbose=True)
     ForwarderStatus.print_latest_status(verbose=True)
开发者ID:AquaBindi,项目名称:dd-agent,代码行数:6,代码来源:flare.py

示例2: info

# 需要导入模块: from checks.check_status import CollectorStatus [as 别名]
# 或者: from checks.check_status.CollectorStatus import print_latest_status [as 别名]
 def info(self, verbose=None):
     logging.getLogger().setLevel(logging.ERROR)
     return CollectorStatus.print_latest_status(verbose=verbose)
开发者ID:AirbornePorcine,项目名称:dd-agent,代码行数:5,代码来源:agent.py

示例3: main

# 需要导入模块: from checks.check_status import CollectorStatus [as 别名]
# 或者: from checks.check_status.CollectorStatus import print_latest_status [as 别名]
def main():
    options, args = get_parsed_args()
    agentConfig = get_config(options=options)
    autorestart = agentConfig.get('autorestart', False)

    COMMANDS = [
        'start',
        'stop',
        'restart',
        'foreground',
        'status',
        'info',
    ]

    if len(args) < 1:
        sys.stderr.write("Usage: %s %s\n" % (sys.argv[0], "|".join(COMMANDS)))
        return 2

    command = args[0]
    if command not in COMMANDS:
        sys.stderr.write("Unknown command: %s\n" % command)
        return 3

    pid_file = PidFile('dd-agent')

    # Only initialize the Agent if we're starting or stopping it.
    if command in ['start', 'stop', 'restart', 'foreground']:

        if options.clean:
            pid_file.clean()

        agent = Agent(pid_file.get_path(), autorestart)

        if 'start' == command:
            log.info('Start daemon')
            agent.start()

        elif 'stop' == command:
            log.info('Stop daemon')
            agent.stop()

        elif 'restart' == command:
            log.info('Restart daemon')
            agent.restart()

        elif 'foreground' == command:
            logging.info('Running in foreground')

            if autorestart:
                # Set-up the supervisor callbacks and fork it.
                logging.info('Running Agent with auto-restart ON')
                def child_func(): agent.run()
                def parent_func(): agent.start_event = False
                AgentSupervisor.start(parent_func, child_func)
            else:
                # Run in the standard foreground.
                agent.run(config=agentConfig)

    # Commands that don't need the agent to be initialized.
    else:
        if 'status' == command:
            pid = pid_file.get_pid()
            if pid is not None:
                sys.stdout.write('dd-agent is running as pid %s.\n' % pid)
                log.info("dd-agent is running as pid %s." % pid)
            else:
                sys.stdout.write('dd-agent is not running.\n')
                log.info("dd-agent is not running.")

        elif 'info' == command:
            logging.getLogger().setLevel(logging.ERROR)
            return CollectorStatus.print_latest_status(verbose=options.verbose)

    return 0
开发者ID:CaptTofu,项目名称:dd-agent,代码行数:76,代码来源:agent.py

示例4: main

# 需要导入模块: from checks.check_status import CollectorStatus [as 别名]
# 或者: from checks.check_status.CollectorStatus import print_latest_status [as 别名]
def main():
    options, args = get_parsed_args()
    agentConfig = get_config()

    # Logging
    setup_logging(agentConfig)


    COMMANDS = [
        'start',
        'stop',
        'restart',
        'foreground',
        'status',
        'info',
    ]

    if len(args) < 1:
        sys.stderr.write("Usage: %s %s\n" % (sys.argv[0], "|".join(COMMANDS)))
        return 2

    command = args[0]

    if command not in COMMANDS:
        sys.stderr.write("Unknown command: %s\n" % command)
        return 3

    pid_file = PidFile('dd-agent')
 
    # Only initialize the Agent if we're starting or stopping it.
    if command in ['start', 'stop', 'restart', 'foreground']:

        if options.clean:
            pid_file.clean()

        agent = Agent(pid_file.get_path())

        if 'start' == command:
            logging.info('Start daemon')
            agent.start()

        elif 'stop' == command:
            logging.info('Stop daemon')
            agent.stop()

        elif 'restart' == command:
            logging.info('Restart daemon')
            agent.restart()

        elif 'foreground' == command:
            logging.info('Running in foreground')
            agent.run()

    # Commands that don't need the agent to be initialized.
    else:
        if 'status' == command:
            pid = pid_file.get_pid()
            if pid is not None:
                sys.stdout.write('dd-agent is running as pid %s.\n' % pid)
            else:
                sys.stdout.write('dd-agent is not running.\n')

        elif 'info' == command:
            return CollectorStatus.print_latest_status()

    return 0
开发者ID:ovesh,项目名称:dd-agent,代码行数:68,代码来源:agent.py

示例5: main

# 需要导入模块: from checks.check_status import CollectorStatus [as 别名]
# 或者: from checks.check_status.CollectorStatus import print_latest_status [as 别名]
def main():
    options, args = get_parsed_args()
    agentConfig = get_config(options=options)
    autorestart = agentConfig.get('autorestart', False)

    COMMANDS = [
        'start',
        'stop',
        'restart',
        'foreground',
        'status',
        'info',
        'check',
    ]

    if len(args) < 1:
        sys.stderr.write("Usage: %s %s\n" % (sys.argv[0], "|".join(COMMANDS)))
        return 2

    command = args[0]
    if command not in COMMANDS:
        sys.stderr.write("Unknown command: %s\n" % command)
        return 3

    pid_file = PidFile('dd-agent')

    # Only initialize the Agent if we're starting or stopping it.
    if command in ['start', 'stop', 'restart', 'foreground', 'check']:

        if options.clean:
            pid_file.clean()

        agent = Agent(pid_file.get_path(), autorestart)

        if 'start' == command:
            log.info('Start daemon')
            agent.start()

        elif 'stop' == command:
            log.info('Stop daemon')
            agent.stop()

        elif 'restart' == command:
            log.info('Restart daemon')
            agent.restart()

        elif 'foreground' == command:
            logging.info('Running in foreground')

            if autorestart:
                # Set-up the supervisor callbacks and fork it.
                logging.info('Running Agent with auto-restart ON')
                def child_func(): agent.run()
                def parent_func(): agent.start_event = False
                AgentSupervisor.start(parent_func, child_func)
            else:
                # Run in the standard foreground.
                agent.run(config=agentConfig)

        elif 'check' == command:
            check_name = args[1]
            try:
                import checks.collector
                # Try the old-style check first
                print getattr(checks.collector, check_name)(log).check(agentConfig)
            except Exception:
                # If not an old-style check, try checks.d
                checks = load_check_directory(agentConfig)
                for check in checks:
                    if check.name == check_name:
                        check.run()
                        print check.get_metrics()
                        print check.get_events()
                        if len(args) == 3 and args[2] == 'check_rate':
                            print "Running 2nd iteration to capture rate metrics"
                            time.sleep(1)
                            check.run()
                        print check.get_metrics()
                        print check.get_events()


    # Commands that don't need the agent to be initialized.
    else:
        if 'status' == command:
            pid = pid_file.get_pid()
            if pid is not None:
                sys.stdout.write('dd-agent is running as pid %s.\n' % pid)
                log.info("dd-agent is running as pid %s." % pid)
            else:
                sys.stdout.write('dd-agent is not running.\n')
                log.info("dd-agent is not running.")

        elif 'info' == command:
            logging.getLogger().setLevel(logging.ERROR)
            return CollectorStatus.print_latest_status(verbose=options.verbose)

    return 0
开发者ID:dwradcliffe,项目名称:dd-agent,代码行数:99,代码来源:agent.py


注:本文中的checks.check_status.CollectorStatus.print_latest_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。