HowTo: monitor Synology NAS

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

Moderator: leecollings

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: 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 :(
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 »

EdwinK wrote: Saturday 21 October 2017 12:42 Never found them :(
Err... Not sure what you mean... :?
marxkemp
Posts: 10
Joined: Sunday 17 January 2016 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by marxkemp »

He never found the power adapters for thos NAS devices..
IDANIT
Posts: 73
Joined: Saturday 07 November 2015 10:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Poland
Contact:

Re: HowTo: monitor Synology NAS

Post 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.
IDANIT
Posts: 73
Joined: Saturday 07 November 2015 10:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Poland
Contact:

Re: HowTo: monitor Synology NAS

Post 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
JacEngels
Posts: 18
Joined: Sunday 03 December 2017 10:17
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: HowTo: monitor Synology NAS

Post 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?
rudolfpi
Posts: 8
Joined: Monday 19 March 2018 18:17
Target OS: Linux
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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)
schoutene
Posts: 5
Joined: Monday 13 April 2015 22:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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.
JacEngels
Posts: 18
Joined: Sunday 03 December 2017 10:17
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: HowTo: monitor Synology NAS

Post 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!
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 »

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 $
Attachments
Screen Shot 2018-04-23 at 10.04.19.png
Screen Shot 2018-04-23 at 10.04.19.png (219.67 KiB) Viewed 4788 times
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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,
Its posible to obtain de SNMP command to a USB disk??

thanks a lot!
DarkAllMan
Posts: 52
Joined: Friday 23 December 2016 9:41
Target OS: Linux
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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?
DarkAllMan
Posts: 52
Joined: Friday 23 December 2016 9:41
Target OS: Linux
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by DarkAllMan »

Solved, SNMP walk revealed that my volume information was on .51
frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by frenchyyii »

Just to give that information:
52 for DS918+
DaWauZ
Posts: 69
Joined: Wednesday 05 November 2014 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post 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 3523 times
12-3-2019 08-29-36.jpg
12-3-2019 08-29-36.jpg (144.28 KiB) Viewed 3523 times
12-3-2019 08-28-39.jpg
12-3-2019 08-28-39.jpg (105.33 KiB) Viewed 3523 times
Raspberry Pi 2 model B with domoticz
OMV NAS installed on thin client HP T610
Openelec Kodi Mediaplayer on thin client HP T520 (and with multiboot windows 10)
Dellie
Posts: 10
Joined: Wednesday 03 April 2019 12:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post 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
koender
Posts: 2
Joined: Friday 24 May 2019 17:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Best, NL
Contact:

Re: HowTo: monitor Synology NAS

Post 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))
svdhaar
Posts: 36
Joined: Friday 10 April 2020 7:01
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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
multinet
Posts: 97
Joined: Friday 05 December 2014 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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
PI 2 - Domoticz 2021.1
RFXCOM - RFXtrx433 USB 433.92MHz Transceiver (5 DIO 54755 + 2 DIO 54756 + 3 DIO 54798)
Z-Wave.Me ZME_UZB1 USB Stick (6 FGSD002 + 2 FGRM222 + 1 FGS223 + 1 FGMS001-ZW5 + 1 FGRGBWM441 + 1 FGBS001 + 2 FGFS101)
6 sondes DS18B20
svdhaar
Posts: 36
Joined: Friday 10 April 2020 7:01
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest