Skip to content

Commit

Permalink
Merge pull request #417 from DataDog/agent-diagnostic
Browse files Browse the repository at this point in the history
add command line option to run a particular agent check
  • Loading branch information
clofresh committed Mar 29, 2013
2 parents 5106b20 + a59d809 commit 666691d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def main():
'foreground',
'status',
'info',
'check',
]

if len(args) < 1:
Expand All @@ -194,7 +195,7 @@ def main():
pid_file = PidFile('dd-agent')

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

if options.clean:
pid_file.clean()
Expand Down Expand Up @@ -226,6 +227,21 @@ def parent_func(): agent.start_event = False
# 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()

# Commands that don't need the agent to be initialized.
else:
if 'status' == command:
Expand Down

0 comments on commit 666691d

Please sign in to comment.