Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telegraf init script hides syntax errors #1344

Closed
forsberg opened this issue Jun 7, 2016 · 3 comments
Closed

telegraf init script hides syntax errors #1344

forsberg opened this issue Jun 7, 2016 · 3 comments
Labels
area/packaging bug unexpected problem or unintended behavior
Milestone

Comments

@forsberg
Copy link

forsberg commented Jun 7, 2016

Bug report

System info:

telegraf 0.13.1 (debian package) on Debian wheezy.

Steps to reproduce:

  1. Introduce a syntax error in /etc/telegraf/telegraf.conf
  2. Start telegraf with /etc/init.d/telegraf start

Expected behavior:

Non-OK output from init script, with info on syntax error.

Actual behavior:

# /etc/init.d/telegraf start
Starting the process telegraf [ OK ]
telegraf process was started [ OK ]

Additional info:

Nothing useful in /var/log/telegraf/telegraf.log

Switching to telegraf user, starting daemon provides useful output (line number of syntax error)

@sparrc sparrc added bug unexpected problem or unintended behavior area/packaging labels Jun 7, 2016
@lifeofguenter
Copy link

This way I discovered that the generated config with contained the following line that does not seem to be supported:

write_consistency = "any"

Log:

root@debian:~# sudo -u telegraf bash -c '/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d'
Error parsing /etc/telegraf/telegraf.conf, line 22: field corresponding to `write_consistency' is not defined in `*influxdb.InfluxDB'

@YerisAntonio
Copy link

Thanks

@sparrc
Copy link
Contributor

sparrc commented Sep 9, 2016

from #1740:

Bug report

Relevant telegraf.conf:

Specifically broken:

[[outputs.influxdb]]
  database = "telegraf"
  interval = "1s"

System info:

telegraf 1.0.0 on CentOS 6.

Steps to reproduce:

Break the config with an invalid param. Attempt to start the service using the Red Hat LSB init script.

Expected behavior:

I should be told the service failed to start (the binary does return a non zero exit code it just gets lost in all the Bash / Su / nohup in there). At the very least I should see the config parser error in the log file.

Actual behavior:

The service starts but dies immediately, but it tells me it started ok. No error message in the log because the init script sends STDOUT to /dev/null.

Actual error message is this:

[root@server ~]# /usr/bin/telegraf -pidfile /var/run/telegraf/telegraf.pid -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
Error parsing /etc/telegraf/telegraf.conf, line 24: field corresponding to `interval' is not defined in `*influxdb.InfluxDB'

Proposal:

Quick fix would be to just not bury STDOUT, so you can at least see error in the log. More robust ways of handling this would be to introduce a config parser option, so you could test the config file validity first before you tried to spawn the real instance.

Another way might be to use the Red Hat daemon() function in /etc/rc.d/init.d/functions, but then you don't have a cross platform init script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/packaging bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants