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

PID file is not created using systemd collectd service #1946

Closed
lukasmrtvy opened this issue Sep 19, 2016 · 4 comments
Closed

PID file is not created using systemd collectd service #1946

lukasmrtvy opened this issue Sep 19, 2016 · 4 comments

Comments

@lukasmrtvy
Copy link

  • Version of collectd: 5.6.0
  • Operating system / distribution: Ubuntu 16.04

Expected behavior

Pid file is created using -P /tmp/collectd.pid as argument

Actual behavior

Run manually creates PID in /tmp
sudo /opt/collectd/sbin/collectd -P /tmp/collectd.pid

Run trough systemd does not create PID
/lib/systemd/system/collectd.service

[Unit]
Description=Statistics collection and monitoring daemon
After=local-fs.target network.target
Requires=local-fs.target network.target
ConditionPathExists=/etc/collectd/collectd.conf
Documentation=man:collectd(1)
Documentation=man:collectd.conf(5)
Documentation=https://collectd.org

[Service]
Type=notify
NotifyAccess=main
EnvironmentFile=-/etc/default/collectd
ExecStartPre=/opt/collectd/sbin/collectd -t
ExecStart=/opt/collectd/sbin/collectd -P /tmp/collectd.pid
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
@rubenk
Copy link
Contributor

rubenk commented Sep 19, 2016

Why do you need a pid file when you're running under systemd?

@lukasmrtvy
Copy link
Author

lukasmrtvy commented Sep 19, 2016

There are many other applications that use the pid file.
For example for monitoring.
I know I can grep process id and compare it with /proc/pid/status, but there is -P argument option, so why it does not use.

@rubenk
Copy link
Contributor

rubenk commented Sep 19, 2016

This is by design. Collectd doesn't write the pid file if systemd monitors the process with Type=notify. If you need to get the process status you need to use the systemd tools (systemctl status) or apis. If you really want to keep using pid files and the associated racy behaviour, use Type=forking.

@rubenk rubenk closed this as completed Sep 19, 2016
@bigHosting
Copy link

bigHosting commented Jan 22, 2018

I know this is closed however I am running into issues because pid is not created. on CentOS 6 I use monit to monitor for pid files, but in CentOS 7 there is no pid file. My Ansible playbook looks at the distribution major release number and based on that, monitors the path to pid file. This works fine for auditd, chronyd, crond .... I am migrating to CentOS 7 however older CentOS 6 has to be still supported.

collectd:
pid:
6: '/var/run/collectdmon.pid'
7: '????'
start_script:
6: '/sbin/service collectd start'
7: '/usr/bin/systemctl collectd httpd.service'

stop_script:
6: '/sbin/service collectd stop'
7: '/usr/bin/systemctl stop collectd.service'

Thanks

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

No branches or pull requests

4 participants