Page 7 of 10

Re: HowTo: monitor Synology NAS

Posted: Thursday 26 May 2016 8:54
by raymond
mickeyr61 wrote:Ray, thanks for yoyr reply. I have changed the last two digits to .36 and now the Parameter HDUsed is 116. But HDFree and HDFreePerc stay 0.
This is what I have, and some more for comparison, which works for me.

Code: Select all

# Free space volume in GB
            #HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.36`  # Change OID to .38 on DSM 5.1
            #HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.36` # Change OID to .38 on DSM 5.1
            #HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.36`  # Change OID to .38 on DSM 5.1
            #HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))

            # Send data
            #curl -s -i -H "Accept: application/json" "http://$DOMO_USER:$DOMO_PASS@$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.36` # Change OID to .38 on DSM 5.1
            HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.36`  # Change OID to .38 on DSM 5.1
            HDFreePerc=$((($HDUsed * 100) / $HDTotal))

            # Send data
            curl -s -i -H "Accept: application/json" "http://$DOMO_USER:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"


This should be working for you, or at least test the snmpwalk commands individually.

Ray

Re: HowTo: monitor Synology NAS

Posted: Tuesday 14 June 2016 19:02
by ruderik
For my DS214play with DSM 6.0 the .36 didn't work correctly, had to change it to .41
This is my storage descriptor table, as you can see .36 is my /tmp

Code: Select all

Name/OID: hrStorageDescr.1; Value (OctetString): Physical memory
Name/OID: hrStorageDescr.3; Value (OctetString): Virtual memory
Name/OID: hrStorageDescr.6; Value (OctetString): Memory buffers
Name/OID: hrStorageDescr.7; Value (OctetString): Cached memory
Name/OID: hrStorageDescr.8; Value (OctetString): Shared memory
Name/OID: hrStorageDescr.10; Value (OctetString): Swap space
Name/OID: hrStorageDescr.31; Value (OctetString): /
Name/OID: hrStorageDescr.36; Value (OctetString): /tmp
Name/OID: hrStorageDescr.37; Value (OctetString): /run
Name/OID: hrStorageDescr.38; Value (OctetString): /dev/shm
Name/OID: hrStorageDescr.41; Value (OctetString): /volume1

Re: HowTo: monitor Synology NAS

Posted: Wednesday 22 June 2016 18:49
by rednas
I am trying to get this to work. But the storage is always showing 0 (both the percentage and the normal one).
I have a DS216+ with DSM 6.0.1.
Also installed SnmpB on my Windows laptop to see the tree of my NAS and I can go up to 1.3.6.1.2.1 but then I am not able to find 25..
Can someone help me?

Re: HowTo: monitor Synology NAS

Posted: Thursday 22 September 2016 13:54
by Erwinvos72
Good afternoon everybody,

i saw this awesone script. Andy i was wondering if i could manage my synology with domoticz. Within domoticz i already have added the motherboard sensors and with these i can see my CPU en Memory percentage. So i did the steps according to the wiki for a setup for my 4 drive NAS (Synology DS916+ 8GB), did the chmod and tried to test the script. And it stucks on the line to ping my NAS. I receive a syntax error on Pingtime. When i try to execute it directly from putty i receive the ping time.

I tried it without the ping part but then it directory stucks on the next line. So my question is, is it possible to run this script on domoticz which is installed as a package on the synology i want to monitor.

any suggestions?

Re: HowTo: monitor Synology NAS

Posted: Tuesday 27 September 2016 14:51
by Erwinvos72
Anyone suggestions on my above question?

Re: HowTo: monitor Synology NAS

Posted: Wednesday 28 September 2016 14:30
by Erwinvos72
I have done some investigating and when i use bash i get the script to run. But it stucks on snmpget, he doesn't know this command. when i try snmpwalk from the putty commandline i'll get the temperature of the disk. So the script is actually working.

But the issue is that on my synology snmpget isn't available. Is it possible to install/include snmpget on my synology so the command can be used. Or is there an other way to get it executed the way it should be.

Re: HowTo: monitor Synology NAS

Posted: Tuesday 04 October 2016 12:25
by Erwinvos72
A view days ago i asked some questions but onfortunately no reactions. In the mean time i was able to get the temperature from my 4 NAS disks and put it into domoticz. But i struggle with the space en mem. Those counters don't give the right information.

Anyone?

Re: HowTo: monitor Synology NAS

Posted: Thursday 13 October 2016 15:37
by raymond
Erwinvos72 wrote:I have done some investigating and when i use bash i get the script to run. But it stucks on snmpget, he doesn't know this command. when i try snmpwalk from the putty commandline i'll get the temperature of the disk. So the script is actually working.

But the issue is that on my synology snmpget isn't available. Is it possible to install/include snmpget on my synology so the command can be used. Or is there an other way to get it executed the way it should be.
I changed all snmpget commands in the bash script itself to snmpwalk one-by-one on my Synology, then it started to work (again). I stated this a few posts earlier also with some example script piece.
Provided that you are running the script on the Synology box itself of course :)
This way you do not have to install anything.
I'm not sure why this has changed on the Synology boxes.

Ray

Re: HowTo: monitor Synology NAS

Posted: Thursday 13 October 2016 16:25
by jumbotroll
Hi.
I have cross compiled snmp packages for synology if you guys want to test.
net-snmp_6.0_5.7.3-2.spk
http://www.jadahl.com/synology6/index.php?fulllist=true

Re: HowTo: monitor Synology NAS

Posted: Monday 19 December 2016 17:01
by TroisSix
Very nice topic, thanks a lot rvmourik, it's working well with my APC ES700 and DS412+ / DSM 6.02 ;)
I retrieve infos like: input voltage, charge, runtime, battery voltage, ... it was quite long to get good informations lol.
The script uses input voltage to give me an alert "no current - battery mode" (with an mail notification every 5 minutes)
So fun ;)

Re: HowTo: monitor Synology NAS

Posted: Thursday 22 December 2016 15:06
by Erwinvos72
Hi everyone,

i got the disk temperature up and running, that wasn't a big part.
The used GB in % is a part of the motherboard sensors so i could add that easy as well (i run domoticz directly on my synology)

Now i am trying to get the available space in GB and % get to work, but i am still stuck in de /1024 /1024 part. With snmpget or snmpwalk i receive an error that is 'kb' and there is missing a ')'

Anyone got this already working and would share this here?

Re: HowTo: monitor Synology NAS

Posted: Friday 23 December 2016 19:58
by kubrik
From cmdline try this command, replacing COMMUNITY and NASIP with your values:

snmpget -v 2c -c COMMUNITY -O qv NASIP 1.3.6.1.2.1.25.2.3.1.4.41
or
snmpget -v 2c -c COMMUNITY -O qv NASIP 1.3.6.1.2.1.25.2.3.1.4.38

and post the result.

Re: HowTo: monitor Synology NAS

Posted: Wednesday 04 January 2017 10:00
by Erwinvos72
Excuse for the delay, i had a short holiday break :-)
Here is the output

1.3.6.1.2.1.25.2.3.1.4.41
No Such Instance currently exists at this OID

1.3.6.1.2.1.25.2.3.1.4.38
4096 Bytes

Extra information:
I use Synology Hybrid Raid and have 4 disks of 3TB. Effictive 8 TB Capacity and 6,8 TB available. But my total isn't shown.
By HDTotal i get 1011689 as value
But when i change the last digit to 37 i also receive 1011689

This also goes for HDUsed.

So i miss the total amount of my SHR

Re: HowTo: monitor Synology NAS

Posted: Friday 20 January 2017 12:11
by duduf
hello, I have trouble with the script. It works wel for a while but for a few mounds anymore. I don't remenber from when it's happend.
I try for now to get the temp from the HDD working but without success. Maybe can someone help me with it.
If i do

Code: Select all

pi@raspberrypi:~$ snmpwalk -v 2c -c public -O qv 192.168.10.94 1.3.6.1.4.1.6574.2.1.1.6
29
29
28
27
29
I see all the temp from my 5 HDD en with .0, .1 etc.. I have got them separately.
Problem is that domoticz don't get the info with the curl....
this is my nas.sh script :

Code: Select all

#!/bin/bash
 # Settings
 
 NASIP="192.168.10.94"        # NAS IP Address
 PASSWORD="public"            # SNMP Password
 DOMO_IP="192.168.10.119"     # Domoticz IP Address
 DOMO_PORT="8080"             # Domoticz Port
 NAS_IDX="135"                # NAS Switch IDX
 NAS_HDD_TEMP_IDX="15"        # NAS HDD Temp IDX
 NAS_HD1_TEMP_IDX="28"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="29"        # NAS HD2 Temp IDX
 NAS_HD3_TEMP_IDX="30"        # NAS HD3 Temp IDX
 NAS_HD4_TEMP_IDX="31"        # NAS HD4 Temp IDX
 NAS_HD5_TEMP_IDX="39"        # NAS HD5 Temp IDX
 NAS_HD_SPACE_IDX="132"       # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="136"  # NAS HD Space IDX in %
 NAS_CPU_IDX="133"            # NAS CPU IDX
 NAS_MEM_IDX="134"            # 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 System
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HDD_TEMP_IDX&nvalue=0&svalue$=$HDtemp1"

		# Temperature HD1
        HDtemp2=`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$=$HDtemp2"

        # Temperature HD2
        HDtemp3=`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$=$HDtemp3"

        # Temperature HD3
        HDtemp4=`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$=$HDtemp4"

        # Temperature HD4
        HDtemp5=`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$=$HDtemp5"
 
        # Temperature HD5
        HDtemp6=`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$=$HDtemp6"


        
 
        

		
 
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 System
        HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2.0`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HDD_TEMP_IDX&nvalue=0&svalue$=$HDtemp1"

		# Temperature HD1
        HDtemp2=`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$=$HDtemp2"

        # Temperature HD2
        HDtemp3=`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$=$HDtemp3"

        # Temperature HD3
        HDtemp4=`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$=$HDtemp4"

        # Temperature HD4
        HDtemp5=`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$=$HDtemp5"
 
        # Temperature HD5
        HDtemp6=`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$=$HDtemp6"

          
        
      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
