HowTo: monitor Synology NAS

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

Moderator: leecollings

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,

I'm trying to get the general temperature in this scripts.
This returns value: 0

I'm running domoticz on a ds214se. Is there an issue with the oid?



# Temperature NAS
NAS_TEMP=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
echo "NAS_TEMP:" $nastemp

# Send data
echo "Sending data to device#:" $NAS_TEMP_IDX
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_TEMP_IDX&nvalue=0&svalue=$nastemp"
echo "Data sent"
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: HowTo: monitor Synology NAS

Post by EddyG »

I am running DSM 6.2 and it works.
To get temperatures from harddisks use: 1.3.6.1.4.1.6574.2.1.1.6
You will get the temperature from every harddisk as 1.3.6.1.4.1.6574.2.1.1.6.0 1.3.6.1.4.1.6574.2.1.1.6.1 etc....

Free tester on: https://www.paessler.com/tools/snmptester

NAS_TEMP=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
echo "NAS_TEMP:" $nastemp

Wrong variable use should be echo "NAS Temp: "$NAS_TEMP Same for the curl command
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 »

EddyG wrote: Saturday 18 April 2020 9:14 I am running DSM 6.2 and it works.
To get temperatures from harddisks use: 1.3.6.1.4.1.6574.2.1.1.6
You will get the temperature from every harddisk as 1.3.6.1.4.1.6574.2.1.1.6.0 1.3.6.1.4.1.6574.2.1.1.6.1 etc....

Free tester on: https://www.paessler.com/tools/snmptester
I only have issues with The HD temps. Only the general temp is returning blank.

The variable change did the job! Thanks
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 »

Another question:

I've added the FAN status to my script.
The data is 1 = ok 2 = not ok (From the MIB documentation)

I've added a virtual sensor, type text. it is updates nicely. But a sensor of type text is a bit ugly in the web gui.

2 questions: 1. is it possible to use a different type of sensor? Or, is it possible to use like conditional formatting. When 1 is returned, a green color, when 2 is returned, a red color.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: HowTo: monitor Synology NAS

Post by EddyG »

You could use a Type General with Subtype Alert.
See: https://www.domoticz.com/wiki/DzVents:_ ... ert_sensor
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by dressie »

svdhaar wrote: Saturday 18 April 2020 13:52 Another question:

I've added the FAN status to my script.
The data is 1 = ok 2 = not ok (From the MIB documentation)

I've added a virtual sensor, type text. it is updates nicely. But a sensor of type text is a bit ugly in the web gui.

2 questions: 1. is it possible to use a different type of sensor? Or, is it possible to use like conditional formatting. When 1 is returned, a green color, when 2 is returned, a red color.
I'm trying to add it too, and send it to an ' Alert Sensor" but I can't seem to get it to work. This is what I have in my script:

Code: Select all

 # Fan alert
        FANUnit=`snmpget -v 2c -c $PASSWORD -O qv $NASIP  1.3.6.1.4.1.6574.1.4.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_ALERT&nvalue=$FANUnit&svalue=FAN"
Any thoughts?
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 »

dressie wrote: Saturday 18 April 2020 19:51
svdhaar wrote: Saturday 18 April 2020 13:52 Another question:

I've added the FAN status to my script.
The data is 1 = ok 2 = not ok (From the MIB documentation)

I've added a virtual sensor, type text. it is updates nicely. But a sensor of type text is a bit ugly in the web gui.

2 questions: 1. is it possible to use a different type of sensor? Or, is it possible to use like conditional formatting. When 1 is returned, a green color, when 2 is returned, a red color.
I'm trying to add it too, and send it to an ' Alert Sensor" but I can't seem to get it to work. This is what I have in my script:

Code: Select all

 # Fan alert
        FANUnit=`snmpget -v 2c -c $PASSWORD -O qv $NASIP  1.3.6.1.4.1.6574.1.4.1`
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_ALERT&nvalue=$FANUnit&svalue=FAN"
Any thoughts?
I've got it working with:

FAN_STATUS=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.4.1`
echo "FAN_STATUS:" $FAN_STATUS

# Send data
echo "Sending data to device#:" $NAS_FAN_STAT_IDX
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_STAT_IDX&nvalue=0&svalue=$FAN_STATUS"
echo "Data sent"
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 »

