Synology DSM monitoring with Monit

Monit is small, monit is fast, monit is installed on each of my servers. Unfortunately, I couldn’t found a package for Synology DSM 6. Hopefully, DSM is based on Linux and Monit provides binaries. So let’s install, run and monitor DSM using Monit.

Install Monit

It is possible to install and configure Monit using SSH and a shell console. But… DSM is Web 2.0 and I wanted to do the things using the Web GUI only.

Go to the Monit download section and grab Monit for linux-x64.

Using File Station, upload the tarball to the directory you like and uncompress the archive. Rename the directory as you like.

Guess what, it’s done!

Configure Monit

Inside the “conf” directory, you’ll find the “monitrc” configuration file. Read the comments and configure as usual.

The most tricky part is to guess the real pathname for the directory where you installed monit. Look inside the Shared Folder dialog box to guess that path. In my case, I installed the “monit” directory in the “apps” shared folder on the “Volume 1” location. This gives the following full pathname: “/volume1/apps/monit”.

Make sure Monit is running

The simplest way to check if monit is running and, if not, to start it is to use the native “Task Scheduler”, from the “Control Panel”.

In the monit/bin directory, using the “Text Editor”, I wrote a small shell script, named check_monit.sh:

#!/bin/bash
#
# Check if Monit runs.
# If not, starts it
#

MONIT_DIR="/volume1/apps/monit"
MONIT_BIN="$MONIT_DIR/bin/monit"
MONIT_PID="$MONIT_DIR/monit.pid"
MONIT_CONF="$MONIT_DIR/conf/monitrc"

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"

if [ -f "$MONIT_PID" ]; then
 PID=$(cat $MONIT_PID)
else
 PID=""
fi

FOUND=$(ps -aef | awk '{ print $2 }' | grep "^$PID$")

# If Monit wasn't found, set various permissions and start it. Else, just quit.
if [ -z "$FOUND" ]; then
 chmod 0600 "$MONIT_CONF"
 chmod 0755 "$MONIT_BIN"
 exec "$MONIT_BIN" -c "$MONIT_CONF"
fi

exit 0

Then I used the Task Scheduler to run this check every 5 minutes.

In the end, I ended with a classic Monit view of my Synology services.

Author: Joel Carnat

Technical Architect and SysAdmin @work ; OpenBSD and FOSS @home ; Karate, Kobudō, Jōdō, Bodyweight workout, Photography @hobby

6 thoughts on “Synology DSM monitoring with Monit”

  1. Hi, would you PLEASE make it so your blog does not limit the number of search results you display? You have some great posts … but … at the moment reading through them demands CLICKING THROUGH EVERY SINGLE ITEM in the “Archives” drop-down box.

  2. could you please also share the monit configuration part for checking the services. It could spare a lot of time not having to find out yourselves what pids/hosts/processes to monitor. That’s always the most time consuming part with monit. So if you’ve done that already would be great to have a template for it.

    1. Here are my rules:

      check process FileStation matching "var/packages/FileStation"
          if not exists for 5 cycles then alert
      	if not exists for 10 cycles then unmonitor
      
      #check process CloudStation matching "var/packages/CloudStation"
      check process SynologyDrive matching "var/packages/SynologyDrive"
          if not exists for 5 cycles then alert
      	if not exists for 10 cycles then unmonitor
      
      check process SynoFinder matching "var/packages/SynoFinder"
          if not exists for 5 cycles then alert
      	if not exists for 10 cycles then unmonitor
      
      check process Virtualization matching "var/packages/Virtualization"
          if not exists for 5 cycles then alert
      	if not exists for 10 cycles then unmonitor
      

      In my case, the more time-consuming process was to have it running on the Syno, not really configuring it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.