Skip to main content

Command Palette

Search for a command to run...

Monitoring Systemd Service Using Monit

Updated
1 min read
Monitoring Systemd Service Using Monit
H

I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)

Monit is an easy-to-use software for monitoring servers. It does not require any agent and runs locally within the server. The ability to use custom scripts makes it versatile for monitoring any services/resources.

Monit uses control files to define how each service/resource is monitored. This a sample control file for monitoring Systemd service.

check program php-fpm with path "/usr/bin/systemctl --quiet is-active php-fpm.service"
    if status != 0 then alert
    if status != 0 then exec "/usr/bin/systemctl start php-fpm.service"

This is especially useful for monitoring custom-defined Systemd services.

More from this blog

Hong's Tech Blog

110 posts

The blog is older than you know. I prefer counting from the emergence of one integral anomaly to the emergence of the next, in which case this is the forth version.