EddyG wrote: Saturday 18 April 2020 18:41 You could use a Type General with Subtype Alert.
See: https://www.domoticz.com/wiki/DzVents:_ ... ert_sensor
Thanks!
Any idea what the syntax should be? If it is 1, it should be green, if it is 2 it should be red..

I use this code to update the sensor:

curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_STAT_IDX&nvalue=0&svalue=$FAN_STATUS"
echo "Data sent"


Fixed it :-)

# Fan status
FAN_STATUS=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.4.1`
echo "FAN_STATUS:" $FAN_STATUS
if expr $FAN_STATUS =<> "1" ; then
# Send data
echo "Sending data to device#:" $NAS_FAN_STAT_IDX
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_STAT_IDX&nvalue=4&svalue=$FAN_STATUS"
echo "Data sent"
else

# Send data
echo "Sending data to device#:" $NAS_FAN_STAT_IDX
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_STAT_IDX&nvalue=1&svalue=$FAN_STATUS"
echo "Data sent"
fi
lukev
Posts: 66
Joined: Friday 21 October 2016 10:42
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by lukev »

mmm.... i'm getting this error after I followed every step in the tutorial:

Code: Select all

./nas.sh: line 125: unexpected EOF while looking for matching `"'
./nas.sh: line 128: syntax error: unexpected end of file
Any ideas?
peidor
Posts: 1
Joined: Wednesday 16 December 2020 12:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by peidor »

svdhaar wrote: Saturday 18 April 2020 8:47
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
I use .44 for DSM 6.2.3-25426 Update 3
RobbieT1974
Posts: 3
Joined: Saturday 06 February 2016 21:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by RobbieT1974 »

I modified the code because some items where no longer working with DSM7.0.
In addition to that I decided I wanted to have the UPS data in Domoticz.

So I have added that too.

I use a cheap APC ups type CS350 which is connected to my nas via a usb cable.

My Domoticz system runs of the same UPS, so it is nice to know when a shutdown is going to happen.
(Now a Raspberry Pi 3B+ with an SSD, will become a NUC with an Intel J4105 Celeron.)

Modified the crontab entry, otherwise the script would not run completely (replacing spaces in a string would not work) from cron.
The /bin/bash entry is new here:

Code: Select all

*/5 * * * * /bin/bash /home/pi/domoticz/scripts/nas.sh (= every 5 minutes)
And here the code of nas.sh after modification.
The memory percentage calculation is modified to suit the amount of RAM in my nas. (6144)
I have a DS218+ with 6Gb of RAM installed.

Code: Select all

 #!/bin/bash

