Missing PID file
astik opened this issue · 4 comments
Hi,
Using debian to work with ES, Kibana and beat. Using this ansible role to deploy metricbeat works fine, still, i'm missing the PID file creation, nothing is created in /var/run, no PID file. I'm no linux expert, so i may be missing something =/
Here is the command line that starts the process :
/usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /var/lib/metricbeat -path.logs/var/log/metricbeat
The file that define service is /etc/init.d/metricbeat and contains :
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Metricbeat is a lightweight shipper for metrics."
NAME="metricbeat"
DAEMON=/usr/share/${NAME}/bin/${NAME}
DAEMON_ARGS="-c /etc/${NAME}/${NAME}.yml -path.home /usr/share/${NAME} -path.config /etc/${NAME} -path.data /var/lib/${NAME} -path.logs /var/log/${NAME}"
TEST_ARGS="-e test config"
PIDFILE=/var/run/metricbeat.pid
WRAPPER="/usr/share/${NAME}/bin/${NAME}-god"
BEAT_USER="root"
WRAPPER_ARGS="-r / -n -p $PIDFILE"
SCRIPTNAME=/etc/init.d/metricbeat
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start \
--pidfile $PIDFILE \
--exec $WRAPPER -- $WRAPPER_ARGS -- $DAEMON $DAEMON_ARGS \
|| return 2
}
Here is my inventory :
beats:
metricbeat:
beat_conf:
setup.dashboards.enabled: true
metricbeat.modules:
- module: system
metricsets:
- cpu
- load
- filesystem
- fsstat
- memory
- network
- process
enabled: true
period: 10s
processes:
- ".*"
and here is my role definition :
- hosts: servers
roles:
- role: ansible-beats
beat: metricbeat
beat_conf: "{{ beats.metricbeat.beat_conf }}"
I can add the systemd unit file (/lib/systemd/system/metricbeat.service):
[Unit]
Description=Metricbeat is a lightweight shipper for metrics.
Documentation=https://www.elastic.co/products/beats/metricbeat
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /var/lib/metricbeat -path.logs /var/log/metricbeat
Restart=always
[Install]
WantedBy=multi-user.target
No PID file is defined there
Hi @astik,
Sorry for the very late answer.
Systemd doesn't need to write pidfiles to manage services, when running systemctl status metricbeat
, you can see that systemd does know the pid without needing /var/run/metricbeat.pid
$ systemctl status metricbeat
● metricbeat.service - Metricbeat is a lightweight shipper for metrics.
Loaded: loaded (/usr/lib/systemd/system/metricbeat.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-07-10 09:02:28 UTC; 2min 45s ago
Docs: https://www.elastic.co/products/beats/metricbeat
Main PID: 9705 (metricbeat)
CGroup: /system.slice/metricbeat.service
└─9705 /usr/share/metricbeat/bin/metricbeat -e -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /v...
You can find a more detailed thread on this topic in Elastic forum: https://discuss.elastic.co/t/pid-file-not-found-on-ubuntu-16-04/64921
I'm closing the issue, don't hesitate to reopen it if you have any question.
Thanks @jmlrt for the explanation.
I was hoping to use PID file in order to monitor with Monit :
check process metricbeat with pidfile /var/run/metricbeat.pid
...
but it seems that i can do it through process name :
check process metricbeat matching "metricbeat"
...
Your link on the elastic forum is exactly what i needed =)