Monitor Synology disk temperature from SNMP

I’m always looking at how to get informations from my I.T. systems ; although it often ends they do nothing…

Here’s a trick to monitor the disks temperature of a Synology NAS (DS409slim in my case).

Enable monitoring on the Synology

First of all, we’ll need the smartmontools. If you don’t already have it, install it using ipkg:

# ipkg install smartmontools # which smartctl /usr/syno/bin/smartctl

Once done, let’s try to find the devices:

# smartctl --scan /dev/hda -d ata # /dev/hda, ATA device /dev/hdb -d ata # /dev/hdb, ATA device /dev/hdc -d ata # /dev/hdc, ATA device /dev/hdd -d ata # /dev/hdd, ATA device (...) /dev/sda -d scsi # /dev/sda, SCSI device /dev/sdb -d scsi # /dev/sdb, SCSI device /dev/sdc -d scsi # /dev/sdc, SCSI device /dev/sdd -d scsi # /dev/sdd, SCSI device (...)

I don’t know why it lists both ATA and SCSI disks… Maybe because I have SATA disks… Anyway, let’s see if the disk answers to information requests:

# smartctl -a /dev/hda -d ata | egrep "Model|Temp" Model Family: Toshiba 2.5" HDD MK..59GSM (Adv. Format) Device Model: TOSHIBA MK1059GSM 194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 32 (Min/Max 20/46)

So we can get the information from every of the disks installed.

Now, let’s extend the SNMP daemon so that it prints disks temperature when polled:

# vi /usr/syno/etc/snmpd.conf (...) #extend disktemp /opt/bin/bash -c "/opt/bin/find /dev/sd[a-z] -exec /usr/syno/bin/smartctl -iA -d ata {} \\; | /opt/bin/awk ' /Serial Number:/ { printf \"%s: \", \$NF }; /Temperature_Celsius/ { print \$10 }; ' | /opt/bin/sed -e \"s/[-_]//g\"" # /usr/syno/etc/rc.d/S08snmpd.sh restart

From a remote machine, we can now get the results:

# snmpget -v 2c -c public syno 'NET-SNMP-EXTEND-MIB::nsExtendResult."disktemp"' NET-SNMP-EXTEND-MIB::nsExtendResult."disktemp" = INTEGER: 0 # snmpwalk -v 2c -c public syno 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp"' NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".1 = STRING: Y0DHF8LPS: 31 NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".2 = STRING: Y0DHF8KTS: 30 NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".3 = STRING: 90L3P2GFT: 31 NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp".4 = STRING: WDWXN209NC0986: 35

That’s it! The information can now be grabbed, stored and graphed from you preferred monitoring tools.

What you see is what you get

Here’re two examples of what I achieved using both “Munin” and “Xymon”. It only requires writing the scripts that will poll the snmp daemon and put the values into the correct format.

You can probably do the same with Nagios, Cacti, … but I don’t use those.

Improving response time

If you’ve had a detailed look at the graphs, you may have noticed that there are holes in the graphs. This is (AFAIK) because the snmpd of the syno answers in between 1.7 and 3 seconds. When it takes too long to answer, Munin and Xymon seem to not write the data in their RRDs.

Therefor, I have modified the way the data are published. From the synology:

# touch /tmp/disktemp.log # cat /usr/syno/etc/snmpd.conf (...) extend disktemp /opt/bin/cat /tmp/disktemp.log # /usr/syno/etc/rc.d/S08snmpd.sh restart # cat /etc/crontab (...) */5 * * * * root ( /opt/bin/find /dev/sd[a-d] -exec /usr/syno/bin/smartctl -iA -d ata {} \; | /opt/bin/awk ' /Serial Number:/ { printf "%s: ", $NF }; /Temperature_Celsius/ { print $10 }; ' | /opt/bin/sed -e "s/[-_]//g" ) > /tmp/disktemp.log # /usr/syno/etc/rc.d/S04crond.sh stop stop crond # /usr/syno/etc/rc.d/S04crond.sh start Starting crond...

Here’s the time response comparison:

snmpd only snmpd and crontab real 0m2.387s 0m0.012s user 0m0.008s 0m0.008s sys 0m0.004s 0m0.004s

So far, I get no holes anymore. If the poll was to be done faster, one may change the crontab to generate the file oftener.

Source

Initial idea was stolen from there: Monitoring de la température des “disk” de Nexenta en SNMP

Unfortunately, my virtual Nexenta with Raw Device Mapping can get the SMART informations :-/

w00t!

