Skip to content
mperham edited this page Oct 17, 2014 · 5 revisions

Inspeqtor is opinionated software and tries to guide you to build better, more reliable applications. Because of this, I strongly recommend against using the legacy /etc/init.d system: no sane developer should need 100 line bash scripts and PID files to track and manage services.

I have documentation on Upstart and Systemd if you want to learn how to control your services with a more modern init system. However many people have legacy services still using init.d so Inspeqtor supports init.d-based services, reluctantly. For this we need a PID file.

PID Files, easy

If you have a service named apache2 in /etc/init.d and it exposes a PID file in /var/run/apache2.pid or /var/run/apache2/apache2.pid, then Inspeqtor will automatically find and monitor the process.

check service apache2
  if memory:rss > 500m then alert

PID Files, slightly less easy

Linux has a file system layout standard known as LSB. It states that all runtime information for a service, including PID files, should go in /var/run. Since Inspeqtor prefers convention over configuration, it only looks for PID files in /var/run. If you have a PID file elsewhere and don't want to adopt the Linux standard, the workaround is straightforward: soft links.

If you have a service named website in /etc/init.d and it exposes a PID file in /opt/website/shared/tmp/pids/unicorn.pid, just run this command:

ln -s /opt/website/shared/tmp/pids/unicorn.pid /var/run/website.pid

Note that /var/run/website/website.pid will also work, so you can give write permissions on the /var/run/website directory to a non-root user.

Your .inq file stays nice and clean:

check service website
  if memory:rss > 500m then alert

Caveats

If you want Inspeqtor to be able to restart your service, the init.d script must handle the restart verb, i.e. /etc/init.d/<service> restart.

Clone this wiki locally