Netdata: Install on Synology?

Yes you can install Netdata on your Synology as long as its AMD architecture, so no ARM!

Download Install Script

I have a DS1621+ which is AMD architecture so the static binary will be the one to be installed: 64-bit static installer

Change to non-root (Optional)

When Netdata is first installed, it will run as root. This may or may not be acceptable for you, and since other installations run it as the netdata user, you might wish to do the same. This requires some extra work:

  1. Create a group netdata via the Synology group interface. Give it no access to anything.
  2. Create a user netdata via the Synology user interface. Give it no access to anything and a random password. Assign the user to the netdata group. Netdata will chuid to this user when running.
  3. Change ownership of the following directories, as defined in Netdata Security:
root@Diskstation:~# chown -R root:netdata /opt/netdata/usr/share/netdata 
root@Diskstation:~# chown -R netdata:netdata /opt/netdata/var/lib/netdata\ /opt/netdata/var/cache/netdata
root@Diskstation:~# chown -R netdata:root /opt/netdata/var/log/netdata

Modify the netdata.conf file

After installing make sure and disable mdstat otherwise you will get alarms since Synology doesn’t use it. Edit the netdata.conf file and change the “# /proc/mdstat = yes” line to “/proc/mdstat = no” and restart netdata.

root@Diskstation:~# /opt/netdata/netdata-configs/edit-config netdata.conf
...
# /sys/class/infiniband = yes 
# /proc/net/stat/conntrack = yes 
# /proc/net/stat/synproxy = yes 
# /proc/diskstats = yes
 /proc/mdstat = no
# /proc/net/rpc/nfsd = yes
# /proc/net/rpc/nfs = yes
# /proc/spl/kstat/zfs/arcstats = yes
# /sys/fs/btrfs = yes
# ipc = yes
# /sys/class/power_supply = yes
...
root@Diskstation:~# /etc/rc.netdata restart 
(You can ignore the error below)
Shutting down Netdata.
 Waiting maximum of 30 seconds for netdata to exit.
 /etc/rc.netdata: line 20: [: 31484: binary operator expected
 Starting Netdata.
 2021-02-16 17:32:51: netdata INFO  : MAIN : SIGNAL: Not enabling reaper

Create startup script#

Additionally, as of 2018/06/24, the Netdata installer doesn’t recognize DSM as an operating system, so no init script is installed. You’ll have to do this manually:

  1. Create/etc/rc.netdata. Make it executable with chmod 0755 /etc/rc.netdata.
!/bin/bash
 Install this as /etc/rc.netdata and call it from /etc/rc.local
 to have it executed on boot.
 NETDATA_DIR=/opt/netdata
 DAEMON=$NETDATA_DIR/bin/srv/netdata
 TIMEOUT=30  # seconds to wait for netdata to exit
 [ -x $DAEMON ] || exit 0
 function get_pid() {
         pid=$( ps ax | grep $DAEMON | grep -v grep | awk '{ print $1 }' )
 }
 function check_netdata() {
         count=1
         while [ $count -lt $TIMEOUT ]; do
                 get_pid
                 if [ -z $pid ]; then
                         break
                 else
                         sleep 1
                         count=$(( $count + 1))
                 fi
         done
     if [ $count -eq $TIMEOUT ]; then             echo "Timeout exceeded waiting for netdata to exit."             echo "Use '$0 kill' to force netdata to exit."             exit 1     fi
 }
 function stop_netdata() {
         get_pid
         if [ "x$pid" != "x" ]; then
                 if [ "x$1" = "xforce" ]; then
                         kill -9 $pid
                 else
                         kill $pid
                 fi
         else
                 echo "No running netdata found."
         fi
 }
 function start_netdata() {
         get_pid
         if [ "x$pid" = "x" ]; then
                 echo "Starting Netdata."
                 $DAEMON
         else
                 echo "Netdata already running with pid $pid"
         fi
 }
 case "$1" in
     start)
                 start_netdata
     ;;
     stop)
                 echo "Shutting down Netdata."
                 stop_netdata
     ;;
         restart)
                 echo "Shutting down Netdata."
                 stop_netdata
                 if [ "x$pid" != "x" ]; then
                         echo "Waiting maximum of $TIMEOUT seconds for netdata to exit."
                 fi
                 check_netdata
                 start_netdata
         ;;
         kill)
                 echo "Killing netdata."
                 stop_netdata force
         ;;
         status)
                 get_pid
                 if [ "x$pid" != "x" ]; then
                         echo "Netdata running with PID $pid"
                 else
                         echo "No running netdata found."
                 fi
         ;;
     *)
         echo "Usage: $0 {start|stop|kill|restart|status}"
         exit 1
 esac
 exit 0
  1. Add or edit /etc/rc.local and add a line calling /etc/rc.netdata to have it start on boot:
# Netdata startup
[ -x /etc/rc.netdata ] && /etc/rc.netdata startCopy
  1. Make sure /etc/rc.netdata is executable: chmod 0755 /etc/rc.netdata.

Add to Netdata Cloud

  1. Login to your Netdata Cloud space: https://app.netdata.cloud/sign-in?cloudRoute=/spaces
  2. Once there you can click on your War Room in my case its called LabServers and at the top left click on LabServers and select Add Nodes:
  1. You will get a window pane to your right that will have the command with the unique token to claim the node.
  2. Login to your Synology
    1. copy and paste the command from the browser
andy@Diskstation:~$
andy@Diskstation:~$ cd /opt/netdata/bin
andy@Diskstation:~$ sudo netdata-claim.sh -token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1111111111112222222222223333333333333 -rooms=1234567-12345-0000-xxxx-12345678910 -url=https://app.netdata.cloud
  1. If everything went okay you will see your new node
  2. Click on the top LabServers for example and look for Nodes and click on that
  1. After you click on Nodes you will get an overview screen of everything within that War Room. You can drill down by click on the node name i.e. Diskstation ion this example, you will notice mdstat to the right twill be missing. If it isn’t then it will show no data. Eventually it will cycle out and you wont see it. That is per the prior step of removing data gathering for that service.
  2. Thats it, have fun!

Resources