Configuring Telegraf on a Synology Virtual Machine

As part of my Home Automation series, we configured a Grafana dashboard to display status and statistics about SmartThings devices, the local weather and more. A few months ago, I retired an 8+ year old Windows Server storage solution and replaced it with a new Synology DS1817+. I knew that I wanted to leverage Grafana to display health statistics about the Synology (disk temperatures, throughput, disk conditions, etc.)—something that I never took the time to setup for my Windows server. Thankfully, Synology’s DSM platform natively supports SNMP, and we can easily run Telegraf to monitor the SNMP data and log it in our previously created InfluxDB instance.

In my case, I’m visualizing the overall system status, condition of each of the 4 disks I currently have loaded in the 8-bay enclosure, CPU load, network throughput, overall system temperature, and the temperature of each of the 4 disks. This data is all being reported to a dedicated “synology” database in InfluxDB. The metrics I’m reporting represent a small subset of the data made available by Synology’s MIBs.

In short, SNMP (Simple Network Management Protocol) is a standardized protocol used for collecting and organizing information about devices on your network. A MIB is a database that contains the properties available to different types of devices. Enabling SNMP on a device allows that device to publish messages on the network, those messages can then be collected and understood by a collector (in our case Telegraf) that contains the appropriate MIB to understand the messages.

Enabling Synology SNMP

The first step is to enable SNMP on the Synology itself, as this is disabled by default. To do this, simply open the Synology Control Panel, navigate to the “Terminal & SNMP” pane, select the “SNMP” tab, and enable the SNMP service as well as SNMPv1 and SNMPv2c. Set the Community to “public”, which corresponds to the profile we’ll use when setting up Telegraf.

Where to Run Telegraf

In this example, Telegraf can really be run anywhere on the network. Prior to configuring it as a VM on the Synology itself, I ran it on my Windows 10 desktop machine as an easy way to configure the profiles and debug the configuration. Since SNMP messages are broadcast on the network, the collector just needs to be on the same network. The “convenience” that Telegraf is on a VM hosted on the Synology itself in my case is completely irrelevant. You could elect to run Telegraf on the InfluxDB server, on a Raspberry Pi, or any other machine on your network.

Creating a Synology Virtual Machine

Assuming you’ve installed the Synology Virtual Machine Manager, simply create a new virtual machine with a small amount of memory (I only allocated 512Mb), and install a Linux operating system (I’m running Ubuntu 18.04 Server), then download and install Telegraf.

Once Telegraf has been installed, install SNMP by running the following command:

sudo apt-get install snmp snmpd

Load the Synology MIBs into /usr/share/snmp/mibs (a download link to the Synology MIBs can be found inside the MIB documentation).

Finally, configure your telegraf.conf to use the InfluxDB output plugin and SNMP input plugin (setting relevant IPs on lines 69 and 98). Note that in my sample configuration I’m collecting a lot more data than the fields I mentioned in the intro, as I’ll likely add more to my dashboard over time. Copy your configuration to /etc/telegraf/telegraf.conf.

Run the following commands to enable the service:

sudo /bin/systemctl enable telegraf
sudo update-rc.d telegraf defaults

Start the service by running:

sudo service telegraf start

Ensure the service started by running:

sudo service telegraf status

And check the logs for any errors:

tail /var/logs/telegraf/synology.log

If everything looks good, reboot the server and check the service status to ensure it automatically started on boot.

Adding to the Dashboard

With Telegraf actively pushing your Synology metrics to InfluxDB, it’s just a matter of deciding what metrics you want to visualize and adding them to your dashboard.