HowTo: monitor Synology NAS

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Erwinvos72
Posts: 61
Joined: Thursday 25 February 2016 16:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Erwinvos72 »

I have the same problem as Duduf. After an upgrade of my synology the temperuture is gone. the script is still working (updated every x minutes) but something happened with the upgrade what caused it to receive 0

The solution of Ray worked! Thnx Ray

Anyone else having this problem, I have found the "solution"
The script uses snmpget which runs fine manually, and used to run fine in the cron too. Some update (I guess Synology DSM) caused the cron to run the script correctly, but gave 0C numbers in return.

Changing the script replacing all snmpget to snmpwalk did the trick, both manually and in cron it works again.
I have to thank Martijn85 above, as he made me aware of this in his correction of the script, where I finally sportted the use of snmpwalk instead snmpget.

Cheers,

Ray
Erwinvos72
Posts: 61
Joined: Thursday 25 February 2016 16:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Erwinvos72 »

Hello Alwin,

Does this part solves the problem with the 1024 issue? Untill now i haven't got succes in displaying the free mem for example.

I have domoticz on my Synology 916+, can read the temperature but the other parts aren't working.


AlwinHummels wrote:I had the same isue but when I use .54 it works again om my DS 415+ with the last DSM 6.1.15047
Hope it helps

Beneath code I grabbed from the Dutch Synology Forum becouse the memory usage was wrong displayed.

Code: Select all

	       # Free Memory Used in %
       tmpMemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
	   MemAvailable=${tmpMemAvailable%% *}
       tmpMemtotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
	   Memtotal=${tmpMemtotal%% *}
       tmpMemShared=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.13.0`
	   MemShared=${tmpMemShared%% *}
       tmpMemBuffer=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.14.0`
	   MemBuffer=${tmpMemBuffer%% *}
       tmpMemCached=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.15.0`
	   MemCached=${tmpMemCached%% *}
       MemFREE=$(($MemAvailable + $MemShared + $MemBuffer + $MemCached))
       MemUsepercent=$(((($Memtotal - $MemFREE) * 100) / $Memtotal)) 
	   #// For Available use MemUsepercent=$(((($MemFREE) * 100) / $Memtotal))	   
       # Send data
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: HowTo: monitor Synology NAS

Post by deennoo »

LouiS22 wrote:I also have problems with this script with my DS416Play with latest firmware. The script partially works, I can get the HDD temp values, but no space used and cpu info. I've tried with .38 and .41 - it's just not working :(
same as me on my ds216play
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
lamouette
Posts: 37
Joined: Friday 20 January 2017 8:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: HowTo: monitor Synology NAS

Post by lamouette »

Running XPenology on a HPN54L with DSM 5.2

I have installed pearl and panorama9 packages https://support.panorama9.com/hc/en-us/ ... MP-add-on-

Then I can retrieve directly the available space by the following:

snmpwalk -v2c -c SNMPCOMMUNITY -O qv NASIP 1.3.6.1.4.1.8072.1.3.2.3.1.2.2.112.57 | grep free | cut -d , -f 5 | cut -d : -f 2 | cut -c 2-

Result to be divided by 1048576 to see it in Go
benj29
Posts: 16
Joined: Sunday 22 January 2017 15:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by benj29 »

Hi,

I've tried to monitor my 415play from Domoticz... 4 temperature sensors instead of 2.
In DSM6, i've changed OID to .41 and i've created the sensors but...

Image

taking code from wiki... https://www.domoticz.com/wiki/NAS_Monitoring

It's working for 4 temperature and OK/KO activity sensor :

Image

But error on the other sensors ... maybe i made a mistake on the code or on the sensor declaration ?
(i've tried custom sensor instead of the picture ... same issue).

Image
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by rjblake »

Here is the code I use for monitoring my DS1813+ running DSM 6.1-15047 Update 1. I do not have a disk installed in Bay7, so not monitored, but the rest are all working.


Code: Select all

#!/bin/bash
 
 # Settings
 
 NASIP="192.168.178.10"      # NAS IP Address
 PASSWORD="community"        # SNMP Password
 DOMO_IP="192.168.178.10"    # Domoticz IP Address
 DOMO_PORT="8084"            # Domoticz Port
 NAS_IDX="50"                # NAS Switch IDX
 NAS_HD1_TEMP_IDX="51"       # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="52"       # NAS HD1 Temp IDX
 NAS_HD3_TEMP_IDX="53"       # NAS HD2 Temp IDX
 NAS_HD4_TEMP_IDX="54"       # NAS HD1 Temp IDX
 NAS_HD5_TEMP_IDX="55"       # NAS HD1 Temp IDX
 NAS_HD6_TEMP_IDX="56"       # NAS HD1 Temp IDX
 NAS_HD7_TEMP_IDX="57"       # NAS HD1 Temp IDX
 NAS_HD8_TEMP_IDX="58"       # NAS HD1 Temp IDX
 NAS_HD_SPACE_IDX="64"       # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="63"  # NAS HD Space IDX in %
 NAS_CPU_IDX="59"            # NAS CPU IDX
 NAS_MEM_IDX="60"            # NAS MEM IDX
 NAS_CPU_TEMP="62"		   # NAS CPU Temperature
 
 
 # Check if NAS in online 
 
 PINGTIME=`ping -c 1 -q $NASIP | awk -F"/" '{print $5}' | xargs`
 
 echo $PINGTIME
 if expr "$PINGTIME" '>' 0
 then
   curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "On" > /dev/null
 
       if [ $? -eq 0 ] ; then
        echo "NAS already ON"
 
        # Temperature CPU
        CPUtemp=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_TEMP&nvalue=0&svalue=$CPUtemp"
 
        # Temperature HD1
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
        # Temperature HD2
        HDtemp2=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"

        # Temperature HD3
        HDtemp3=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.2`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD3_TEMP_IDX&nvalue=0&svalue=$HDtemp3"

        # Temperature HD4
        HDtemp4=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.3`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD4_TEMP_IDX&nvalue=0&svalue=$HDtemp4"

        # Temperature HD5
        HDtemp5=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.4`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD5_TEMP_IDX&nvalue=0&svalue=$HDtemp5"

        # Temperature HD6
        HDtemp6=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.5`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD6_TEMP_IDX&nvalue=0&svalue=$HDtemp6"

        # Temperature HD7
        HDtemp7=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.6`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD7_TEMP_IDX&nvalue=0&svalue=$HDtemp7"

        # Temperature HD8
        # HDtemp8=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.7`
        # Send data
        # curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD8_TEMP_IDX&nvalue=0&svalue=$HDtemp8"

        # Free space volume in Go
        HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.4.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.5.52` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.6.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
 
        # Free space volume in percent
        HDTotal=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.52` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDFreePerc=$((($HDUsed * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
 
	    # CPU utilisation
        CpuUser=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	    CpuSystem=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.10.0`
	    CpuUse=$(($CpuUser + $CpuSystem))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
 
        # Free Memory Available in %
	    MemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.4.1.2021.4.6.0`
        MemAvailableinMo=$(($MemAvailable / 1024))
	    MemUsepercent=$((($MemAvailableinMo * 100) / 1024))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
 
else
        echo "NAS ON"
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=On"

        # Temperature CPU
        CPUtemp=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_TEMP&nvalue=0&svalue=$CPUtemp"
  
        # Temperature HD1
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
        # Temperature HD2
        HDtemp2=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
 
        # Temperature HD3
        HDtemp3=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.2`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp3"

        # Temperature HD4
        HDtemp4=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.3`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp4"

        # Temperature HD5
        HDtemp5=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.4`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp5"

        # Temperature HD6
        HDtemp6=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.5`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp6"

        # Temperature HD7
        HDtemp7=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.6`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp7"

        # Temperature HD8
        # HDtemp8=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.7`
        # Send data
        # curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp8"

        # Free space volume in Go
        HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.4.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.5.52` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.6.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
 
        # Free space volume in percent
        HDTotal=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.52` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.52`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
        HDFreePerc=$((($HDUsed * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
 
	    # CPU utilisation
        CpuUser=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
        CpuSystem=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.10.0`
        CpuUse=$(($CpuUser + $CpuSystem))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
 
        # Free Memory Available in %
        MemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.4.1.2021.4.6.0`
        MemAvailableinMo=$(($MemAvailable / 1024))
        MemUsepercent=$((($MemAvailableinMo * 100) / 1024))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
 
      fi
 
 else
        curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "Off" > /dev/null
        if [ $? -eq 0 ] ; then
                echo "NAS already OFF"
                exit
        else
                echo "NAS OFF"
                # Send data
                curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=Off"
        fi
 fi
benj29
Posts: 16
Joined: Sunday 22 January 2017 15:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by benj29 »

Hi,

Thanks for your support.
Could you confirm the type of the output in Domoticz ?

Mine are :
Image

When I use your code (i've removed the 4 last temperature sensors), only HDD temperature sensors will working... and i have this error :

Code: Select all

}
./nas.sh: ligne 86: (No Such Instance currently exists at this OID - No Such Instance currently exists at this OID) * No Such Instance currently exists at this OID / 1024 / 1024 / 1024 : « ) » manquante (le symbole erroné est "Such Instance currently exists at this OID - No Such Instance currently exists at this OID) * No Such Instance currently exists at this OID / 1024 / 1024 / 1024")
Line 86 = Free Space Volume in Go.
The code does not check CPU, RAM etc... ?
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by rjblake »

Suggest running the following command from the command line on Synology:

snmpwalk -v 2c -c"your password" "your NAS IP" 1.3.6.1.2.1.25.2.3.1 (where items in " " need to be replaced with yours)

This will return the information needed to determine the correct OID to check disk space. Look for a entry like the following (assuming you want info for /volume1):

HOST-RESOURCES-MIB::hrStorageDescr.52 = STRING: /volume1

Where .52 is correct for my setup, it may/will be something else for yours (e.g. 31, 41, 51, etc.). In the script, edit the relevant lines with the correct OID, such as:

# Free space volume in Go
HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.4.52`
HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.5.52`
HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.6.52`
HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))

Do the same type of check for CPU, RAM, etc.

My devices as attached.
Attachments
Syno-Devices.png
Syno-Devices.png (84.83 KiB) Viewed 6582 times
benj29
Posts: 16
Joined: Sunday 22 January 2017 15:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by benj29 »

I will try tonight thanks! Keep u in touch

Envoyé de mon Moto G (4) en utilisant Tapatalk
Erwinvos72
Posts: 61
Joined: Thursday 25 February 2016 16:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Erwinvos72 »

thnx to your post rjblake i saw my OID was .51
After that it worked. the values are much the same

Free space in Go (synology says 6.7TB, script ,6.918TB)
Free used space in % give me the % which is used, so i changed my text.

CPU en Mem usage i dont use, i use the motherboard feature in domoticz.
kubrik
Posts: 47
Joined: Wednesday 30 November 2016 15:07
Target OS: Linux
Domoticz version: 2020.2
Location: Italy
Contact:

Re: HowTo: monitor Synology NAS

Post by kubrik »

I could suggest this free tool to test and find snmp values: https://www.paessler.com/tools/snmptester
Ubuntu 20.04 on ACEPC AK1 (previously RPi3b+)
Z-Stick Gen5, RFXtrx433E, Philips HUE Bridge, Yeelight, ESP8266 NodeMCU, Broadlink RM
dZvents, bash, php, Node-RED
User avatar
wizjos
Posts: 78
Joined: Monday 07 March 2016 19:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by wizjos »

For a member of the Dutch Synology forum who needs to monitor various Synologys I've made an extension of the current script that lets you enter a the name of the volume want to investigate:

Code: Select all

	# Free space volume in Gb

	# Extra variable stating the name of the volume you want to read the free space of
	searchVolume="volume1"

	# read the output of the complete hrStorageDescr
	tmpVolume=`snmpwalk -v 2c -c $PASSWORD  $NASIP .1.3.6.1.2.1.25.2.3.1.3`
	# adjust string separator to line-break
	IFS=$'\n'
	# array with all hrStorageDescr's
	storageArray=($tmpVolume) 
	for index in "${!storageArray[@]}"
	do
		# is the current hrStorageDescr equal to searchVolume 
		if [[ ${storageArray[index]} =~ .*$searchVolume.* ]]
		then
			# get the complete hrStorageDescr line sought
			foundVolume=${storageArray[index]}
			# adjust string separator to '.'
			IFS=$'.'
			# split into array (eg. element 0='HOST-RESOURCES-MIB::hrStorageDescr'; element 1 ='41 = STRING: /volume1')
			foundStorageArray=($foundVolume)
			# get first two numbers as the right hrStorageDescr element number
			hrStorageDescr=${foundStorageArray[1]:0:2}
		fi
	done
	echo "hrStorageDescr of $searchVolume = $hrStorageDescr"
	# re-adjust string separator to line-break
	IFS=$'\n'
	tmpHDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.4.$hrStorageDescr`
	echo "HDUnit:" $tmpHDUnit
	HDUnit=${tmpHDUnit%% *}
	HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.$hrStorageDescr`
	echo "HDTotal:" $HDTotal
	HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.$hrStorageDescr`
	echo "HDUsed:" $HDUsed
	HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
	echo $HDFree

	# Send data
	echo "Sending data to device#:" $NAS_HD_SPACE_IDX
	curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
	echo "Data sent"

	# Free space volume in percent
	HDTotal=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.$hrStorageDescr`
	echo "HDTotal:" $HDTotal
	HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.$hrStorageDescr`
	echo "HDUsed:" $HDUsed
	HDUsedPerc=$((($HDUsed * 100) / $HDTotal))
	echo "HDUsedPerc:" $HDUsedPerc

	# Send data
	echo "Sending data to device#:" $NAS_HD_SPACE_PERC_IDX
	curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDUsedPerc"
	echo "Data sent"
Works like a charm on both my Syno's.
Hope you guys find it usefull :P

Regards,

Wizjos
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by rjblake »

@Wizjos - nice elegant solution - thanks for sharing
duduf
Posts: 6
Joined: Friday 20 January 2017 11:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.604
Location: Capelle a/d IJssel
Contact:

Re: HowTo: monitor Synology NAS

Post by duduf »

Martijn85 wrote:
duduf wrote:Anyone???
Do you have turned on SNMP on the NAS?
Sorry for the very late answer but I don't get a message saying someone reply at my question. I decide today to try again to get it works.
SNMP is on on the NAS.
Any idea what the problem can be?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: HowTo: monitor Synology NAS

Post by Egregius »

Why not keep it simple and just run a script on the nas to check disk space and sent warning when over a treshold?
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: HowTo: monitor Synology NAS

Post by EdwinK »

wizjos wrote:For a member of the Dutch Synology forum who needs to monitor various Synologys I've made an extension of the current script that lets you enter a the name of the volume want to investigate:


Works like a charm on both my Syno's.
Hope you guys find it usefull :P

Regards,

Wizjos
Would be nice to monitor my two D110j's (if I ever can find those Power supplies).
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
wizjos
Posts: 78
Joined: Monday 07 March 2016 19:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by wizjos »

EdKo66 wrote:Would be nice to monitor my two D110j's (if I ever can find those Power supplies).
I'm not sure if I'm able to help you find them :mrgreen:
But if you need assistance with the script please tell me.

Regards,
Wizjos
walberg
Posts: 46
Joined: Thursday 28 May 2015 18:41
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Diemen Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by walberg »

ThaBoo wrote:@rvmourik Thanx for the script!

Got it all set up within 30 minutes.
Configuration: DS1010+ DSM 4.3-3810, Raspberry PI Domoticz V1.1492 ( and a Plugwise Circle for the power consumption)

Synology Domotics.gif
Does this script (with Plugwise Circle) also work on Domoticz on Synology? and how do i name this script?
HM31
Posts: 56
Joined: Friday 04 August 2017 16:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by HM31 »

[/quote]Does this script (with Plugwise Circle) also work on Domoticz on Synology? and how do i name this script?[/quote]
Finaly, thanks to everybody in this thread, I think I got it to work with Domoticz installed on a Synology NAS (DSM 5.2) to monitor another NAS (DSM 6.0 with two HDD in 1 JBOD volume). But without Plugwise Circle.

Just have to put it in cron to get complete.

Here is the code :

Code: Select all

 #!/bin/bash
 
 # Settings
 
 NASIP="192.168.x.x"         # NAS IP Address
 PASSWORD="xxxxx"           # SNMP Password
 DOMO_IP="192.168.x.y"       # Domoticz IP Address
 DOMO_PORT="8084"            # Domoticz Port
 NAS_IDX="62"                 # NAS Switch IDX
 NAS_HD1_TEMP_IDX="63"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="64"        # NAS HD2 Temp IDX
 NAS_HD_SPACE_IDX="65"        # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="66"   # NAS HD Space IDX in %
 NAS_CPU_IDX="68"             # NAS CPU IDX
 NAS_MEM_IDX="67"             # NAS MEM IDX
 
 
 # Check if NAS in online 
 
 PINGTIME=`ping -c 1 -q $NASIP | awk -F"/" '{print $5}' | xargs`
 
 echo $PINGTIME
 if expr "$PINGTIME" '>' 0
 then
   curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "On" > /dev/null
 
       if [ $? -eq 0 ] ; then
        echo "NAS already ON"
 
        # Temperature HD1
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
        # Temperature HD2
        HDtemp2=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
 
        # Free space volume in Go !! # Last OID digits based on snmpwalk -v 2c -c"password" "NAS IP" 1.3.6.1.2.1.25.2.3.1 
        tmpHDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUnit=${tmpHDUnit%% *}  
        HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.40` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
 
        # Free space volume in percent
        HDTotal=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.40` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
     	HDFreePerc=$(((($HDTotal - $HDUsed) * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
 
	# CPU utilisation
        CpuUser=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.10.0`
	CpuUse=$(($CpuUser + $CpuSystem))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
 
	# Memory Used in %
	tmpMemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
	MemAvailable=${tmpMemAvailable%% *}
	tmpMemtotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
	Memtotal=${tmpMemtotal%% *}
	tmpMemShared=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.13.0`
	MemShared=${tmpMemShared%% *}
	tmpMemBuffer=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.14.0`
	MemBuffer=${tmpMemBuffer%% *}
	tmpMemCached=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.15.0`
	MemCached=${tmpMemCached%% *}
	MemFREE=$(($MemAvailable + $MemShared + $MemBuffer + $MemCached))
	MemUsepercent=$(((($Memtotal - $MemFREE) * 100) / $Memtotal))
	#// For Available use MemUsepercent=$(((($MemFREE) * 100) / $Memtotal))      
	# Send data
  	curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent" 
else
        echo "NAS ON"
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=On"
 
        # Temperature HD1
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
        # Temperature HD2
        HDtemp2=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
 
        # Free space volume in Go !! # Last OID digit based on snmpwalk -v 2c -c"password" "NAS IP" 1.3.6.1.2.1.25.2.3.1 
        tmpHDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUnit=${tmpHDUnit%% *}
        HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.40` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
 
        # Free space volume in percent
        HDTotal=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.40` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.40`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
     	HDFreePerc=$(((($HDTotal - $HDUsed) * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
 
	# CPU utilisation
        CpuUser=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.10.0`
	CpuUse=$(($CpuUser + $CpuSystem))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
 
        # Memory Used in %                                                                    
        tmpMemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`     
        MemAvailable=${tmpMemAvailable%% *}                                                   
        tmpMemtotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`         
        Memtotal=${tmpMemtotal%% *}                                                           
        tmpMemShared=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.13.0`       
        MemShared=${tmpMemShared%% *}                                                         
        tmpMemBuffer=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.14.0`       
        MemBuffer=${tmpMemBuffer%% *}                                                         
        tmpMemCached=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.15.0`       
        MemCached=${tmpMemCached%% *}                                                         
	MemFREE=$(($MemAvailable + $MemShared + $MemBuffer + $MemCached))
	MemUsepercent=$(((($Memtotal - $MemFREE) * 100) / $Memtotal))
	#// For Available use MemUsepercent=$(((($MemFREE) * 100) / $Memtotal))      
	# Send data
	curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent" 
      fi
 
 else
        curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "Off" > /dev/null
        if [ $? -eq 0 ] ; then
                echo "NAS already OFF"
                exit
        else
                echo "NAS OFF"
                # Send data
                curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=Off"
        fi
#fi
 fi
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: HowTo: monitor Synology NAS

Post by DAVIZINHO »

Hello!
I use the script and wiki instrucctions to monitor a ds414 and work fin. I searched the correct id for my devices but with the instrucctions of this forum was easy.

The problem is with the "counter virtual swith", in the device seccion of domoticz i see it with the correct values. But in "utility section" apears strangr dates and diferent in title and in the body of sensor. I don´t understand nothing :-(
I use counter virtual switch

any advice???

and other question, i find the correct id for my 4 hdd. its posible to find the id for a usb device?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests