HowTo: monitor Synology NAS

Compatibility (hardware, devices and OS)
MAidEN
Posts: 48
Joined: Sunday 07 December 2014 16:14
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by MAidEN » Thursday 18 December 2014 23:00

Yes we can add this tip on Wiki. How do that?

@zaadstra : I think if you monitor your synology (cpu, mem, temp, ping) from your domoticz, synology can't be sleep mode...

Anybody has a idea for my problem with HDD space monitor? :|

Luuc_a
Posts: 65
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: HowTo: monitor Synology NAS

Post by Luuc_a » Friday 19 December 2014 11:51

MAidEN wrote:
Image
I have the solution for the Disk monitoring of my NAS with the screenshot above. The OID of Volume1 is 38.

The code for Free Space in GB

Code: Select all

 # Free space volume1 (GB)
                                HDUnit=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.4.38`
                                HDTotal=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
                                HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.38`
                                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"
The code for Free Space in Percent

Code: Select all

 # Free space volume1 (Percentage)
                                HDTotal=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
                                HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.38`
                                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"

roblom
Posts: 554
Joined: Wednesday 26 February 2014 16:28
Target OS: Raspberry Pi
Domoticz version:
Location: the Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by roblom » Friday 19 December 2014 15:35

The above seems to work indeed.

roblom
Posts: 554
Joined: Wednesday 26 February 2014 16:28
Target OS: Raspberry Pi
Domoticz version:
Location: the Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by roblom » Friday 19 December 2014 15:36

MAidEN wrote:Yes we can add this tip on Wiki. How do that?
Just login here and you can edit the wiki page.

MAidEN
Posts: 48
Joined: Sunday 07 December 2014 16:14
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by MAidEN » Saturday 20 December 2014 9:34

Luuc_a wrote: I have the solution for the Disk monitoring of my NAS with the screenshot above. The OID of Volume1 is 38.

The code for Free Space in GB

Code: Select all

 # Free space volume1 (GB)
                                HDUnit=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.4.38`
                                HDTotal=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
                                HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.38`
                                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"
The code for Free Space in Percent

Code: Select all

 # Free space volume1 (Percentage)
                                HDTotal=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
                                HDUsed=`snmpget -c $PASSWORD -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.6.38`
                                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"
Thanks is ok now, but I don't understand why I have a value "7" on title :

Image

The good value is 5901 Go.

The percent monitor is ok.

MAidEN
Posts: 48
Joined: Sunday 07 December 2014 16:14
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by MAidEN » Saturday 20 December 2014 9:48

decrxgarage wrote:
MAidEN wrote:Yes we can add this tip on Wiki. How do that?
Just login here and you can edit the wiki page.
It's good I had update the wiki page with this news :

Cpu monitor
Memory monitor
Disk usage in %
And I add a coment with new OID for disk usage to DSM 5.1 (.38)

SwordFish
Posts: 268
Joined: Sunday 14 December 2014 13:28
Target OS: Raspberry Pi
Domoticz version: V3.7207
Location: Helmond, netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by SwordFish » Monday 22 December 2014 14:00

Hello, i'm new with this, using domoticz for a few days know.
So I have questing, how do i make a virtual Switch en the virtual temperature sensors?
I have the script running on the Pi. But when I test it i get this.
Attachments
Knipsel.PNG
Knipsel.PNG (26.79 KiB) Viewed 2614 times

roblom
Posts: 554
Joined: Wednesday 26 February 2014 16:28
Target OS: Raspberry Pi
Domoticz version:
Location: the Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by roblom » Monday 22 December 2014 14:59

SwordFish wrote:So I have questing, how do i make a virtual Switch en the virtual temperature sensors?
  • Go to "Hardware"
  • Choose for type "Dummy (does nothing, use for virtual switches only"
  • Give it a name, like "NAS"
  • Click on "add"
  • Now in the device list there is a new hardware created. In this line of "NAS" is a button with "create virtual sensors"
  • When you click on this, choose what kind of device you need. For the NAS Script you need a counter for example.
  • Click "ok"
  • Now in the devices tab there is a new device created. Click on the green arrow behind it and give it a name.
  • Now there is a device created on the tab "Several" (or other if you choose a different type of device).
Look in the device tab in the column IDX for the IDX number of the device, then change this in the NAS script. Create more devices if you need more.

User avatar
sincze
Posts: 686
Joined: Monday 02 June 2014 22:46
Target OS: Linux
Domoticz version: 3.7546
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by sincze » Monday 22 December 2014 15:23

Excellent . ;-)
Running Domoticz since 2013 with Cubietruck
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

SwordFish
Posts: 268
Joined: Sunday 14 December 2014 13:28
Target OS: Raspberry Pi
Domoticz version: V3.7207
Location: Helmond, netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by SwordFish » Monday 22 December 2014 15:43

decrxgarage wrote:
SwordFish wrote:So I have questing, how do i make a virtual Switch en the virtual temperature sensors?
  • Go to "Hardware"
  • Choose for type "Dummy (does nothing, use for virtual switches only"
  • Give it a name, like "NAS"
  • Click on "add"
  • Now in the device list there is a new hardware created. In this line of "NAS" is a button with "create virtual sensors"
  • When you click on this, choose what kind of device you need. For the NAS Script you need a counter for example.
  • Click "ok"
  • Now in the devices tab there is a new device created. Click on the green arrow behind it and give it a name.
  • Now there is a device created on the tab "Several" (or other if you choose a different type of device).
Look in the device tab in the column IDX for the IDX number of the device, then change this in the NAS script. Create more devices if you need more.
Thanks for the quick reply. I will give it a try

SwordFish
Posts: 268
Joined: Sunday 14 December 2014 13:28
Target OS: Raspberry Pi
Domoticz version: V3.7207
Location: Helmond, netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by SwordFish » Monday 22 December 2014 16:57

I've managed to get the virtual switches but when i test the script i'll still get this?
Attachments
Knipsel.PNG
Knipsel.PNG (26.79 KiB) Viewed 2620 times

roblom
Posts: 554
Joined: Wednesday 26 February 2014 16:28
Target OS: Raspberry Pi
Domoticz version:
Location: the Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by roblom » Monday 22 December 2014 17:22

Did you make the script executable:

Code: Select all

sudo chmod +x nas.sh
Is this a windows machine?

SwordFish
Posts: 268
Joined: Sunday 14 December 2014 13:28
Target OS: Raspberry Pi
Domoticz version: V3.7207
Location: Helmond, netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by SwordFish » Sunday 28 December 2014 16:31

I've managed to get it work. But there are a few things that i don't get to work.
- Memory use is allways 1%?
- Its seems that the crontab is not working, because it doesn't update?
But when I run nas.sh in the terminal its working. ( I've another crontab running what is working)
- On dashboard the free HD space doesn't show the right free space.
running sh.PNG
running nas.sh
running sh.PNG (24.79 KiB) Viewed 2576 times
dashboard.PNG
dashboard
dashboard.PNG (88.58 KiB) Viewed 2576 times
crontab.PNG
crontab
crontab.PNG (4.01 KiB) Viewed 2576 times
#!/bin/bash

# Settings

NASIP="192.168.1.11" # NAS IP Address
PASSWORD="public" # SNMP Password
DOMO_IP="192.168.1.216" # Domoticz IP Address
DOMO_PORT="8080" # Domoticz Port
NAS_IDX="28" # NAS Switch IDX
NAS_HD1_TEMP_IDX="29" # NAS HD1 Temp IDX
NAS_HD_SPACE_IDX="30" # NAS HD Space IDX in Go
NAS_CPU_IDX="35" # NAS CPU IDX
NAS_MEM_IDX="36" # 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"

# 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
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
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
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
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
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"

# 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
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
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
HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024 / 1000))

# 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
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
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

roblom
Posts: 554
Joined: Wednesday 26 February 2014 16:28
Target OS: Raspberry Pi
Domoticz version:
Location: the Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by roblom » Sunday 28 December 2014 19:49

When you paste some code here it's better to use the code tags.

I think the problem is in your cronjob, the "(= every 5 minutes)" is not allowed because it don't understands what it means so it gives an error.

SwordFish
Posts: 268
Joined: Sunday 14 December 2014 13:28
Target OS: Raspberry Pi
Domoticz version: V3.7207
Location: Helmond, netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by SwordFish » Monday 29 December 2014 10:55

Thanks, will remove that.
Sorry for not using the code tags, didn't know .

JacquesMulders
Posts: 56
Joined: Saturday 03 January 2015 23:05
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by JacquesMulders » Saturday 03 January 2015 23:12

I was having the same issue as Swordfish, because is have a username and password installed.
i've edit the script (for synology) to:

Code: Select all

 #!/bin/bash
 
 # Settings
 
 NASIP="0.0.0.0"             # NAS IP Address
 PASSWORD="password"         # SNMP Password
 DOMO_IP="0.0.0.0"           # Domoticz IP Address
 DOMO_PORT="0000"            # Domoticz Port
 DOMO_PASS="PASSWORD"        # Domoticz password
 DOMO_USER="USERNAME"           # Domoticz user
 NAS_IDX="1"                 # NAS Switch IDX
 NAS_HD1_TEMP_IDX="2"        # NAS HD1 Temp IDX
 NAS_HD2_TEMP_IDX="3"        # NAS HD2 Temp IDX
 NAS_HD_SPACE_IDX="4"        # NAS HD Space IDX in Go
 NAS_HD_SPACE_PERC_IDX="5"   # NAS HD Space IDX in %
 NAS_CPU_IDX="6"             # NAS CPU IDX
 NAS_MEM_IDX="7"             # 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_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$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
        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
        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
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_USER:[email protected]$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
        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
     	HDFreePerc=$((($HDUsed * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$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
        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
        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
        HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
 
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_USER:[email protected]$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
        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
     	HDFreePerc=$((($HDUsed * 100) / $HDTotal))
        # Send data
        curl -s -i -H "Accept: application/json" "http://$DOMO_USER:[email protected]$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_USER:[email protected]$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_USER:[email protected]$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
 
      fi
 
 else
        curl -s "http://$DOMO_USER:[email protected]$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_USER:[email protected]$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=Off"
        fi
 fi

Jan
Posts: 17
Joined: Wednesday 05 February 2014 8:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by Jan » Friday 09 January 2015 13:24

In the script something is wrong. To calculate the free memory percent, the MemAvailable will be divided by 1024. For a synology with 1024MB RAM, this is right. But not for a synology with 512MB RAM. Maybe the script can be updated!

The old script contains:

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))
   # Send data
   curl -s -i -H "Accept: application/json" "http://$DOMO_USER:[email protected]$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
Maybe this can be the solution:

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`
	MemTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
	MemUsepercent=$((($MemAvailable * 100) / MemTotal))
	# Send data
	curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