PATH='/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin'

 # Settings

 NASIP="192.168.1.?"             # NAS IP Address
 PASSWORD="?????"         # SNMP Password
 DOMO_IP="192.168.1.?"           # Domoticz IP Address
 DOMO_PORT="8080"            # Domoticz Port
 NAS_IDX="280"                 # NAS Switch IDX
 NAS_HD1_TEMP_IDX="277"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="278"        # NAS HD2 Temp IDX
 NAS_HD_SPACE_IDX="279"        # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="276"   # NAS HD Space IDX in %
 NAS_CPU_IDX="274"             # NAS CPU IDX
 NAS_MEM_IDX="275"             # NAS MEM IDX
 NAS_UPS_MANUFACTURER_IDX="515"     # NAS UPS MANUFACTURER IDX
 NAS_UPS_MODEL_IDX="516"            # NAS UPS MODEL IDX
 NAS_UPS_STATUS_IDX="517"           # NAS UPS STATUS IDX
 NAS_UPS_CHARGE_VALUE_IDX="514"     # NAS UPS CHARGE VALUE 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.55`  # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ was 51
        HDTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # 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.55`  # 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.55` # 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.55`  # 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"
 
	# 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) / 6144))
        # 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"
 
    # UPS Charge value
    UPSchargevalue=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.3.1.1.0`
             # Send data
             curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_CHARGE_VALUE_IDX&nvalue=0&svalue=$UPSchargevalue"
 
    # UPS Status
    UPSstatus=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.2.1.0`
        TmpSts="${UPSstatus%\"}"
        UPSstatus="${TmpSts#\"}"
        echo $UPSstatus
           case $UPSstatus in
               OL) UPSstatTxt="ONLINE"
                   ;;
               OB) UPSstatTxt="ON%20BATTERY"
                   ;;
               LB) UPSstatTxt="LOW%20BATTERY"
                   ;;
               HB) UPSstatTxt="HIGH%20BATTERY"
                   ;;
               RB) UPSstatTxt="REPLACE%20BATTERY"
                   ;;
               CHRG) UPSstatTxt="CHARGING"
                   ;;
               DISCHRG) UPSstatTxt="DISCHARGING"
                   ;;
               BYPASS) UPSstatTxt="BYPASS"
                   ;;
               CAL) UPSstatTxt="CALIBRATION"
                   ;;
               OFF) UPSstatTxt="OFF"
                   ;;
               OVER) UPSstatTxt="OVERLOAD"
                   ;;
               TRIM) UPSstatTxt="SMARTTRIM"
                   ;;
               BOOST) UPSstatTxt="BOOST"
                   ;;
               FSD) UPSstatTxt="FORCE%20SHUTDOWN"
                   ;;
               *) UPSstatTxt="STATUS%20UNKNOWN"
                   ;;
                esac
                # Send data
                curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_STATUS_IDX&nvalue=0&svalue=$UPSstatTxt"
                echo $UPSstatTxt
    # UPS Manufacturer
    UPSmanufacturer=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.1.2.0`
        TmpMfg1="${UPSmanufacturer%\"}"
        TmpMfg2="${TmpMfg1#\"}"
        TmpMfg3="${TmpMfg2// /%20}"
        UPSmanufacturerTxt=$TmpMfg3
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_MANUFACTURER_IDX&nvalue=0&svalue=$UPSmanufacturerTxt"
        echo $UPSmanufacturerTxt 
    # UPS Model
    UPSmodel=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.1.1.0`
        TmpMod1="${UPSmodel%\"}"
        TmpMod2="${TmpMod1#\"}"
        TmpMod3="${TmpMod2// /%20}"
        UPSmodelTxt=$TmpMod3
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_MODEL_IDX&nvalue=0&svalue=$UPSmodelTxt"
        echo $UPSmodelTxt 
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.55`  # 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.55` # 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.55`  # 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.55` # 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.55`  # 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"
 
	# 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 %
	MemTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP .1.3.6.1.4.1.2021.4.5.0`
    MemTotalinMo=$(($MemTotal / 1024))	
	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) / MemTotalinMo))
        # 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"
 
    # UPS Charge value
    UPSchargevalue=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.3.1.1.0`
             # Send data
             curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_CHARGE_VALUE_IDX&nvalue=0&svalue=$UPSchargevalue"
 
    # UPS Status
    UPSstatus=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.2.1.0`
        TmpSts="${UPSstatus%\"}"
        UPSstatus="${TmpSts#\"}"
		echo $UPSstatus
           case $UPSstatus in
               OL) UPSstatTxt="ONLINE"
                   ;;
               OB) UPSstatTxt="ON%20BATTERY"
                   ;;
               LB) UPSstatTxt="LOW%20BATTERY"
                   ;;
               HB) UPSstatTxt="HIGH%20BATTERY"
                   ;;
               RB) UPSstatTxt="REPLACE%20BATTERY"
                   ;;
               CHRG) UPSstatTxt="CHARGING"
                   ;;
               DISCHRG) UPSstatTxt="DISCHARGING"
                   ;;
               BYPASS) UPSstatTxt="BYPASS"
                   ;;
               CAL) UPSstatTxt="CALIBRATION"
                   ;;
               OFF) UPSstatTxt="OFF"
                   ;;
               OVER) UPSstatTxt="OVERLOAD"
                   ;;
               TRIM) UPSstatTxt="SMARTTRIM"
                   ;;
               BOOST) UPSstatTxt="BOOST"
                   ;;
               FSD) UPSstatTxt="FORCE%20SHUTDOWN"
                   ;;
               *) UPSstatTxt="STATUS%20UNKNOWN"
                   ;;
                esac
                # Send data
                curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_STATUS_IDX&nvalue=0&svalue=$UPSstatTxt"
                echo $UPSstatTxt 
    # UPS Manufacturer
    UPSmanufacturer=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.1.2.0`
        TmpMfg1="${UPSmanufacturer%\"}"
        TmpMfg2="${TmpMfg1#\"}"
        TmpMfg3="${TmpMfg2// /%20}"
        UPSmanufacturerTxt=$TmpMfg3
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_MANUFACTURER_IDX&nvalue=0&svalue=$UPSmanufacturerTxt"
        echo $UPSmanufacturerTxt 
    # UPS Model
    UPSmodel=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.4.1.1.0`
        TmpMod1="${UPSmodel%\"}"
        TmpMod2="${TmpMod1#\"}"
        TmpMod3="${TmpMod2// /%20}"
        UPSmodelTxt=$TmpMod3
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_UPS_MODEL_IDX&nvalue=0&svalue=$UPSmodelTxt"
        echo $UPSmodelTxt   
      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
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: HowTo: monitor Synology NAS

Post by EddyG »

For what purpose do you use 'UPSmanufacturer' and UPSmodel in Domoticz? Does that change overtime?
RobbieT1974
Posts: 3
Joined: Saturday 06 February 2016 21:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by RobbieT1974 »

You are right, those (manufacturer and model) serve no purpose at all.

Looking back at it, the only thing the ups data provides for me is info in the Domoticz screen.
For switching off the server when the ups shuts down I use nut.

Could have used nut to get the ups info in Domoticz as well.
averter
Posts: 39
Joined: Thursday 24 February 2022 8:32
Target OS: Linux
Domoticz version: 2024.4
Contact:

Re: HowTo: monitor Synology NAS

Post by averter »

This setup works fairly well and many of the tips written in the forum are useful. However, the disk temperatures are oscillating between 0 and 31ºC for some reason
chart.png
chart.png (277.24 KiB) Viewed 1153 times
I'm on DSM7 and have been using the following script

Code: Select all

#!/bin/bash

# Settings

NASIP="192.168.1.150"            # NAS IP Address
PASSWORD="xxxxxxxxxxxxxxxxxxxxx" # SNMP Password
DOMO_IP="192.168.1.151"          # Domoticz IP Address
DOMO_PORT="8080"		# Domoticz Port
NAS_IDX="60"			# NAS Switch IDX
NAS_HD1_TEMP_IDX="61"		# NAS HD1 Temp IDX
NAS_HD2_TEMP_IDX="62"		# NAS HD2 Temp IDX
NAS_HD_SPACE_IDX="66"		# NAS HD Space IDX in Go
NAS_HD_SPACE_PERC_IDX="65"	# NAS HD Space IDX in %
NAS_CPU_IDX="63"		# NAS CPU IDX
NAS_MEM_IDX="64"		# NAS MEM IDX


# Check if NAS in online 

PINGTIME=`ping -c 1 -q $NASIP | awk -F"/" '{print $5}' | xargs`

echo $PINGTIME
if expr "$PINGTIME" '>' 0
then
  curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "On" > /dev/null

      if [ $? -eq 0 ] ; then
       echo "NAS already ON"
      
       # Temperature HD1
       HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
       # Send data
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"

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

       # Free space volume in Go
       HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
    	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 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=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
       # Send data
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"

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

       # Free space volume in Go
       HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
    	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 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
Does anyone has stumbled upon the same issue? Thanks in advance.
averter
Posts: 39
Joined: Thursday 24 February 2022 8:32
Target OS: Linux
Domoticz version: 2024.4
Contact:

Re: HowTo: monitor Synology NAS

Post by averter »

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

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

The script in line 43 and 44 is :

Code: Select all

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

NB: When running a single command like :
HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.41`
I sometimes get a result but not often (time out)
My issue is exactly the same as yours. I've changed my cronjob to output the log

