5.1 Monitoring Service

The monitoring service, as its name suggests, monitors resource usage of the shepherd daemon. It does so by periodically logging information about key resources: heap size (memory usage), open file descriptors, and so on. It is a simple and useful way to check whether resource usage remains under control.

To use it, a simple configuration file that uses this service and nothing else would look like this:

(use-modules (shepherd service monitoring))

(register-services
  ;; Create a monitoring service that logs every 15 minutes.
  (list (monitoring-service #:period (* 15 60))))

;; Start it!
(start-service (lookup-service 'monitoring))

Using the herd command, you can get immediate resource usage logging:

$ herd log monitoring
service names: 3; heap: 8.77 MiB; file descriptors: 20

You can also change the logging period; for instance, here is how you’d change it to 30 minutes:

$ herd period monitoring 30

The (shepherd service monitoring) module exports the following bindings:

Procedure: monitoring-service [#:period (default-monitoring-period)]

Return a service that will monitor shepherd resource usage by printing it every period seconds.

Variable: default-monitoring-period

This parameter specifies the default monitoring period, in seconds.