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

Is there any way to point a pid file for telegraf so that process could be easily find and kill in cluster? #2566

Closed
visionarywind opened this issue Mar 24, 2017 · 2 comments

Comments

@visionarywind
Copy link

visionarywind commented Mar 24, 2017

This may be a stupid question. But if there is a way to find process accurately, it would be a big convenience.

@danielnelson
Copy link
Contributor

Are you asking if telegraf can create its own pidfile? We don't do that in telegraf itself but the initscript does manage one.

We try to reserve GitHub Issues for actionable bug reports or feature requests. Please ask general questions at the InfluxData Community site.

@kaspergrubbe
Copy link

So if anyone else has been on the same goosechase as me I will now save you the time.

Telegraf actually seems to support specifying a pidfile.

Not that -h will list it:

/usr/local/sbin/telegraf -h
Telegraf, The plugin-driven server agent for collecting and reporting metrics.

Usage:

  telegraf [commands|flags]

The commands & flags are:

  config              print out full sample configuration to stdout
  version             print the version to stdout

  --config <file>     configuration file to load
  --test              gather metrics once, print them to stdout, and exit
  --config-directory  directory containing additional *.conf files
  --input-filter      filter the input plugins to enable, separator is :
  --output-filter     filter the output plugins to enable, separator is :
  --usage             print usage for a plugin, ie, 'telegraf --usage mysql'
  --debug             print metrics as they're generated to stdout
  --pprof-addr        pprof address to listen on, format: localhost:6060 or :6060
  --quiet             run in quiet mode

But if you look closer, this init script is utilising it:

su -s /bin/sh -c "nohup $daemon -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR &" $USER

And it seems to be parsed in here:

var fPidfile = flag.String("pidfile", "", "file to write our pid to")

And when I launch Telegraf with -pidfile /home/deploy/test.pid I can see that it actually does work:

~ $ cat /home/deploy/test.pid
26628

And it even cleans up after itself, after Telegraf is killed:

~ $ cat /home/deploy/test.pid
cat: /home/deploy/test.pid: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants