Re: HowTo: monitor Synology NAS
Posted: Saturday 21 October 2017 12:42
Code: Select all
ping: '''192.168.1.68''': Name or service not known
0
NAS OFF
Code: Select all
NASIP="'''192.168.1.68'''" # NAS IP Address
PASSWORD="'''mypassword'''" # SNMP Password
DOMO_IP="'''192.168.1.110'''" # Domoticz IP Address
DOMO_PORT="'''8080'''" # Domoticz Port
NAS_IDX="'''1100'''" # Virtual switch NAS STATUS
CPU_TEMP_IDX="'''1101'''" # Virtual temerature sensor IDX$
HD1_TEMP_IDX="'''1102'''" # Virtual temerature sensor IDX$
HD2_TEMP_IDX="'''1103'''" # Virtual temerature sensor IDX$
HD_REMAIN_IDX="'''1104'''" # Virtual temerature sensor IDX HD REMA$
DOMO_LOGIN="mylogin"
DOMO_PASS="mypassword"
Code: Select all
snmpget -v 2c -c mysnmppassword -O qv 192.168.1.68 1.3.6.1.4.1.24681.1.2.11.1.3.1
upIDANIT wrote: ↑Sunday 29 October 2017 9:49Code: Select all
ping: '''192.168.1.68''': Name or service not known 0 NAS OFF
QNAP TS-251. What I did wrong? NAS is working of course... 24/7.Code: Select all
NASIP="'''192.168.1.68'''" # NAS IP Address PASSWORD="'''mypassword'''" # SNMP Password DOMO_IP="'''192.168.1.110'''" # Domoticz IP Address DOMO_PORT="'''8080'''" # Domoticz Port NAS_IDX="'''1100'''" # Virtual switch NAS STATUS CPU_TEMP_IDX="'''1101'''" # Virtual temerature sensor IDX$ HD1_TEMP_IDX="'''1102'''" # Virtual temerature sensor IDX$ HD2_TEMP_IDX="'''1103'''" # Virtual temerature sensor IDX$ HD_REMAIN_IDX="'''1104'''" # Virtual temerature sensor IDX HD REMA$ DOMO_LOGIN="mylogin" DOMO_PASS="mypassword"
When I didI get "40 C/104 F" so snmp is working.Code: Select all
snmpget -v 2c -c mysnmppassword -O qv 192.168.1.68 1.3.6.1.4.1.24681.1.2.11.1.3.1
I had the same. I did some Internet searching and found that the OID needs to be .42 for DSM 6.1., which works on my Synology. I updated the script on the Domoticz wiki.JacEngels wrote: ↑Sunday 24 December 2017 15:04 I'm setting this up for my DS212j Synology NAS running on DSM 6.1.4-15217 Update 5.
Both temperature checks are working but the disk checks don't work: there is nothing to find for the OID! I used .41 and several others.
Which OID do I use to get the script working?
Thank you for the update. I've figured that out some time ago but forgot to mention it here!schoutene wrote: ↑Thursday 19 April 2018 10:04I had the same. I did some Internet searching and found that the OID needs to be .42 for DSM 6.1., which works on my Synology. I updated the script on the Domoticz wiki.JacEngels wrote: ↑Sunday 24 December 2017 15:04 I'm setting this up for my DS212j Synology NAS running on DSM 6.1.4-15217 Update 5.
Both temperature checks are working but the disk checks don't work: there is nothing to find for the OID! I used .41 and several others.
Which OID do I use to get the script working?
Code: Select all
#!/bin/bash
# Settings
NASIP="192.168.0.10" # NAS IP Address
PASSWORD="<<PASSWORD>>" # SNMP Password
DOMO_IP="192.168.0.11" # Domoticz IP Address
DOMO_PORT="8080" # Domoticz Port
NAS_IDX="160" # NAS Switch IDX
NAS_HD1_TEMP_IDX="161" # NAS HD1 Temp IDX
NAS_HD2_TEMP_IDX="162" # NAS HD1 Temp IDX
NAS_HD3_TEMP_IDX="163" # NAS HD2 Temp IDX
NAS_HD4_TEMP_IDX="164" # NAS HD1 Temp IDX
#NAS_HD5_TEMP_IDX="55" # NAS HD1 Temp IDX
#NAS_HD6_TEMP_IDX="56" # NAS HD1 Temp IDX
#NAS_HD7_TEMP_IDX="57" # NAS HD1 Temp IDX
#NAS_HD8_TEMP_IDX="58" # NAS HD1 Temp IDX
NAS_HD_SPACE_IDX="168" # NAS HD Space IDX in Go
#NAS_HD_SPACE_PERC_IDX="63" # NAS HD Space IDX in %
NAS_CPU_IDX="165" # NAS CPU IDX
NAS_MEM_IDX="166" # NAS MEM IDX
NAS_CPU_TEMP="169" # NAS CPU Temperature
# 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 CPU
CPUtemp=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_CPU_TEMP&nvalue=0&svalue=$CPUtemp"
# 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¶m=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¶m=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
# Temperature HD3
HDtemp3=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.2`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD3_TEMP_IDX&nvalue=0&svalue=$HDtemp3"
# Temperature HD4
HDtemp4=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.3`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD4_TEMP_IDX&nvalue=0&svalue=$HDtemp4"
# Temperature HD5
HDtemp5=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.4`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD5_TEMP_IDX&nvalue=0&svalue=$HDtemp5"
# Temperature HD6
HDtemp6=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.5`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD6_TEMP_IDX&nvalue=0&svalue=$HDtemp6"
# Temperature HD7
HDtemp7=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.6`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD7_TEMP_IDX&nvalue=0&svalue=$HDtemp7"
# Temperature HD8
# HDtemp8=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.7`
# Send data
# curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_HD8_TEMP_IDX&nvalue=0&svalue=$HDtemp8"
# Free space volume in Go
HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qvU $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+ or .52 in my case
HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qvU $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+ or .52 in my case
HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qvU $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+ or .52 in my case
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"
# Free space volume in percent
HDTotal=`snmpwalk -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+ or .52 in my case
HDUsed=`snmpwalk -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+ or .52 in my case
HDFreePerc=$((($HDUsed * 100) / $HDTotal))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=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¶m=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
# Free Memory Available in %
MemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qvU $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¶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_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$NAS_IDX&switchcmd=On"
# Temperature CPU
CPUtemp=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.1.2`
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$NAS_CPU_TEMP&nvalue=0&svalue=$CPUtemp"
# 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¶m=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¶m=udevice&idx=$NAS_HD2_TEMP_IDX&nvalue=0&svalue=$HDtemp2"
# Temperature HD3
HDtemp3=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.2`
# 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=$HDtemp3"
# Temperature HD4
HDtemp4=`snmpwalk -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.6574.2.1.1.6.3`
# 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=$HDtemp4"
# Free space volume in Go
HDUnit=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.4.42` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
HDTotal=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.5.42` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
HDUsed=`snmpwalk -v 2c -c $PASSWORD -O qvU $NASIP 1.3.6.1.2.1.25.2.3.1.6.42` # Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .52 in my case
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"
# Free space volume in percent
HDTotal=`snmpwalk -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+ or .52 in my case
HDUsed=`snmpwalk -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+ or .52 in my case
HDFreePerc=$((($HDUsed * 100) / $HDTotal))
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=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¶m=udevice&idx=$NAS_CPU_IDX&nvalue=0&svalue=$CpuUse"
# Free Memory Available in %
MemAvailable=`snmpwalk -v 2c -c $PASSWORD -O qvU $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¶m=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¶m=switchlight&idx=$NAS_IDX&switchcmd=Off"
fi
fi
./nas.sh
0.345
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
pi@domo-server:~/domoticz/scripts $ sudo nano nas.sh
pi@domo-server:~/domoticz/scripts $ ./nas.sh
0.376
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>HTTP/1.1 400 Bad Request
Content-Length: 89
Content-Type: text/html
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>./nas.sh: line 86: (No Such Instance currently exists at this OID - No Such Instance currently exists at this OID) * No Such Instance currently exists at this OID / 1024 / 1024 / 1024: missing `)' (error token is "Such Instance currently exists at this OID - No Such Instance currently exists at this OID) * No Such Instance currently exists at this OID / 1024 / 1024 / 1024")
0.333
1
NAS already ON
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
pi@domo-server:~/domoticz/scripts $
Code: Select all
snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.4.36
4096
snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.5.36
234011
snmpget -v 2c -c ###### -O qv 192.168.1.# 1.3.6.1.2.1.25.2.3.1.6.36
265
The percentage calculation is wrong, as it only uses the available memory without getting total amount of memory. So how do you calculate a percentage with only one value .DaWauZ wrote: ↑Tuesday 12 March 2019 8:44But there is something wrong with the memory, it is giving 500% and the harddisk counter is giving only 1 result, I dont know if thats right.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))
Code: Select all
MemTotal=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.5.0`
MemAvailable=`snmpget -v 2c -c $PASSWORD -O qv $NASIP 1.3.6.1.4.1.2021.4.6.0`
MemFreepercent=$(($MemAvailable*100 / $MemTotal))
Code: Select all
Taak: Check NAS status
Starttijd: Sat, 11 Apr 2020 10:28:29 GMT
Stoptijd: Sat, 11 Apr 2020 10:28:31 GMT
Huidige status: 1 (Onderbroken)
Standaard uitvoer/fout:
0.138
1
NAS ON
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: DMZSID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
# 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¶m=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¶m=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
.41 works for me! DSM6.2multinet 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¶m=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¶m=udevice&idx=$NAS_HD_SPACE_PERC_IDX&nvalue=0&svalue=$HDFreePerc"
Thank you