When I look in my DSM of my Synology the percent will be 48%. The script shows 3%. I don't know why both values are different. Hopefully somebody can explain this?
Last edited by Jan on Friday 09 January 2015 13:38, edited 1 time in total.
My hardware:
- Raspberry Pi
- Rfxtrx433 transceiver
- RaZberry
- Nuon Smart Plug 6 (2x)
- Nuon Smart Plug (5x)
- Fibaro Universal Sensor
- Fibaro Smoke Sensor
- Aeon Door Sensor
- Bluetooth dongle

MAidEN
Posts: 48
Joined: Sunday 07 December 2014 16:14
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by MAidEN » Sunday 01 February 2015 21:13

i Jan,

Is right, we have a problem with this formul.

On my Synology i have that :

Image

On Domoticz :

Image

I don't understand how synology obtain 33% memory use...is egal to 337,92 Mo. :roll:

On my screen memory free (libre) = 106 Mb (10,5%) !

You have a same problem ?

globalassist
Posts: 27
Joined: Monday 09 December 2013 17:51
Target OS: Windows
Domoticz version: Latest
Location: Netherlands
Contact:

Re: HowTo: monitor Synology NAS

Post by globalassist » Sunday 01 February 2015 23:09

Is there a way to monitor this in a windows-installation of Domoticz?

MAidEN
Posts: 48
Joined: Sunday 07 December 2014 16:14
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor Synology NAS

Post by MAidEN » Monday 02 February 2015 8:44

The script is for linux installation of domoticz only : http://www.domoticz.com/wiki/NAS_Monitoring

Post Reply

Who is online

Users browsing this forum: alanlsmith and 2 guests