8 Comments

  • Ramon Tue, 01 May 2012 13:42:47 +0000 Reply

    This looks exactly what I need but I am not able to execute your scripts. Can you explain what you are doing? I do not have /opt/bin/awk, /opt/bin/sed /opt/bin/find, etc. which ipkg packages do I need to install to get these?

    • Joel Carnat Wed, 02 May 2012 10:50:04 +0000 Reply Author

      ipkg is installed this way: http://goo.gl/sQtNB
      to find which packages provides which utility, I usually go `ipkg list | grep what_im_lookin_for`.
      having a look at my installed package, I think you’ll need : smartmontools, findutils, gawk, and sed.

  • Diego d’Ambra Tue, 10 Jul 2012 17:10:55 +0000 Reply

    If you’re not into SSH and editing files then perhaps are more simple solution is to use a small package for Synology that I’ve created. The package will extend the build-in SNMP solution to include more detailed information about the health of disks and volumes.
    For more info and download of package see here:
    https://panorama9.zendesk.com/entries/21677572-monitor-synology-storage-devices-snmp-add-on

  • Marcin Sun, 02 Sep 2012 21:54:05 +0000 Reply

    Wher I’m using command from ash:
    /opt/bin/bash -c “/usr/bin/find /dev/sd[a-z] -exec /usr/syno/bin/smartctl -iA -d ata {} \\; | /usr/bin/awk ‘ /Serial Number:/ { printf \”%s: \”, \$NF }; /Temperature_Celsius/ { print \$10 }; ‘ | /bin/sed -e \”s/[-_]//g\””

    is OK. But when I’m trying to execute snmpwalk from remote host I’m getting :NET-SNMP-EXTEND-MIB::nsExtendNumEntries.0 = INTEGER: 1
    NET-SNMP-EXTEND-MIB::nsExtendCommand.”disktemp” = STRING: /opt/bin/bash
    NET-SNMP-EXTEND-MIB::nsExtendArgs.”disktemp” = STRING: -c “/usr/bin/find /dev/sd[a-z] -exec /usr/syno/bin/smartctl -iA -d ata {} \\; |
    NET-SNMP-EXTEND-MIB::nsExtendInput.”disktemp” = STRING:
    NET-SNMP-EXTEND-MIB::nsExtendCacheTime.”disktemp” = INTEGER: 5
    NET-SNMP-EXTEND-MIB::nsExtendExecType.”disktemp” = INTEGER: exec(1)
    NET-SNMP-EXTEND-MIB::nsExtendRunType.”disktemp” = INTEGER: run-on-read(1)
    NET-SNMP-EXTEND-MIB::nsExtendStorage.”disktemp” = INTEGER: permanent(4)
    NET-SNMP-EXTEND-MIB::nsExtendStatus.”disktemp” = INTEGER: active(1)
    NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.”disktemp” = STRING: /opt/bin/bash: -c: line 1: syntax error: unexpected end of file
    NET-SNMP-EXTEND-MIB::nsExtendOutputFull.”disktemp” = STRING: /opt/bin/bash: -c: line 1: syntax error: unexpected end of file
    NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.”disktemp” = INTEGER: 1
    NET-SNMP-EXTEND-MIB::nsExtendResult.”disktemp” = INTEGER: 2
    NET-SNMP-EXTEND-MIB::nsExtendOutLine.”disktemp”.1 = STRING: /opt/bin/bash: -c: line 1: syntax error: unexpected end of file

    SNMP configuration is as you worte in article, but path to find, sed and awk are corrected . My system is : GNU/Linux synology_ppc853x_210+

    Could you give me a some hints, please?

    • Joel Carnat Fri, 07 Sep 2012 10:00:47 +0000 Reply Author

      Well, the syntax error is probably a ‘, ” or \ that is parsed differently from shell and from snmpd.
      Could also be carriage return in the snmpd.conf

      Have a look at the #3 “Improving response time” section. More than improving the response time, you only have to copy/paste shell command from shell to cron. Which makes very easy maintenance.

  • Marcin Sat, 08 Sep 2012 18:34:31 +0000 Reply

    Hi Joel,
    I found that Synology discs are supportind entarprice mib 1.3.6.1.4.1.6574. where are OIDs for system health, RAID and discs. So, temperature monitoring vis smartmontools is no longer needed 🙂 Please look here http://www.synology.com/support/snmp_mib.php

    BR and thanks.

  • A.Liechti Wed, 14 Nov 2012 20:38:37 +0000 Reply

    Hi,

    As you are apparently using XyMon, I’m sure you will be interested by SynoMon, my XyMon native client on Synology 😉

    http://developer.sysco.ch/hobbit/SynoMon-noarch-100.spk

    Regards,

    André

  • A.Liechti Sun, 16 Dec 2012 09:51:19 +0000 Reply

    Hello, I have added some more functionalities, like UPS information handling and an optional local CSV storage. Define an alternative package source as http://synology.sysco.ch/, or surf directly on the page to have more information.

    Regards,

    André

Leave a Reply

%d bloggers like this: