Skip to content

Commit

Permalink
Running configcheck when starting the agent
Browse files Browse the repository at this point in the history
Fix #838
  • Loading branch information
remh committed Mar 6, 2014
1 parent c6dd162 commit d71cf96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,17 @@ def parent_func(): agent.start_event = False
check_yaml(conf_path)
except Exception, e:
all_valid = False
print "%s contains errors:\n%s\n" % (basename, e)
print "%s contains errors:\n %s" % (basename, e)
else:
print "%s is valid\n" % basename
print "%s is valid" % basename
if all_valid:
print "All yaml files passed. You can now run the Datadog agent."
return 0
else:
print("Fix the invalid yaml files above in order to start the Datadog agent. "
"A useful external tool for yaml parsing can be found at "
"http://yaml-online-parser.appspot.com/")
return 1

elif 'jmx' == command:
from jmxfetch import JMX_LIST_COMMANDS, JMXFetch
Expand Down
6 changes: 6 additions & 0 deletions packaging/datadog-agent-base-rpm/datadog-agent-redhat
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ start() {
exit 3
fi

su $AGENTUSER -c "$AGENTPATH configcheck" > /dev/null
if [ $? -ne 0 ]; then
echo -n "Invalid check configuration. Please run sudo /etc/init.d/datadog-agent configtest for more details."
echo -n "Resuming starting process."
fi

if [ -f $USE_SUPERVISOR ]; then
# no need to test for status before daemon,
# the daemon function does the right thing
Expand Down
6 changes: 6 additions & 0 deletions packaging/datadog-agent-deb/datadog-agent.init
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ case "$1" in
exit 0
fi

su $AGENTUSER -c "$AGENTPATH configcheck" > /dev/null
if [ $? -ne 0 ]; then
log_daemon_msg "Invalid check configuration. Please run sudo /etc/init.d/datadog-agent configtest for more details."
log_daemon_msg "Resuming starting process."
fi


log_daemon_msg "Starting $DESC (using supervisord)" "$NAME"
start-stop-daemon --start --quiet --oknodo --exec $SUPERVISORD -- -c $SUPERVISOR_FILE --pidfile $SUPERVISOR_PIDFILE
Expand Down

0 comments on commit d71cf96

Please sign in to comment.