and in domoticz stay everything to 0 :
Knipsel.PNG
Knipsel.PNG (91.4 KiB) Viewed 7750 times
Somebody a idea??

Re: HowTo: monitor Synology NAS

Posted: Saturday 21 January 2017 10:39
by duduf
Anyone???

Re: HowTo: monitor Synology NAS

Posted: Friday 27 January 2017 21:57
by curious
When I run the script I mostly get the message Timeout : no response
When pinging the ip-adres I get an answer within about .420 ms

Besides that I get an error message :
line 44: ( - ) * / 1024 / 1024 / 1024: syntax error: operand expected (error token is ") * / 1024 / 1024 / 1024")
But that can be caused by the time outs ?

The script in line 43 and 44 is :

Code: Select all

 HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.41`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
I can't see anything wrong, the only thing I changes is .36 to .41
I have a synology 213J running on DSM 6.0+

NB: When running a single command like :
HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.41`
I sometimes get a result but not often (time out)

Re: HowTo: monitor Synology NAS

Posted: Saturday 04 February 2017 23:59
by Martijn85
duduf wrote:Anyone???
Do you have turned on SNMP on the NAS?

Re: HowTo: monitor Synology NAS

Posted: Sunday 12 February 2017 14:01
by LouiS22
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 :(

Re: HowTo: monitor Synology NAS

Posted: Saturday 18 February 2017 21:11
by epierre
same for me, time out and no more values... DS216 on DSM 6.0.2-8451 Update 9

snmpwalk -v1 -cpublic 192.168.0.12|grep 1.2.1.25.2.3.1.6
iso.3.6.1.2.1.25.2.3.1.6.1 = INTEGER: 490696
iso.3.6.1.2.1.25.2.3.1.6.3 = INTEGER: 726968
iso.3.6.1.2.1.25.2.3.1.6.6 = INTEGER: 13240
iso.3.6.1.2.1.25.2.3.1.6.7 = INTEGER: 165888
iso.3.6.1.2.1.25.2.3.1.6.10 = INTEGER: 236272
iso.3.6.1.2.1.25.2.3.1.6.31 = INTEGER: 251229
iso.3.6.1.2.1.25.2.3.1.6.32 = INTEGER: 1
iso.3.6.1.2.1.25.2.3.1.6.33 = INTEGER: 856261946
iso.3.6.1.2.1.25.2.3.1.6.34 = INTEGER: 358245396

Re: HowTo: monitor Synology NAS

Posted: Tuesday 21 February 2017 16:28
by AlwinHummels
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"