Saturday, 11 July 2015

Synology NAS monitoring with Synagios using SNMP

After installing Synagios, using the instructions on the Nagrestconf Web site, you will find that a whole bunch of things on the Diskstation are monitored and graphed, but these are not Synology specific.

In this blog post I will show how to add a new Nagios plugin to monitor things that are specific to Synology devices and we will get the plugin from A little Linux command line knowledge would be useful, but not much is required.

The nagios plugin we add can then be used to monitor other Synology devices and the method shown here can be used for adding any other Nagios plugins that use SNMP polling.

Getting Ready

This tutorial assumes that Synagios has been set up as described in the instructions on the Nagrestconf Web site, so it has the extra service templates etc.

We'll need two programs to configure Synagios: a Web Browser, to use the nagrestconf and nagios interfaces, and a terminal. Open these now, as shown next, so we can switch between them as necessary.

Start a Terminal Session to the Diskstation

Log into your diskstation using Putty or ssh then use the 'chroot' command to enter into the nagios chroot as shown next:
chroot /volume1/@appstore/Synagios/nagios-chroot/ /bin/bash
I'll call this the synagios chroot from this point on.

Note that anything you do here, after typing the 'chroot' command, will be inside the Synagios chroot, so you won't break your Synology NAS. Take a backup using the Nagrestconf GUI before starting and if things go terribly wrong just log out by typing 'exit', twice, then uninstall Synagios and then reinstall it.

Open Nagrestconf and Nagios3

Using a Web Browser, preferably Firefox, Safari, or Chrome, open the following links, changing 'diskstation' for the name or IP address of your diskstation.
I'll refer to this as the Nagrestconf GUI from now on, and,
,which I will refer to as the Nagios GUI.

Plugin Locations

In the synagios chroot, in the file '/etc/nagios3/resource.cfg', there are two nagios macros, $USER1$ and $USER5$, which hold the locations of the nagios plugins and are used in the 'Commands' tab in the nagrestconf GUI.

Take a look in the Nagrestconf GUI now and click the 'Commands' tab to see them. Look for $USER1$ and $USER5$ in that page to see how they have been used.

The two Nagios macros are defined in resource.cfg as:
$USER1$ is where the official nagios plugins are and $USER5$ is where extra plugins are kept.

When we get the new plugin we will put it in $USER5$.

Get the New Plugin

Lots of nagios plugins are available at I searched for 'synology' at the Web site and I'm going to try the 'Synology status' plugin.

NOTE: Looking at the comments for the 'Synology status' plugin you'll see that some people have problems with it so it might not work for you. It works for me, but it fails when my system is doing a Timed Backup to another Synology device. This is at 2am, when alerting is off anyway, so this plugin is fine for me.

In this case I can download this plugin from the Web site straight from the synagios chroot using 'curl'.

Switch to the synagios chroot and type (or paste):
mkdir ~/tmp

cd ~/tmp

curl -o check_snmp_synology ''
The first line makes a 'tmp' directory in the home directory; '~' means home, which will be '/root' in this case.
The second line switches us to that directory.
The third line gets the file from the Web site and names it 'check_snmp_synology' using the '-o' option.

You can view the first few lines of the file by typing 'head check_snmp_synology' to verify you got the right file, for example:
root@DiskStation:~/tmp# head check_snmp_synology
# check_snmp_synology for nagios version 2.2
# 16.04.2015  Nicolas Ordonez, Switzerland
# this plugin checks the health of your Synology NAS
# - System status (Power, Fans)
# - Disks status
# - RAID status
# - DSM update status
# - Te
mperature Warning and Critical
So, we have the new plugin. Let's test it.

Testing the plugin

We can test that the plugin works by running it in the synagios chroot before setting it up properly.

First we'll make it runnable with:
chmod +x check_snmp_synology
Then run it to see the options:
It should show a few options. Let's try it with options:
./check_snmp_synology -2 public -h
This did not work for me as SNMP was not enabled on my diskstation, so it failed with:
 CRITICAL - Problem with SNMP request, check user/password/host
I logged into my diskstation DSM using the Web Browser and opened the control panel, then searched for 'snmp' and opened 'Terminal and SNMP'. I then enabled 'SNMPv1, SNMPv2c service'.

Trying './check_snmp_synology -2 public -h' again worked the second time.

If you don't get the plugin working then don't continue with the rest of this tutorial!

So, now that the nagios plugin works from the command line, lets use it.

Adding the Plugin to Synagios

First we will move the Nagios plugin we downloaded to the $USER5$ directory:
mv ~/tmp/check_snmp_synology /usr/local/nagios/plugins/
Next we add a new command using the Nagrestconf GUI:
  1. Switch to the Nagrestconf GUI.
  2. Click the 'Commands' tab.
  3. Click the 'Add new command' icon at the top right of the table.
  4. For 'Command name' enter 'check_snmp_synology'.
  5. For 'Command' enter '$USER5$/check_snmp_synology $ARG1$'.
  6. Click 'Create Command'.

This command can now be used in other tabs. It can be added to service sets or directly to hosts. For speed we'll add it directly to the host:
  1. Click the 'Hosts' tab.
  2. Click on 'diskstation' to see the list of all checks for that host.
  3. Click the 'Add new service' icon at the top right of the inner table.
  4. Choose the Service Template 'svctmpl-lin'.
  5. For 'Command' enter 'check_snmp_synology!-2 public -h'.
  6. For 'Description' enter 'Synology'.
  7. Leave the other fields blank and click 'Create Service'.

Now apply this new configuration:
  1. At the top left of the screen, click the 'Apply Changes' button.
  2. Click 'Apply Configuration'.
The plugin is now added and the new 'Synology' check will appear in the Nagios GUI. Log into the Nagios GUI to check the status.


Errors in the Nagios GUI:

(Return code of 126 is out of bounds - plugin may not be executable)
  •  The plugin is not executable. The 'chmod +x' step was not done, as shown above.
(Return code of 127 is out of bounds - plugin may be missing)
  • The plugin was copied to the wrong place, or,
  • The Command in the Nagrestconf GUI was misspelt, or,
  • Then Command in the Nagrestconf GUI uses the wrong USER variable

Monitoring another Synology NAS

I have another synology NAS that I will try monitoring using the one I just set up. I will only use the check_snmp_synology plugin installed above.

First I need to enable SNMP on the other NAS using the Diskstation DSM as above.

In the Nagrestconf GUI I'll add a host, diskstation2:
  1. Click the 'Hosts' tab.
  2. Click the 'Add new host' icon at the top right of the main table.
  3. For 'Host name' and 'Alias' enter 'diskstation2'.
  4. For 'IP Address' enter the IP address.
  5. Click 'Create Host'.
Add the check_snmp_synology service as done before, but this time for diskstation2 and with a different IP address (using a nagios macro):
  1. Click the 'Hosts' tab.
  2. Click on 'diskstation2' to see the list of all checks for that host.
  3. Click the 'Add new service' icon at the top right of the inner table.
  4. Choose the Service Template 'svctmpl-lin'.
  5. For 'Command' enter 'check_snmp_synology!-2 public -h $HOSTADDRESS$'.
  6. For 'Description' enter 'Synology'.
  7. Leave the other fields blank and click 'Create Service'.
Now apply this new configuration:
  1. At the top left of the screen, click the 'Apply Changes' button.
  2. Click 'Apply Configuration'.
The new NAS, diskstation2, will appear in the Nagios GUI with a single check. Log into the Nagios GUI to check the status.


If you have a few Synology NAS devices to monitor then you might want to add the check_snmp_synology service check to a Service Set. Then, when adding a new host, you only need to specify the Service Set and the check will be added automatically. Adding new hosts could be done in the Nagrestconf GUI, one by one, by using Bulk Tools and supplying a comma delimited file, or by using REST commands in a script.

You may have noticed that I used the command 'check_snmp_synology!-2 public -h' the first time then 'check_snmp_synology!-2 public -h $HOSTADDRESS$' the second time. The latter command, with '$HOSTADDRESS$', could have been used for both commands instead.


  1. This comment has been removed by a blog administrator.

  2. Long Description Riskonnect is the trusted, preferred source of Integrated Risk Management technology, offering a growing suite of solutions on a world-class cloud computing model that enable clients to elevate their programs for management of all risks across the enterprise. Riskonnect allows organizations to holistically understand, manage and control risks, positively affecting shareholder value OSHA compliance solution