joshuar / pingbeat

DEPRECATED. Pingbeat sends ICMP packets and stores the RTT in Elasticsearch or other outputs supported by libbeat.
Apache License 2.0
55 stars 19 forks source link

PID file #13

Closed captainark closed 7 years ago

captainark commented 8 years ago

Hi,

I use Monit to monitor daemons running on my systems. It needs a PID file to be able to check whether a process is running or not.

Could you please provide an option to generate a PID file when pingbeat starts ?

Thanks.

joshuar commented 8 years ago

Hi @captainark thanks for reporting! Yes, I need to make better use of the beats-packer tooling the Beats team uses for releases and also fix small things like this.

I believe as a workaround, Monit can track services using the process name IIRC. That might be a workaround while I get this sorted.

captainark commented 8 years ago

Hi @joshuar !

Thanks for taking the time to reply !

I didn't know that monit doesn't need PID files anymore... I guess I hadn't read the manual in a while.

I've added the following in my /etc/systemd/system/pingbeat.service unit file to generate a PID file :

ExecStartPre=/bin/bash -c "/bin/rm -f /run/pingbeat.pid"
ExecStartPost=/bin/bash -c "/usr/bin/pgrep -fx '/opt/go/bin/pingbeat -c /etc/pingbeat/pingbeat.yml' > /run/pingbeat.pid"
ExecStopPost=/bin/bash -c "[[ -f /run/pingbeat.pid ]] && /bin/rm /run/pingbeat.pid"

I'm still looking forward to seeing pingbeat generate a PID file on its own though ;)

mbadran commented 8 years ago

The latest update includes a systemd service file. I copied it to /etc/systemd/system/, updated the path in ExecStart, and it just worked with systemctl.

$ systemctl status pingbeat
● pingbeat.service - Pingbeat
   Loaded: loaded (/etc/systemd/system/pingbeat.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2016-07-08 21:23:40 AEST; 38min ago
 Main PID: 3572 (pingbeat)
   CGroup: /system.slice/pingbeat.service
           └─3572 /opt/go/bin/pingbeat -c /etc/pingbeat/pingbeat.yml

Jul 08 21:23:40 pingbeat.local systemd[1]: Started Pingbeat.
Jul 08 21:23:40 pingbeat.local systemd[1]: Starting Pingbeat...
joshuar commented 7 years ago

Closing as the systemd file should be working now?