NAS Monitoring

From Domoticz
Jump to: navigation, search

NAS (Network Attached Storage) Monitoring via SNMP

This guide describes how to monitor your NAS (Network Attached Storage) via SNMP on your Raspberry Pi.
This guide contains instructions for QNAP, Synology, and NETGEAR

QNAP

This part of the guide describes how to monitor your QNAP NAS via SNMP on your Raspberry Pi.
The script will check if the NAS is on, when the NAS was first Off it will switch a virtual switch to ON and update the temperature sensors.
On the next check (5 min later), if the has is still ON it will leave the switch alone and only update the temperature sensors.

When the NAS is OFF the switch will be switched OFF, and will be left alone till the NAS is back ON.

The script will run every 5 min.

SNMP

For this script to work you need to enable SNMP on your NAS and install SNMP on your Raspberry Pi

Enable SNMP on your QNAP NAS

Follow instruction on: http://docs.qnap.com/nas/en/index.html?snmp_settings.htm

You can use V1/V2
And set a password (Community)

Install SNMP on Raspberry Pi

Log in to you Raspberry Pi and issue:

sudo apt-get install snmpd
sudo apt-get install snmp

Reboot your Pi:

sudo reboot

Check if SNMP is up and running, issue:

snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.4.1.24681.1.2.11.1.3.1

You should get something like this:
"37 C/98 F"

Setting up the script

Create 1 virtual switch and 4 virtual temperature sensors.

The script

nas.sh (in /domoticz/scripts/)

 #!/bin/bash
 
 # Settings
 
 NASIP="'''0.0.0.0'''"		        # NAS IP Address
 PASSWORD="'''SNMP password'''"		# SNMP Password
 DOMO_IP="'''0.0.0.0'''"		# Domoticz IP Address
 DOMO_PORT="'''0000'''"			# Domoticz Port
 NAS_IDX="'''1'''"		        # Virtual switch NAS STATUS
 CPU_TEMP_IDX="'''2'''"			# Virtual temerature sensor IDX NAS CPU
 HD1_TEMP_IDX="'''3'''"			# Virtual temerature sensor IDX HD1
 HD2_TEMP_IDX="'''4'''"			# Virtual temerature sensor IDX HD2
 HD_REMAIN_IDX="'''5'''"		# Virtual temerature sensor IDX HD REMAIN
 
 # 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
         	        # NAS already ON
        					echo "NAS already ON"
 
           	        # Temprature CPU
             			               CPUtemp=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.6.0 | cut -c 2-3`
                        	               # Send data
                                               curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$CPU_TEMP_IDX&nvalue=0&svalue=$CPUtemp"
 
          	        # Temperature HD1
 						HDtemp1=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.11.1.3.1 | cut -c 2-3`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
 			# Temperature HD2
 						HDtemp2=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.11.1.3.2 | cut -c 2-3`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
 
 			# Remaining HD size
 						size=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.17.1.5.1 | cut -c 2-7`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD_REMAIN_IDX&nvalue=0&svalue=$size"
       else
 			# NAS ON
        					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"
 
           	        # Temprature CPU
             			              CPUtemp=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.6.0 | cut -c 2-3`
                        	              # Send data
                                              curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$CPU_TEMP_IDX&nvalue=0&svalue=$CPUtemp"
 
          	        # Temperature HD1
 						HDtemp1=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.11.1.3.1 | cut -c 2-3`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
 
 			# Temperature HD2
 						HDtemp2=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.11.1.3.2 | cut -c 2-3`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
 
 			# Remaining HD size
 						size=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.24681.1.2.17.1.5.1 | cut -c 2-7`
 						# Send data
 						curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD_REMAIN_IDX&nvalue=0&svalue=$size"
         fi
 
 else
        	curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$NAS_IDX" | grep "Status" | grep "Off" > /dev/null
        		# NAS uitgeschakeld
         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

Change the text in bold in "settings" to your own needs.
If you are using a password protected Domoticz, you will need to add 2 extra variables:
DOMO_LOGIN="yourusername"
DOMO_PASS="yourpassword"

The correct url will be http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT instead of http://$DOMO_IP:$DOMO_PORT


Make executable

Make this script executable:

sudo chmod +x nas.sh

Try script

Try the script out:

./nas.sh

Make crontab job

Make a new crontab job:

crontab -e
*/5 * * * * /home/pi/domoticz/scripts/nas.sh (= every 5 minutes)

Optional

You can create a "room" called NAS with al your sensors and switch in it to have it all in place.

Discuss

If you have any questions, please use this forum thread: http://www.domoticz.com/forum/viewtopic.php?f=17&t=1337

Synology

SNMP

For this script to work you need to enable SNMP on your NAS and install SNMP on your Raspberry Pi

Enable SNMP on your Synology NAS

You can find the option in the Configuration Screen, it's a sub-option in "Network Services".

You can use V1/V2
And set a password (Community)

Install SNMP on Raspberry Pi

Log in to you Raspberry Pi and issue:

sudo apt-get install snmpd
sudo apt-get install snmp

Reboot your Pi:

sudo reboot

Check if SNMP is up and running, issue:

snmpget -c PASSWORD -v2c -O qv NASIPADDRESS .1.3.6.1.4.1.6574.1.2.0

You should get something like this:
"40"

Setting up the script

Create:

* 1 dummy hardware to create devices below:
* 1 virtual switch (Nas status on/off)
* 2 virtual temperature sensors (for two disks temp)
* 3 virtual percentage (cpu, ram and disk amount available)
* 1 virtual counter, and edit it to be a counter (available space in Mo)

The script

Remember to modify the OID for a DSM >=5.1 as indicated below:

nas.sh (in /domoticz/scripts/)

 #!/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
 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_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 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.36` # 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.36`  # 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.36` # 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.36`  # 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) / 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 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.36` # 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.36`  # 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.36` # 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.36`  # 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) / 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

Change the text in bold in "settings" to your own needs.

Make executable

Make this script executable:

sudo chmod +x nas.sh

Try script

Try the script out:

./nas.sh

Make crontab job

Make a new crontab job:

crontab -e
*/5 * * * * /home/pi/domoticz/scripts/nas.sh (= every 5 minutes)

Optional

You can create a "room" called NAS with al your sensors and switch in it to have it all in place.

Discuss

If you have any questions, please use this forum thread: http://www.domoticz.com/forum/viewtopic.php?f=17&t=1379

NETGEAR

SNMP

Enable SNMP on your ReadyNAS and install SNMP on your Raspberry Pi

Enable SNMP on your ReadyNAS

To configure SNMP go to the Admin Page:
1. Select System > Settings > Services.
2. Click the SNMP button.
3. Select Enable SNMP.
4. Keep the default setting 'public' or select a PASSWORD for the Community field.
5. Click the Apply button.
Your changes are saved.

For more additional info follow the instructions on http://kb.netgear.com/app/answers/detail/a_id/23105/~/how-do-i-configure-simple-network-management-protocol-(snmp)-monitoring-on-my

Install SNMP on Raspberry Pi

Log in to you Raspberry Pi and issue:

sudo apt-get update
sudo apt-get install snmpd
sudo apt-get install snmp

Reboot your Pi:

sudo reboot

Check if SNMP is up and running, issue (PASSWORD can be 'public'):

snmpget -c PASSWORD -v2c -O qv NASIPADDRESS 1.3.6.1.4.1.4526.22.1.0

This should show the firmware version of the ReadyNas (e.g. "6.5.1").

or

snmpwalk -c PASSWORD -v2c -O qv NASIPADDRESS 1.3.6.1.4.1.4526.22

This shows all the available objects of the NAS manager.

Setting up the script

Create in Domoticz:

* 1 dummy Hardware 'NAS' to create devices below:
* 1 virtual switch (Nas status on/off) 'NAS switch' 
* 5 virtual temperature sensors (for four disks temps and cpu temp) 'NAS Disk 1', 'NAS Disk 2', 'NAS Disk 3', 'NAS Disk 4', and 'NAS CPU'
* 2 virtual counter sensors, and edit it to be a counter (fan speed in RPM and available space in megabytes)
* 1 virtual percentage sensor (disk amount available)

NAS switch panel.png

You can upload the custom NAS icons via the Setup menu in Domoticz. Goto 'More Options' and 'Custom Icons', and select a compressed zip file. Here you can download the zip folder I created: https://drive.google.com/open?id=0B4JIA4XkxWOXN1dEbWRCaE5TZTA.

NAS temps.png

NAS FAN+SPACE.png

The script has been tested for a NETGEAR ReadyNAS RN104 (4 disks).

The script

nas.sh (in /domoticz/scripts/)

#!/bin/bash
 
# Settings
NASIP="192.168.1.247"       # NAS IP Address
PASSWORD="public"           # SNMP Password
DOMO_IP="192.168.1.19"      # Domoticz IP Address
DOMO_PORT="8080"            # Domoticz Port
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_HD3_TEMP_IDX="4"        # NAS HD3 Temp IDX
NAS_HD4_TEMP_IDX="5"        # NAS HD4 Temp IDX
NAS_CPU_TEMP_IDX="6"	    # NAS CPU Temp IDX
NAS_FAN_RPM_IDX="7"	    # NAS FAN RPM IDX		   
NAS_HD_FREE_SPACE_IDX="8"  # NAS Free HD Space IDX in megabytes
NAS_HD_PERC_SPACE_IDX="9"  # NAS Free HD Space IDX in %
 
# 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"
    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"
    fi
 
    # Temperature HD1
    HDtemp1=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.4526.22.3.1.10.1`
    # 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.4526.22.3.1.10.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=$HDtemp2"
 
    # Temperature HD3
    HDtemp3=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.4526.22.3.1.10.3`
    # 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.4526.22.3.1.10.4`
    # 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 CPU
    CPUtemp=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.4526.22.5.1.2.1`
    # Send data
    curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_CPU_TEMP_IDX&nvalue=0&svalue=$CPUtemp"
 
    # FAN RPM
    FANrpm=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.4526.22.4.1.2.1`
    # Send data
    curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_FAN_RPM_IDX&nvalue=0&svalue=$FANrpm"
 
    # Free space volume in megabytes and percentage
    HDTotal=`snmpget -c $PASSWORD -v2c -O qv $NASIP 1.3.6.1.4.1.4526.22.7.1.5.1` 
    HDFree=`snmpget -c $PASSWORD -v2c -O qv $NASIP 1.3.6.1.4.1.4526.22.7.1.6.1`  
    HDFreePerc=$(($HDFree *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_FREE_SPACE_IDX&nvalue=0&svalue=$HDFree"
    curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$NAS_HD_PERC_SPACE_IDX&nvalue=0&svalue=$HDFreePerc"
 
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"
    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

Change the text in the "Settings" section to your own needs (e.g. IP addresses, Device IDXs).

Make executable

Make this script executable:

sudo chmod +x nas.sh

Try script

Try the script out:

./nas.sh

Make crontab job

Make a new crontab job:

crontab -e
*/5 * * * * /home/pi/domoticz/scripts/nas.sh

The script nas.sh will be called every 5 minutes by the cron daemon.