In addition to the post of mbliek about setting up monitoring for a QNAP NAS, here is the how to for a Synology NAS.
I have used most of the info from his topic (http://www.domoticz.com/forum/viewtopic.php?f=17&t=1337), so the credits are for him

Below you'll find the how-to:
First 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)
Then install SNMP on your RaspberryPi
sudo apt-get install snmpd
sudo apt-get install snmp
Reboot Pi
Check if SNMP is up and running:
Code: Select all
snmpget -c PASSWORD -v2c -O qv NASIPADDRESS .1.3.6.1.4.1.6574.1.2.0
"40"
Every device (I.E. Qnap or Synology has it own implementation layer regarding commands for SNMP, you can use the documentation together with the command line tool snmpwalk to get more information on which codes to use to get a specific output for temperature of used disk space. Below you'll find an example using snmpwalk to get more information:
Code: Select all
snmpwalk -c PASSWORD -v2c -O qv NASIPADDRESS .1.3.6.1.4.1.6574.1.2
Ouput will be someting like:
iso.3.6.1.4.1.6574.1.2.0 = INTEGER: 40
as you can see, you need to use the additional ".0" at the end to get the temperature of your Synology NAS.
And 1 new virtual Switch (NAS)
nas.sh (in domoticz/scripts/)
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
NAS_IDX="16" # NAS Switch IDX
NAS_HD1_TEMP_IDX="14" # NAS HD1 Temp IDX
NAS_HD2_TEMP_IDX="13" # NAS HD2 Temp IDX
NAS_HD_SPACE_IDX="15" # NAS HD1 Temp IDX
# Check if NAS in online
PINGTIME=`ping -c 1 -q $NASIP | awk -F"/" '{print $5}' | xargs`
echo $PINGTIME
if expr "$PINGTIME" '>' 0
then
echo "NAS ON"
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=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¶m=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¶m=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
# Free space volume
HDUnit=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.36`
HDTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.36`
HDUsed=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.36`
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¶m=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
else
echo "NAS OFF"
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$NAS_IDX&switchcmd=Off"
fi
Make this script executable:
sudo chmod +x nas.sh
Try the script out:
./nas.sh
You should get something like:
Code: Select all
0.809
1
NAS ON
HTTP/1.0 200 OK
Content-Length: 51
Content-Type: text/html;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP/1.0 200 OK
Content-Length: 53
Content-Type: text/html;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.0 200 OK
Content-Length: 53
Content-Type: text/html;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.0 200 OK
Content-Length: 53
Content-Type: text/html;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
{
"status" : "OK",
"title" : "Update Device"
}
crontab -e
*/5 * * * * /home/pi/domoticz/scripts/nas.sh (= every 5 minutes)
Forgot to say
I did made a room called NAS and put all my virtual sensors and switch there.
Thats it, any question? Just ask.
As mbliek mentioned in his topic:
This is it for now, if you have any questions let me know. And again the credits go out to the original poster mbliek with his topic:Forgot to say
I did made a room called NAS and put all my virtual sensors and switch there.
http://www.domoticz.com/forum/viewtopic.php?f=17&t=1337
07-02-14 change Changed a hardcoded number into a variable, thanks to BigDog for noticing