Monitor Synology DiskStation NAS (DS211J / DS415+) using SNMP and Nagios or Naemon Core

Why not add enterprise class monitoring of your Synology DiskStation NAS using Nagios or Naemon Core and the standard plugins packages included in most distributions or available in community repositories to simply get good control over your precious data?

This will help anyone who wants to set up the most important things to keep control of your data without the need for deep knowledge of SNMP to do so. However basic editing skills and basic knowledge of Linux as well as know how to configure Nagios is as must as this article won’t cover those steps.

All checks has been verified for DS211J and DS415+ and for the latter i needed to change disk integers a bit to get all the disks monitored.

The SNMP plugin used for most monitoring is check_snmp and available forΒ most distributions “nagios-plugins / monitoring-plugins” andΒ the plugin for monitoring interfaces is developed by op5 and available in the git repositories (needs to be compiled)

This will help you monitor:

  • CPU Usage
  • CPU Fan Status
  • Disk 1 & 2 Status (My NAS only has two drives)
  • Disk 1 & 2 Temperature
  • Memory Usage
  • Power Status (Maybe too much as my NAS only has one power supply and if it breaks.. well, i’ll know!)
  • Raid Status
  • Swap Usage
  • System Fan Status
  • System Status
  • Network card(s) / Interfaces

 

So first we’ll define the commands to use, check_snmp is the plugin of choice here so add the following to your checkcommands.cfg (or nagios-plugins conf.d directory)

 

define command{
command_name check_synology_disk_temperature
 command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.2.1.1.6.$ARG2$ -l "Temperature" -u C -w $ARG3$ -c $ARG4$
 }
define command{
 command_name check_snmp_process
 command_line $USER1$/check_snmp_process -H $HOSTADDRESS$ -C $ARG1$ -n "$ARG2$" -F
 }
define command{
command_name check_synology_cpu
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -o .1.3.6.1.4.1.9.2.1.58.0 -w $ARG1$ -c $ARG2$ -C$ARG3$ -u % -l "CPU load is" -m:
}
define command{
command_name check_synology_disk_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.2.1.1.5.$ARG2$ -l "Diskstatus" -s 1
}
define command{
command_name check_synology_raid_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.3.1.1.3.$ARG2$ -l "Raid status" -s 1
}
define command{
command_name check_synology_system_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.1.1.0 -l "System status" -s 1
}
define command{
command_name check_synology_power_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.1.3.0 -l "Power status" -s 1
}
define command{
command_name check_synology_fan_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.1.4.1.0 -l "System fan status" -s 1
}
define command{
command_name check_synology_cpufan_status
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P 1 -C $ARG1$ -o .1.3.6.1.4.1.6574.1.4.2.0 -l "CPU fan status" -s 1
}
define command{
command_name    snmp_cpu_all
command_line    $USER1$/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o .1.3.6.1.4.1.2021.11.9.0,.1.3.6.1.4.1.2021.11.10.0,.1.3.6.1.4.1.2021.11.11.0 -w :'$ARG2$',:'$ARG3$',:'$ARG4$' -c :'$ARG5$',:'$ARG6$',:'$ARG7$' -l user,system,idle -u%,%,%
}
define command{
command_name    snmp_mem
command_line    $USER1$/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o .1.3.6.1.4.1.2021.4.6.0,.1.3.6.1.4.1.2021.4.5.0 -w '$ARG2$': -c '$ARG3$': -l available,total -u kb,kb
}
define command{
command_name    snmp_swap
command_line    $USER1$/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o .1.3.6.1.4.1.2021.4.4.0,.1.3.6.1.4.1.2021.4.3.0 -w '$ARG2$': -c '$ARG3$': -l free,total -u kb,kb
}

 

These commands uses the op5-plugin (info above)

define command{
 command_name check_traffic
 command_line $USER1$/check_snmpif traffic -H $HOSTADDRESS$ -C $ARG1$ -i $ARG2$ -b $ARG3$ -w $ARG4$ -c $ARG5$
 }
define command{
 command_name check_iferrors
 command_line $USER1$/check_snmpif errors -H $HOSTADDRESS$ -C $ARG1$ -i $ARG2$ -w $ARG3$ -c $ARG4$ -t 10
 }
define command{
 command_name check_ifoperstatus
 command_line $USER1$/check_snmpif status -H $HOSTADDRESS$ -C $ARG1$ -v 1 -k $ARG2$
 }

And when this is done, add the services to your configuration:

define service{
use generic-service; name of service template to use
host_name diskstation
service_description if 2: eth0 errors
check_command check_iferrors!public!2!1.5!2.5
}
define service{
use generic-service ; name of service template to use
host_name diskstation
service_description if 2: eth0 status
check_command check_ifoperstatus!public!2
}
define service{
use generic-service ; name of service template to use
host_name diskstation
service_description if 2: eth0 traffic
check_command check_traffic!public!2!1000mbit!70!90
}
define service{ 
use generic-service ; name of service template to use 
host_name diskstation 
service_description cpu usage 
check_command snmp_cpu_all!public!75!75!100!90!90!100
}
define service{
use generic-service ; name of service template to use
host_name diskstation
service_description memory usage
check_command snmp_mem!public!8000!4000
}
define service{
use generic-service ; name of service template to use
host_name diskstation
service_description swap usage
check_command snmp_swap!public!1202498!800000
}
define service{
use generic-service ; name of service template to use
host_name diskstation
service_description ping
check_command check_ping!20,40%!100,60%
}
define service{
use generic-service
host_name diskstation
service_description system status
check_command check_synology_system_status!public
}
define service{
use generic-service
host_name diskstation
service_description power status
check_command check_synology_power_status!public
}
define service{
use generic-service
host_name diskstation
service_description system fan status
check_command check_synology_fan_status!public
}
define service{
use generic-service
host_name diskstation
service_description cpu fan status
check_command check_synology_cpufan_status!public
}
define service{
use generic-service
host_name diskstation
service_description disk 1 temperature
check_command check_synology_disk_temperature!public!0!45!50
}
define service{
use generic-service
host_name diskstation
service_description disk 2 temperature
check_command check_synology_disk_temperature!public!1!45!50
}
define service{
use generic-service
host_name diskstation
service_description disk 1 status
check_command check_synology_disk_status!public!0
}
define service{
use generic-service
host_name diskstation
service_description disk 2 status
check_command check_synology_disk_status!public!1
}
define service{
use generic-service
host_name diskstation
service_description raid status
check_command check_synology_raid_status!public!0
}

This is pretty much it!

Here’s a screenshot with this config running:

Synology-Nagios-Screenshot

/Christian

20 thoughts on “Monitor Synology DiskStation NAS (DS211J / DS415+) using SNMP and Nagios or Naemon Core”

  1. Ahh thanks, your a life saver!
    Btw: you should change the last 3 cmd entrys from $USER1$ to /usr/lib/nagios/plugins so it woks out of the box πŸ˜€

    1. Rasmus, you’re right shoud be $USER1$ and i’ve updated the post now! Thanks! Those commands are originally from debian packages and for some reason they have hardcoded paths instead of user defined macros in the check commands but i forgot to correct them πŸ™‚

      /Christian

  2. Thank you! Worked great on a DS213. Fedora 19 setup was slightly different – Added commands to /etc/nagios/objects/commands.cfg and then defined ‘diskstation’ as a host in network.cfg and added the services in the same network.cfg file. (Nagios 3.5.1).

  3. Hi, i use the DS213j. I think all commands are right in my nagios config, but exept the ping command i have no answer in nagios. what i must configurate in the nas ? I activated snmp v1 and the community is the ip of my nagios server. i hope you have a solution for me. Thanks

  4. Sorry for digging this post. But can you describe how you manage the if status/errors/traffic. Thanks.

  5. Thank you so much for this article πŸ™‚
    Can you please also describe how to configure the network card ? Would be great πŸ˜‰

      1. Thanks again for your reply πŸ™‚
        I keep you updated if it works for me, but do you have the check_snmpif plugin somewhere else ? Unfortunately the link you provided doesn’t work πŸ™

        1. Sorry, was the git-url so you needed to use git to clone the code using that one. Corrected it now with the web-based url so you should be able to download the repo from there (or use git if you like, all options are open). Good luck!

          1. It really works great so far. I had a lot of work to install net-snmp and compile check_snmpif, but now it is done πŸ˜‰
            I only have 2 warning for eth0 errors and traffic: Failed to create directory for /opt/monitor/var/snmpif/errors/if2@xxx.xxx.xxx.xxx.errors: Permission deniedWARNING: Failed to stash current data in /opt/monitor/var/snmpif/errors/if2@xxx.xxx.xxx.xxx.errors: Permission denied.
            Do you have an idea where I have to change what on the NAS ?
            And again, thanks for your great help πŸ˜€ πŸ˜€

  6. Right, didn’t remember the path was hardcoded in the plugin… so you have two options, create the directory (on the monitoring side) and give the Naemon/nagios user rw permissions or patch the code and use another directory for the cache-files and recompile.. (directory you know the user has rw rights for).

    Also, as long snmp is running as i should on the NAS nothing needs to be changed there so its on the monitoring side giving you the error when the plugin are going to write the cache file for calculating traffic etc. πŸ™‚

    1. Great, I changed the directory and recompiled the plugin and now it works πŸ™‚
      Thanks again for your great support for me !

  7. Hi
    I’am new to OP5 and need some help to this setup , can someone get a hint to get started, like a how to πŸ™‚

    I manage to get oid value with check_SNMP but thats it…

    1. If you are using op5 Monitor free version and want to monitor Synology NAS devices there’s a management pack you can download and import. Then just use the host wizard to add all the checks in “two clicks”. All needed plugins are already pre-packaged so it’s just a matter of downloading the management pack from here: https://kb.op5.com/x/LwJH
      Good luck! πŸ™‚

Leave a Reply

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