Page 1 of 1
SNMP monitoring Synology NAS
Posted: Sunday 04 September 2016 13:13
by Lichtschilder
hi all,
as a new user of Domoticz i thought it would be nice to integrate monitoring my NAS in Domoticz.
have found the Wiki page:
http://www.domoticz.com/wiki/NAS_Monitoring#Synology
when following this method i get some results but can't seem to be able to get a few meters working.
anyone here who has any tips?
tried to search first but haven't found a tip yet.
currently running:
domoticz: Version: 3.4834
Synology DSM 6.0.2
have tried both changeing the .36 to .38 in the script.. didn't work yet?
working:
on/of switch
temperature 1 and temperature 2
CPU status
not working:
disk counter
disk %
ramp%
any one with a suggestion? help would be appriciated by this newbie
Re: SNMP monitoring Synology NAS
Posted: Saturday 31 December 2016 21:40
by huizi036
curl -s -i -H "Accept: application/json" "
http://192.168.1.248:8080/json.htm?type ... e=$HDtemp1"
when i enter this command i receive ERR please can somebody advise
Version: 3.5877
{
"status" : "ERR"
}
Re: SNMP monitoring Synology NAS
Posted: Sunday 01 January 2017 23:08
by Martijn85
I have this working with two synology systems: DS110j (DSM 5.x) and DS214+ (DSM 5.x)
This is my complete script for the DS110j (one harddisk):
Code: Select all
#!/bin/bash
# Settings
NASIP="x.x.x.x" # NAS IP Address
COMMUNITY="public" # SNMP Community
DOMO_IP="x.x.x.x" # Domoticz IP Address
DOMO_PORT="8080" # Domoticz Port
DOMO_LOGIN="" # Domoticz Username
DOMO_PASS="" # Domoticz Password
DOMO_PASSCODE="xxxx" # Domoticz Light/Switch Protection
NAS_IDX="x" # NAS Switch IDX
NAS_HD1_TEMP_IDX="x" # NAS HD1 Temp IDX
NAS_HD_SPACE_PERC_IDX="x" # NAS HD Space IDX in percent
NAS_HD_SPACE_IDX="x" # NAS HD Space IDX in GB
NAS_CPU_IDX="x" # NAS CPU IDX
NAS_MEM_IDX="x" # 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_LOGIN:$DOMO_PASS@$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 HD
HDtemp1=`snmpwalk -v 2c -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
# Used volume space in percent
HDTotal=`snmpwalk -c $COMMUNITY -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
HDUsed=`snmpwalk -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
# Free space volume in GB
tmpHDUnit=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.38`
HDUnit=${tmpHDUnit%% *}
tmpHDTotal=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.38`
HDTotal=${tmpHDTotal%% *}
tmpHDUsed=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.38`
HDUsed=${tmpHDUsed%% *}
HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
# CPU utilisation
CpuUser=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
CpuSystem=`snmpwalk -v 2c -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
# Free Memory Used in %
tmpMemAvailable=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
MemAvailable=${tmpMemAvailable%% *}
tmpMemtotal=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
Memtotal=${tmpMemtotal%% *}
tmpMemShared=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.13.0`
MemShared=${tmpMemShared%% *}
tmpMemBuffer=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.14.0`
MemBuffer=${tmpMemBuffer%% *}
tmpMemCached=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.15.0`
MemCached=${tmpMemCached%% *}
MemFREE=$(($MemAvailable + $MemShared + $MemBuffer + $MemCached))
MemUsepercent=$(((($Memtotal - $MemFREE) * 100) / $Memtotal))
#// For Available use MemUsepercent=$(((($MemFREE) * 100) / $Memtotal))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
else
echo "NAS ON"
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$NAS_IDX&switchcmd=On&passcode=$DOMO_PASSCODE"
# Temperature HD1
HDtemp1=`snmpwalk -v 2c -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD1_TEMP_IDX&nvalue=0&svalue=$HDtemp1"
# Used volume space in percent
HDTotal=`snmpwalk -c $COMMUNITY -v2c -O qv $NASIP .1.3.6.1.2.1.25.2.3.1.5.38`
HDUsed=`snmpwalk -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
# Free space volume in GB
tmpHDUnit=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.4.38`
HDUnit=${tmpHDUnit%% *}
tmpHDTotal=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.5.38`
HDTotal=${tmpHDTotal%% *}
tmpHDUsed=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.2.1.25.2.3.1.6.38`
HDUsed=${tmpHDUsed%% *}
HDFree=$((($HDTotal - $HDUsed) * $HDUnit / 1024 / 1024 / 1024))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD_SPACE_IDX&nvalue=0&svalue=$HDFree"
# CPU utilisation
CpuUser=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.11.9.0`
CpuSystem=`snmpwalk -v 2c -c $COMMUNITY -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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
# Free Memory Used in %
tmpMemAvailable=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
MemAvailable=${tmpMemAvailable%% *}
tmpMemtotal=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
Memtotal=${tmpMemtotal%% *}
tmpMemShared=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.13.0`
MemShared=${tmpMemShared%% *}
tmpMemBuffer=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.14.0`
MemBuffer=${tmpMemBuffer%% *}
tmpMemCached=`snmpwalk -v 2c -c $COMMUNITY -O qv $NASIP 1.3.6.1.4.1.2021.4.15.0`
MemCached=${tmpMemCached%% *}
MemFREE=$(($MemAvailable + $MemShared + $MemBuffer + $MemCached))
MemUsepercent=$(((($Memtotal - $MemFREE) * 100) / $Memtotal))
#// For Available use MemUsepercent=$(((($MemFREE) * 100) / $Memtotal))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_MEM_IDX&nvalue=0&svalue=$MemUsepercent"
fi
else
curl -s "http://$DOMO_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$NAS_IDX&switchcmd=Off&passcode=$DOMO_PASSCODE"
fi
fi