Code: Select all

*/5 * * * * /home/pi/domoticz/scripts/nas.sh 1> /dev/null 2> /home/pi/some_job.err
and every 25 minutes or so the NAS makes some unusual noise, the temperature values return zero, and the contents of the some_job.err file becomes

Code: Select all

Timeout: No Response from 192.168.1.5
Timeout: No Response from 192.168.1.5
Timeout: No Response from 192.168.1.5
Timeout: No Response from 192.168.1.5
/home/pi/domoticz/scripts/nas.sh: line 44: ( - 201822598) *  / 1024 / 1024 / 1024: syntax error: operand expected (error token is "/ 1024 / 1024 / 1024")
NOTE: the code runs fine by hand and most of times. It is an occasional, but rather predictable (every 25 minutes) event, so maybe the way to address this is with a conditional statement? I've also run some tests and the timelapse of pinging does not give it away either: it is fairly constant at 600ms.
My DSM is version 7.2 and the nas.sh code that I'm using is

Code: Select all

#!/bin/bash

# Settings

NASIP="192.168.1.5"             # NAS IP Address
PASSWORD="????????????????????" # SNMP Password
DOMO_IP="192.168.1.162"         # Domoticz IP Address
DOMO_PORT="8080"		# Domoticz Port
NAS_IDX="60"			# NAS Switch IDX
NAS_HD1_TEMP_IDX="61"		# NAS HD1 Temp IDX
NAS_HD2_TEMP_IDX="62"		# NAS HD2 Temp IDX
NAS_HD_SPACE_IDX="66"		# NAS HD Space IDX in Go
NAS_HD_SPACE_PERC_IDX="65"	# NAS HD Space IDX in %
NAS_CPU_IDX="63"		# NAS CPU IDX
NAS_MEM_IDX="64"		# 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=command&param=getdevices&rid=$NAS_IDX" | grep "Status" | grep "On" > /dev/null
    
    if [ $? -eq 0 ] ; then
       echo "NAS already ON"
	
       # Temperature HD1
       HDtemp1=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
       # Send data
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"

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

       # Free space volume in Go
       HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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 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=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.0`
       # Send data
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"

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

       # Free space volume in Go
       HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       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 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=command&param=getdevices&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
averter
Posts: 39
Joined: Thursday 24 February 2022 8:32
Target OS: Linux
Domoticz version: 2024.4
Contact:

Re: HowTo: monitor Synology NAS

Post by averter »

I've made a few extra tests and based on this webpage
https://www.baeldung.com/linux/snmpwalk ... out-values
one can set timeout values to improve the success rate. After a few tests I was able to avoid any timeout errors, by setting the interval at 5 seconds with 3 retries. However, the disk temperature values still return zero and the NAS does some clicking noise at every 25 minutes. If I comment out the snmpwalk commands for temperature this does not happen anymore, and I've confirmed that it happens for any of my two disks. I've checked that my commands are correct using

Code: Select all

snmpwalk -v 2c -c"mypassword" 192.168.1.5 1.3.6.1.4.1.6574.2.1.1.6
which returns

Code: Select all

SYNOLOGY-DISK-MIB::diskTemperature.0 = INTEGER: 30
SYNOLOGY-DISK-MIB::diskTemperature.1 = INTEGER: 31
and so I am not sure what else to do...(head scratching). There is a possibly related post in synology's forum
https://community.synology.com/enu/forum/17/post/82156
Sjaak
Posts: 2
Joined: Wednesday 18 September 2024 19:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Sjaak »

Hi, I used the monitor script for years to monitor my NAS disk usage, but I recently upgraded to DSM 7.1.1 and now it doesn't work any more.

Does anyone know the correct OID for DSM 7.1.1?

Code: Select all

       # Free space volume in Go
       HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.55` # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.55`  # Change OID to .38 on DSM 5.1, .41 on DSM 6.0, 42 on DSM 6.1, 44 for DSM 6.2.3
       HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
.55 also doesn't work
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: HowTo: monitor Synology NAS

Post by waltervl »

Perhaps this tip will help you to find the correct OID https://domoticz.com/forum/viewtopic.ph ... 78#p279178
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Sjaak
Posts: 2
Joined: Wednesday 18 September 2024 19:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Sjaak »

Thanx, found it:

Code: Select all

pi@domoticz:~/domoticz/scripts $ snmpget -c xxxxxx -v2c -O qv xxx.xxx.xxx.xxx 1.3.6.1.2.1.25.2.3.1.3.48
"/volume1"
With 48 everything works again!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest