Page 9 of 10

Re: HowTo: monitor Synology NAS

Posted: Saturday 21 October 2017 12:42
by EdwinK
wizjos wrote: Tuesday 30 May 2017 12:49
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

Never found them :(

Re: HowTo: monitor Synology NAS

Posted: Saturday 21 October 2017 13:44
by wizjos
EdwinK wrote: Saturday 21 October 2017 12:42 Never found them :(
Err... Not sure what you mean... :?

Re: HowTo: monitor Synology NAS

Posted: Saturday 21 October 2017 16:42
by marxkemp
He never found the power adapters for thos NAS devices..

Re: HowTo: monitor Synology NAS

Posted: Sunday 29 October 2017 9:49
by IDANIT

Code: Select all

ping: '''192.168.1.68''': Name or service not known

0
NAS OFF

Code: Select all

 NASIP="'''192.168.1.68'''"             # NAS IP Address
 PASSWORD="'''mypassword'''"            # SNMP Password
 DOMO_IP="'''192.168.1.110'''"          # Domoticz IP Address
 DOMO_PORT="'''8080'''"                 # Domoticz Port
 NAS_IDX="'''1100'''"                   # Virtual switch NAS STATUS
 CPU_TEMP_IDX="'''1101'''"              # Virtual temerature sensor IDX$
 HD1_TEMP_IDX="'''1102'''"              # Virtual temerature sensor IDX$
 HD2_TEMP_IDX="'''1103'''"              # Virtual temerature sensor IDX$
 HD_REMAIN_IDX="'''1104'''"             # Virtual temerature sensor IDX HD REMA$
 DOMO_LOGIN="mylogin"
 DOMO_PASS="mypassword"
QNAP TS-251. What I did wrong? NAS is working of course... 24/7.
When I did

Code: Select all

snmpget -v 2c -c mysnmppassword -O qv 192.168.1.68 1.3.6.1.4.1.24681.1.2.11.1.3.1
I get "40 C/104 F" so snmp is working.

Re: HowTo: monitor Synology NAS

Posted: Wednesday 15 November 2017 8:23
by IDANIT
IDANIT wrote: Sunday 29 October 2017 9:49

Code: Select all

ping: '''192.168.1.68''': Name or service not known

0
NAS OFF

Code: Select all

 NASIP="'''192.168.1.68'''"             # NAS IP Address
 PASSWORD="'''mypassword'''"            # SNMP Password
 DOMO_IP="'''192.168.1.110'''"          # Domoticz IP Address
 DOMO_PORT="'''8080'''"                 # Domoticz Port
 NAS_IDX="'''1100'''"                   # Virtual switch NAS STATUS
 CPU_TEMP_IDX="'''1101'''"              # Virtual temerature sensor IDX$
 HD1_TEMP_IDX="'''1102'''"              # Virtual temerature sensor IDX$
 HD2_TEMP_IDX="'''1103'''"              # Virtual temerature sensor IDX$
 HD_REMAIN_IDX="'''1104'''"             # Virtual temerature sensor IDX HD REMA$
 DOMO_LOGIN="mylogin"
 DOMO_PASS="mypassword"
QNAP TS-251. What I did wrong? NAS is working of course... 24/7.
When I did

Code: Select all

snmpget -v 2c -c mysnmppassword -O qv 192.168.1.68 1.3.6.1.4.1.24681.1.2.11.1.3.1
I get "40 C/104 F" so snmp is working.
up

Re: HowTo: monitor Synology NAS

Posted: Sunday 24 December 2017 15:04
by JacEngels
I'm setting this up for my DS212j Synology NAS running on DSM 6.1.4-15217 Update 5.

Both temperature checks are working but the disk checks don't work: there is nothing to find for the OID! I used .41 and several others.

Which OID do I use to get the script working?

Re: HowTo: monitor Synology NAS

Posted: Monday 19 March 2018 18:40
by rudolfpi
How to get the virtual sensors in Domoticz, and get them connected to the scripts that runned on the Synology (sorry I'm new in Domoticz)

Re: HowTo: monitor Synology NAS

Posted: Thursday 19 April 2018 10:04
by schoutene
JacEngels wrote: Sunday 24 December 2017 15:04 I'm setting this up for my DS212j Synology NAS running on DSM 6.1.4-15217 Update 5.

Both temperature checks are working but the disk checks don't work: there is nothing to find for the OID! I used .41 and several others.

Which OID do I use to get the script working?
I had the same. I did some Internet searching and found that the OID needs to be .42 for DSM 6.1., which works on my Synology. I updated the script on the Domoticz wiki.

Re: HowTo: monitor Synology NAS

Posted: Sunday 22 April 2018 19:46
by JacEngels
schoutene wrote: Thursday 19 April 2018 10:04
JacEngels wrote: Sunday 24 December 2017 15:04 I'm setting this up for my DS212j Synology NAS running on DSM 6.1.4-15217 Update 5.

Both temperature checks are working but the disk checks don't work: there is nothing to find for the OID! I used .41 and several others.

Which OID do I use to get the script working?
I had the same. I did some Internet searching and found that the OID needs to be .42 for DSM 6.1., which works on my Synology. I updated the script on the Domoticz wiki.
Thank you for the update. I've figured that out some time ago but forgot to mention it here!

Re: HowTo: monitor Synology NAS

Posted: Monday 23 April 2018 10:04
by EdwinK
So, I think I'm almost there with this script. Still, I also think that there is something not quite right. This is the script I use. I only have 4 drives, so commented out where it looks for more drives.

Code: Select all

#!/bin/bash
 
 # Settings
 
 NASIP="192.168.0.10"      # NAS IP Address
 PASSWORD="<<PASSWORD>>"        # SNMP Password
 DOMO_IP="192.168.0.11"    # Domoticz IP Address
 DOMO_PORT="8080"            # Domoticz Port
 NAS_IDX="160"                # NAS Switch IDX
 NAS_HD1_TEMP_IDX="161"       # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="162"       # NAS HD1 Temp IDX
 NAS_HD3_TEMP_IDX="163"       # NAS HD2 Temp IDX
 NAS_HD4_TEMP_IDX="164"       # 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="168"       # NAS HD Space IDX in Go
 #NAS_HD_SPACE_PERC_IDX="63"  # NAS HD Space IDX in %
 NAS_CPU_IDX="165"            # NAS CPU IDX
 NAS_MEM_IDX="166"            # NAS MEM IDX
 NAS_CPU_TEMP="169"		   # 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"

        # 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.42`  # 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.42` # 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.42`  # 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
 
When I run this script manually, I see the following:
./nas.sh
0.345
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
pi@domo-server:~/domoticz/scripts $ sudo nano nas.sh
pi@domo-server:~/domoticz/scripts $ ./nas.sh
0.376
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html

<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html

<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html

<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>./nas.sh: line 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: missing `)' (error token is "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")
0.333
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *

{
"status" : "OK",
"title" : "Update Device"
}
pi@domo-server:~/domoticz/scripts $

Re: HowTo: monitor Synology NAS

Posted: Monday 14 May 2018 13:06
by DAVIZINHO
hello,
Its posible to obtain de SNMP command to a USB disk??

thanks a lot!

Re: HowTo: monitor Synology NAS

Posted: Thursday 16 August 2018 13:30
by DarkAllMan
Installed DS218+ today and implemented the script...
Everything is working except DISKSPACE & DISKSPACE PERCENTAGE

Code: Select all

snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.4.36
4096
snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.5.36
234011
snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.6.36
265
But counter and diskpercentage stay at 0

Can anyone point me in the right direction?

Re: HowTo: monitor Synology NAS

Posted: Thursday 16 August 2018 15:02
by DarkAllMan
Solved, SNMP walk revealed that my volume information was on .51

Re: HowTo: monitor Synology NAS

Posted: Sunday 28 October 2018 11:28
by frenchyyii
Just to give that information:
52 for DS918+

Re: HowTo: monitor Synology NAS

Posted: Tuesday 12 March 2019 8:44
by DaWauZ
Hello there,

I have build a Xpenology Nas based on model 3615XS with DSM 6.2
RAID5 setup with 3 1TB disks, and total 6gb ram modules (2+2+1+1 gb modules)

I have used the script from the wiki, blurred here my ipadress settings etc
Spoiler: show

Code: Select all

#!/bin/bash
 
 # Settings
 
 NASIP=""       # NAS IP Address
 PASSWORD=""            # SNMP Password
 DOMO_IP=""      # Domoticz IP Address
 DOMO_PORT=""            # Domoticz Port
 NAS_IDX="335"                 # NAS Switch IDX
 NAS_HD1_TEMP_IDX="336"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="337"        # NAS HD2 Temp IDX
 NAS_HD3_TEMP_IDX="338"
 NAS_HD4_TEMP_IDX="343"
 NAS_HD_SPACE_IDX="344"        # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="341"   # NAS HD Space IDX in %
 NAS_CPU_IDX="339"             # NAS CPU IDX
 NAS_MEM_IDX="340"             # 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=`snmpget -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=`snmpget -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&id$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
       
        # Temperature HD3
        HDtemp3=`snmpget -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
        HDtemp3=`snmpget -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"
 
        # Free space volume in Go
        HDUnit=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.51` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        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=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.51` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
     	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=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpget -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=`snmpget -v 2c -c $PASSWORD -O qv $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 HD1
        HDtemp1=`snmpget -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=`snmpget -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=`snmpget -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=`snmpget -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"
 
        # Free space volume in Go
        HDUnit=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.51` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        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=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.51` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.51`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1
     	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=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpget -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=`snmpget -v 2c -c $PASSWORD -O qv $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

It works for disk temps, cpu percentage used and harddisk % used, these are correct.
But there is something wrong with the memory, it is giving 500% and the harddisk counter is giving only 1 result, I dont know if thats right.
12-3-2019 08-31-40.jpg
12-3-2019 08-31-40.jpg (66.52 KiB) Viewed 3524 times
12-3-2019 08-29-36.jpg
12-3-2019 08-29-36.jpg (144.28 KiB) Viewed 3524 times
12-3-2019 08-28-39.jpg
12-3-2019 08-28-39.jpg (105.33 KiB) Viewed 3524 times

Re: HowTo: monitor Synology NAS

Posted: Tuesday 21 May 2019 15:04
by Dellie
Hi,

Hope someone is still active in this post.

Got some problems making it work with my Synology DS112 single bay NAS.
It has something to do with the OID’s but I just don’t see where I’m going wrong.

# Free space volume in Go
HDUnit=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
HDTotal=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
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=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
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"

Doing a snmpwalk -v1 -c <password> 192.168.1.10 results in a big list off information.
I think the part below is related to the script

iso.3.6.1.2.1.25.2.3.1.4.1 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.3 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.6 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.7 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.8 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.10 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.31 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.36 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.37 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.38 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.40 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.5.1 = INTEGER: 118456
iso.3.6.1.2.1.25.2.3.1.5.3 = INTEGER: 2215600
iso.3.6.1.2.1.25.2.3.1.5.6 = INTEGER: 118456
iso.3.6.1.2.1.25.2.3.1.5.7 = INTEGER: 47164
iso.3.6.1.2.1.25.2.3.1.5.8 = INTEGER: 1496
iso.3.6.1.2.1.25.2.3.1.5.10 = INTEGER: 2097144
iso.3.6.1.2.1.25.2.3.1.5.31 = INTEGER: 612782
iso.3.6.1.2.1.25.2.3.1.5.36 = INTEGER: 14807
iso.3.6.1.2.1.25.2.3.1.5.37 = INTEGER: 14807
iso.3.6.1.2.1.25.2.3.1.5.38 = INTEGER: 14807
iso.3.6.1.2.1.25.2.3.1.5.40 = INTEGER: 239196901
iso.3.6.1.2.1.25.2.3.1.6.1 = INTEGER: 104024
iso.3.6.1.2.1.25.2.3.1.6.3 = INTEGER: 298284
iso.3.6.1.2.1.25.2.3.1.6.6 = INTEGER: 692
iso.3.6.1.2.1.25.2.3.1.6.7 = INTEGER: 47164
iso.3.6.1.2.1.25.2.3.1.6.8 = INTEGER: 1496
iso.3.6.1.2.1.25.2.3.1.6.10 = INTEGER: 194260
iso.3.6.1.2.1.25.2.3.1.6.31 = INTEGER: 239807
iso.3.6.1.2.1.25.2.3.1.6.36 = INTEGER: 363
iso.3.6.1.2.1.25.2.3.1.6.37 = INTEGER: 512
iso.3.6.1.2.1.25.2.3.1.6.38 = INTEGER: 1
iso.3.6.1.2.1.25.2.3.1.6.40 = INTEGER: 189493620

Anybody an idea witch value's I should use?

Thanks in advance!!

Martijn

Re: HowTo: monitor Synology NAS

Posted: Friday 24 May 2019 17:20
by koender
DaWauZ wrote: Tuesday 12 March 2019 8:44

Code: Select all

        # Free Memory Available in %
	MemAvailable=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
        MemAvailableinMo=$(($MemAvailable / 1024))
	MemUsepercent=$((($MemAvailableinMo * 100) / 1024))
But there is something wrong with the memory, it is giving 500% and the harddisk counter is giving only 1 result, I dont know if thats right.
The percentage calculation is wrong, as it only uses the available memory without getting total amount of memory. So how do you calculate a percentage with only one value :roll: .
So try this:

Code: Select all

	MemTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
	MemAvailable=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
    	MemFreepercent=$(($MemAvailable*100 / $MemTotal))

Re: HowTo: monitor Synology NAS

Posted: Saturday 11 April 2020 8:21
by svdhaar
Hi all,

Hopefully some can help me with an error which occurs when i run the scripts.
I'm a noob in developing..

Domoticz is running on my Synology NAS, could that be the cause of this error?
If yes, anybody an idea if it is possible to monitor my NAS via domoticz which is installed on the NAS i want to monitor?

ok, ok.

Probleem solved. Username pwd was activated on domonicz and i didn't exclude the internal network setting..

i have copied the mentioned script and created a userdefined scheduled job which starts the script every 5 minutes.
This error occurs

Code: Select all

Taak: Check NAS status
Starttijd: Sat, 11 Apr 2020 10:28:29 GMT
Stoptijd: Sat, 11 Apr 2020 10:28:31 GMT
Huidige status: 1 (Onderbroken)
Standaard uitvoer/fout:
0.138
1
NAS ON
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: DMZSID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
Anyone an idea how to fix it?

I've setup snmp v1 - v2
And offcourse i've setup a password.

Spoiler: show

Code: Select all

#!/bin/bash
 
 # Settings
 
 NASIP="192.168.0.160"             # NAS IP Address
 PASSWORD="******"         # SNMP Password
 DOMO_IP="192.168.0.160"           # Domoticz IP Address
 DOMO_PORT="****"            # Domoticz Port
 NAS_IDX="34"                 # NAS Switch IDX
 NAS_HD1_TEMP_IDX="28"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="29"        # NAS HD2 Temp IDX
 NAS_HD_SPACE_IDX="33"        # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="32"   # NAS HD Space IDX in %
 NAS_CPU_IDX="30"             # NAS CPU IDX
 NAS_MEM_IDX="31"             # 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=`snmpget -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=`snmpget -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
        HDUnit=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDTotal=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        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=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
     	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=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpget -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=`snmpget -v 2c -c $PASSWORD -O qv $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 HD1
        HDtemp1=`snmpget -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=`snmpget -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
        HDUnit=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDTotal=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        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=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
        HDUsed=`snmpget -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, .41 on DSM 6.0, 42 on DSM 6.1
     	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=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
	CpuSystem=`snmpget -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=`snmpget -v 2c -c $PASSWORD -O qv $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

Re: HowTo: monitor Synology NAS

Posted: Monday 13 April 2020 13:05
by multinet
Hello

Does anyone have the correct OID for DSM6.2+ ?

Since I upgraded to this version my script is faulty on HDSPace calculation

on this part
# Free space volume in Go
HDUnit=`snmpget -v 2c -c $PASSWORD -O qv $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+
HDTotal=`snmpget -v 2c -c $PASSWORD -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+
HDUsed=`snmpget -v 2c -c $PASSWORD -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+
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=`snmpget -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+
HDUsed=`snmpget -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+
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"

Thank you

Re: HowTo: monitor Synology NAS

Posted: Saturday 18 April 2020 8:47
by svdhaar
multinet wrote: Monday 13 April 2020 13:05 Hello

Does anyone have the correct OID for DSM6.2+ ?

Since I upgraded to this version my script is faulty on HDSPace calculation

on this part
# Free space volume in Go
HDUnit=`snmpget -v 2c -c $PASSWORD -O qv $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+
HDTotal=`snmpget -v 2c -c $PASSWORD -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+
HDUsed=`snmpget -v 2c -c $PASSWORD -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+
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=`snmpget -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+
HDUsed=`snmpget -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+
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"

Thank you
.41 works for me! DSM6.2