本文整理汇总了Python中utils.flare.Flare.collect方法的典型用法代码示例。如果您正苦于以下问题:Python Flare.collect方法的具体用法?Python Flare.collect怎么用?Python Flare.collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.flare.Flare
的用法示例。
在下文中一共展示了Flare.collect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: windows_flare
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import collect [as 别名]
def windows_flare():
case_id, ok = QInputDialog.getInteger(
None, "Flare",
"Your logs and configuration files are going to be collected and "
"sent to Datadog Support. Please enter your ticket number if you have one:",
value=0, min=0
)
if not ok:
info_popup("Flare cancelled")
return
case_id = int(case_id) if case_id != 0 else None
f = Flare(case_id=case_id)
f.collect()
email, ok = QInputDialog.getText(
None, "Your email",
"Logs and configuration files have been collected."
" Please enter your email address:"
)
if not ok:
info_popup("Flare cancelled. You can still use {0}".format(f.tar_path))
return
try:
case_id = f.upload(email=str(email))
info_popup("Your logs were successfully uploaded. For future reference,"
" your internal case id is {0}".format(case_id))
except Exception, e:
warning_popup('The upload failed. Please send the following file by email'
' to support: {0}\n\n{1}'.format(f.tar_path, str(e)))
示例2: main
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import collect [as 别名]
def main():
options, args = get_parsed_args()
agentConfig = get_config(options=options)
autorestart = agentConfig.get('autorestart', False)
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get('developer_mode')
COMMANDS_AGENT = [
'start',
'stop',
'restart',
'status',
'foreground',
]
COMMANDS_NO_AGENT = [
'info',
'check',
'configcheck',
'jmx',
'flare',
]
COMMANDS = COMMANDS_AGENT + COMMANDS_NO_AGENT
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
# TODO: actually kill the start/stop/restart/status command for 5.11
if command in ['start', 'stop', 'restart', 'status'] and not in_developer_mode:
logging.error('Please use supervisor to manage the agent')
return 1
if command in COMMANDS_AGENT:
agent = Agent(PidFile(PID_NAME, PID_DIR).get_path(), autorestart, in_developer_mode=in_developer_mode)
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 'status' == command:
agent.status()
elif 'info' == command:
return Agent.info(verbose=options.verbose)
elif 'foreground' == command:
log.info('Agent version %s' % get_version())
if autorestart:
# Set-up the supervisor callbacks and fork it.
logging.info('Running Agent with auto-restart ON')
def child_func():
agent.start(foreground=True)
def parent_func():
agent.start_event = False
AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.start(foreground=True)
elif 'check' == command:
if len(args) < 2:
sys.stderr.write(
"Usage: %s check <check_name> [check_rate]\n"
"Add check_rate as last argument to compute rates\n"
% sys.argv[0]
)
return 1
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, hostname)
for check in checks['initialized_checks']:
if check.name == check_name:
if in_developer_mode:
check.run = AgentProfiler.wrap_profiling(check.run)
cs = Collector.run_single_check(check, verbose=True)
#.........这里部分代码省略.........
示例3: main
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import collect [as 别名]
def main():
options, args = get_parsed_args()
agentConfig = get_config(options=options)
autorestart = agentConfig.get('autorestart', False)
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get('developer_mode')
COMMANDS_AGENT = [
'start',
'stop',
'restart',
'status',
'foreground',
]
COMMANDS_NO_AGENT = [
'info',
'check',
'configcheck',
'jmx',
'flare',
]
COMMANDS = COMMANDS_AGENT + COMMANDS_NO_AGENT
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
# Deprecation notice
if command not in DD_AGENT_COMMANDS:
# Will become an error message and exit after deprecation period
from utils.deprecations import deprecate_old_command_line_tools
deprecate_old_command_line_tools()
if command in COMMANDS_AGENT:
agent = Agent(PidFile('dd-agent').get_path(), autorestart, in_developer_mode=in_developer_mode)
if command in START_COMMANDS:
log.info('Agent version %s' % get_version())
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 'status' == command:
agent.status()
elif 'info' == command:
return Agent.info(verbose=options.verbose)
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.start(foreground=True)
def parent_func():
agent.start_event = False
AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.start(foreground=True)
elif 'check' == command:
if len(args) < 2:
sys.stderr.write(
"Usage: %s check <check_name> [check_rate]\n"
"Add check_rate as last argument to compute rates\n"
% sys.argv[0]
)
return 1
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, hostname)
for check in checks['initialized_checks']:
if check.name == check_name:
if in_developer_mode:
#.........这里部分代码省略.........
示例4: main
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import collect [as 别名]
def main():
options, args = get_parsed_args()
agentConfig = get_config(options=options)
autorestart = agentConfig.get("autorestart", False)
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get("developer_mode")
COMMANDS_AGENT = ["start", "stop", "restart", "status", "foreground"]
COMMANDS_NO_AGENT = ["info", "check", "configcheck", "jmx", "flare"]
COMMANDS = COMMANDS_AGENT + COMMANDS_NO_AGENT
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
# Deprecation notice
if command not in DD_AGENT_COMMANDS:
# Will become an error message and exit after deprecation period
from utils.deprecations import deprecate_old_command_line_tools
deprecate_old_command_line_tools()
if command in COMMANDS_AGENT:
agent = Agent(PidFile(PID_NAME, PID_DIR).get_path(), autorestart, in_developer_mode=in_developer_mode)
if command in START_COMMANDS:
log.info("Agent version %s" % get_version())
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 "status" == command:
agent.status()
elif "info" == command:
return Agent.info(verbose=options.verbose)
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.start(foreground=True)
def parent_func():
agent.start_event = False
AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.start(foreground=True)
elif "check" == command:
if len(args) < 2:
sys.stderr.write(
"Usage: %s check <check_name> [check_rate]\n"
"Add check_rate as last argument to compute rates\n" % sys.argv[0]
)
return 1
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, hostname)
for check in checks["initialized_checks"]:
if check.name == check_name:
if in_developer_mode:
check.run = AgentProfiler.wrap_profiling(check.run)
cs = Collector.run_single_check(check, verbose=True)
print CollectorStatus.render_check_status(cs)
if len(args) == 3 and args[2] == "check_rate":
print "Running 2nd iteration to capture rate metrics"
time.sleep(1)
cs = Collector.run_single_check(check, verbose=True)
print CollectorStatus.render_check_status(cs)
#.........这里部分代码省略.........
示例5: main
# 需要导入模块: from utils.flare import Flare [as 别名]
# 或者: from utils.flare.Flare import collect [as 别名]
def main():
options, args = get_parsed_args()
agentConfig = get_config(options=options)
autorestart = agentConfig.get("autorestart", False)
hostname = get_hostname(agentConfig)
COMMANDS = ["start", "stop", "restart", "foreground", "status", "info", "check", "configcheck", "jmx", "flare"]
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")
if options.clean:
pid_file.clean()
agent = Agent(pid_file.get_path(), autorestart)
if command in START_COMMANDS:
log.info("Agent version %s" % get_version())
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 "status" == command:
agent.status()
elif "info" == command:
return agent.info(verbose=options.verbose)
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.start(foreground=True)
def parent_func():
agent.start_event = False
AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.start(foreground=True)
elif "check" == command:
if len(args) < 2:
sys.stderr.write(
"Usage: %s check <check_name> [check_rate]\n"
"Add check_rate as last argument to compute rates\n" % sys.argv[0]
)
return 1
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, hostname)
for check in checks["initialized_checks"]:
if check.name == check_name:
check.run()
print check.get_metrics()
print check.get_events()
print check.get_service_checks()
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()
print check.get_service_checks()
check.stop()
elif "configcheck" == command or "configtest" == command:
configcheck()
elif "jmx" == command:
from jmxfetch import JMX_LIST_COMMANDS, JMXFetch
#.........这里部分代码省略.........