HowTo: monitor QNAP NAS
Moderator: leecollings
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
HowTo: monitor QNAP NAS
Anyone interested in monitoring HD temp and Free HD space for QNAP systems?
If so, I would write a how to.
Now in the WIKI: http://www.domoticz.com/wiki/NAS_Monitoring
If so, I would write a how to.
Now in the WIKI: http://www.domoticz.com/wiki/NAS_Monitoring
Op zoek naar een Domoticz Start Set?
-
- Posts: 4
- Joined: Thursday 03 October 2013 10:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Italy
- Contact:
Re: HowTo: monitor QNAP NAS
Yes!! I did a couple of simple sh scripts for generic Linux I can publish as well
-
- Posts: 46
- Joined: Tuesday 10 December 2013 22:27
- Target OS: Linux
- Domoticz version: beta
- Contact:
Re: HowTo: monitor QNAP NAS
Both of you, publish them.
Orange Pi (@ Debian) / MySensors Serial / GPIO / Custom Serial 433 MHz Transmitter (for plug switches and livolo wall switches) / JSON&Bash API scripts
-
- Posts: 4
- Joined: Thursday 03 October 2013 10:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Italy
- Contact:
Re: HowTo: monitor QNAP NAS
Some scripts to monitor the Domoticz process:
#!/bin/sh
# Get Domoticz Process CPU
ps -C domoticz -o %cpu | tail -n +2
#!/bin/sh
# Get Domoticz Process Memory
ps -C domoticz -o %mem | tail -n +2
#!/bin/sh
# Get Domoticz Folder Size
du -shb /home/pi/camillo/domoticz-code | awk -F " " {'print $1'}
#!/bin/sh
# Get Domoticz Process CPU
ps -C domoticz -o %cpu | tail -n +2
#!/bin/sh
# Get Domoticz Process Memory
ps -C domoticz -o %mem | tail -n +2
#!/bin/sh
# Get Domoticz Folder Size
du -shb /home/pi/camillo/domoticz-code | awk -F " " {'print $1'}
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
HowTo: monitor QNAP NAS
Now in the WIKI: http://www.domoticz.com/wiki/NAS_Monitoring
The script is changed, use the one on the WIKI page.
Here is my HowTo
First enable SNMP on your QNAP NAS:
http://docs.qnap.com/nas/en/index.html? ... ttings.htm
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:
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"
Make 3 new virtual Temperature Sensors (NAS HD1, NAS HD2 and NAS Free HD)
And 1 new virtual Switch (NAS)
nas.sh (in domoticz/scripts/)
Change the idx to your own idx
Make this script executable:
sudo chmod +x nas.sh
Try the script out:
./nas.sh
You should get something like:
Make a new crontab job:
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.
The script is changed, use the one on the WIKI page.
Here is my HowTo
First enable SNMP on your QNAP NAS:
http://docs.qnap.com/nas/en/index.html? ... ttings.htm
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:
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"
Make 3 new virtual Temperature Sensors (NAS HD1, NAS HD2 and NAS Free HD)
And 1 new virtual Switch (NAS)
nas.sh (in domoticz/scripts/)
Code: Select all
#!/bin/bash
# Settings
NASIP="00.00.00.00" # NAS IP Address
PASSWORD="password" # SNMP Password
DOMO_IP="00.00.00.00" # Domoticz IP Address
DOMO_PORT="0000" # Domoticz Port
# 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=184&switchcmd=On"
# 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¶m=udevice&idx=181&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¶m=udevice&idx=182&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¶m=udevice&idx=183&nvalue=0&svalue=$size"
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=184&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
2.052
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.
Op zoek naar een Domoticz Start Set?
-
- Posts: 5
- Joined: Wednesday 18 December 2013 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HowTo: monitor QNAP NAS
mbliek thank you for this HOWTO, it's briliant!
As I have some issues with temp. of all my HDDs I start reporting Sys temp.
I've replaced one of yours command with following one:
snmpget -v 2c -c password -O qv NASIP 1.3.6.1.4.1.24681.1.2.6.0
This returns the Sys temperature.
Just FYI if somebody will looking for it.
As I have some issues with temp. of all my HDDs I start reporting Sys temp.
I've replaced one of yours command with following one:
snmpget -v 2c -c password -O qv NASIP 1.3.6.1.4.1.24681.1.2.6.0
This returns the Sys temperature.
Just FYI if somebody will looking for it.
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
I couldn't get my system temp. Will test it when I got home.
Op zoek naar een Domoticz Start Set?
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
Thanks for that Jastrzi. Got my system temp now as well.
Will update my howto later
Will update my howto later
Op zoek naar een Domoticz Start Set?
-
- Posts: 18
- Joined: Saturday 28 December 2013 15:17
- Target OS: Linux
- Domoticz version: 3.8637
- Location: Krommenie
- Contact:
Re: HowTo: monitor QNAP NAS
Great stuff. One question, what is the 'Switch' used for?
- VM running Debian with Domoticz 3.8637
- RFXtrx443E FW1006
- 2 x YouLess FW2.1 Analog energy and gasmeter
- 3 x Impuls, 3 x Action-brand
- 2 x Cresto Temp
- 3 x MiLight with WiFi-box v3
- RFXtrx443E FW1006
- 2 x YouLess FW2.1 Analog energy and gasmeter
- 3 x Impuls, 3 x Action-brand
- 2 x Cresto Temp
- 3 x MiLight with WiFi-box v3
-
- Posts: 5
- Joined: Wednesday 18 December 2013 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HowTo: monitor QNAP NAS
Switch is showing you wheter Qnap is on or off
-
- Posts: 18
- Joined: Saturday 28 December 2013 15:17
- Target OS: Linux
- Domoticz version: 3.8637
- Location: Krommenie
- Contact:
Re: HowTo: monitor QNAP NAS
Oh, just status
Switching off / on your NAS would be not the best thing using a switch
Switching off / on your NAS would be not the best thing using a switch
- VM running Debian with Domoticz 3.8637
- RFXtrx443E FW1006
- 2 x YouLess FW2.1 Analog energy and gasmeter
- 3 x Impuls, 3 x Action-brand
- 2 x Cresto Temp
- 3 x MiLight with WiFi-box v3
- RFXtrx443E FW1006
- 2 x YouLess FW2.1 Analog energy and gasmeter
- 3 x Impuls, 3 x Action-brand
- 2 x Cresto Temp
- 3 x MiLight with WiFi-box v3
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
Op zoek naar een Domoticz Start Set?
-
- Posts: 148
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: HowTo: monitor QNAP NAS
Great stuff! But, is there a limit to how many drives one could monitor with this script or with Domoticz; asking since you've only included 2 drives where I would need to monitor 4 drives?
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
There is no limit. My NAS has only 2 drives, that's why this script includes 2 drives.
Op zoek naar een Domoticz Start Set?
-
- Posts: 148
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: HowTo: monitor QNAP NAS
Ok, Just copied and updated the script to monitor 4 drives. Only thing that I'm not getting to work is the NAS Free HD parameter; it comes out empty in the Device. But, assume that's due to device error as the input data isn't what is expected (temperatur);
Code: Select all
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>
-
- Posts: 3
- Joined: Thursday 19 September 2013 10:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HowTo: monitor QNAP NAS
Hi,
I was having the same problem so I put a few echo's in the script and got ...
>>> HD free: > 1.41 T <
HTTP/1.0 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>pi@PI-DOMO ~/domoticz/scripts $ ./brinas.sh
When I changed the 'cut -c 2-7' to 'cut -c 2-5' I got ...
>>> HD free: > 1.41 <
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"
}
So, I am using the change in the cut as a work around until I can find what is the max content length and how it relates to the length of the string passed.
Any suggestions or pointers gratefully received.
Regards,
I was having the same problem so I put a few echo's in the script and got ...
>>> HD free: > 1.41 T <
HTTP/1.0 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>pi@PI-DOMO ~/domoticz/scripts $ ./brinas.sh
When I changed the 'cut -c 2-7' to 'cut -c 2-5' I got ...
>>> HD free: > 1.41 <
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"
}
So, I am using the change in the cut as a work around until I can find what is the max content length and how it relates to the length of the string passed.
Any suggestions or pointers gratefully received.
Regards,
Regards
--------------------------------------------------------------------------------------
Multiple RPI mod B running ...
Domoticz (RFXtrx433, various RC sockets, lights, switches, PIR, sensors)
Intranet (Internal web site to TV, Mosquitto, XBMC, NAS
--------------------------------------------------------------------------------------
Multiple RPI mod B running ...
Domoticz (RFXtrx433, various RC sockets, lights, switches, PIR, sensors)
Intranet (Internal web site to TV, Mosquitto, XBMC, NAS
-
- Posts: 148
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: HowTo: monitor QNAP NAS
Using "cut -c 2-5" did not do the trick on my side; still error and no update.
- BobdeBouwer
- Posts: 5
- Joined: Saturday 10 May 2014 13:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
Thanx for starting this, it is great for learning and reading!
I downloaded the MIB file from my QNAP TS219P admin pages, used the snmpB browser and "walked" some tree's.
That information will be nice to combine with Domoticz via the scripts and the WIKI HowTo.
I did not find a query for the system Fan speed, perhaps later.
My 2 cents:
First of all, the HDD queries makes the disk spin-up, so if you query them every 5 minutes they will never spin-down.
Secondly, some more variables to use.
I downloaded the MIB file from my QNAP TS219P admin pages, used the snmpB browser and "walked" some tree's.
That information will be nice to combine with Domoticz via the scripts and the WIKI HowTo.
I did not find a query for the system Fan speed, perhaps later.
My 2 cents:
First of all, the HDD queries makes the disk spin-up, so if you query them every 5 minutes they will never spin-down.
Secondly, some more variables to use.
Code: Select all
$COMM is community string
$IP is QNAP NAS IP-address
#system CPU usage
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.4.1.24681.1.2.1.0
#system total memory
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.4.1.24681.1.2.2.0
#system free memory
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.4.1.24681.1.2.3.0
#Uptime of network portion of system
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.4.1.24681.1.2.4.0
#System uptime - fraction longer
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.2.1.25.1.1.0
#System temp
snmpget -v 2c -c $COMM -O qv $IP 1.3.6.1.4.1.24681.1.2.6.0
Regards,
Bob
Bob
-
- Posts: 15
- Joined: Wednesday 11 June 2014 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HowTo: monitor QNAP NAS
Hello,
In the past the QNAP script made my domoticz crash a few times a week. I've added an extra check in my version, it checks if only numbers are returned, if not, then it does not update Domoticz with the new value. I did not make it for the free space check because i'm not using that part. Here is an example:
In the past the QNAP script made my domoticz crash a few times a week. I've added an extra check in my version, it checks if only numbers are returned, if not, then it does not update Domoticz with the new value. I did not make it for the free space check because i'm not using that part. Here is an example:
Code: Select all
# Temperature 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`
if [[ $CPUtemp == ?(-)+([0-9.]) ]]; then
# Send data
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$CPU_TEMP_IDX&nvalue=0&svalue=$CPUtemp"
else
echo "Oeps, er komen niet alleen cijfers terug!"
fi
- BobdeBouwer
- Posts: 5
- Joined: Saturday 10 May 2014 13:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: HowTo: monitor QNAP NAS
Hi All,
I was having some discussions with my QNAP NAS 219P as to why it would not spin down. A lot of reading can be done on this topic and long story short is that I decided to disable the cloud service and edit my CRONTAB (and reload it) with my maintanance window set to 21:00, most chances are that one ore more PC's are performing a back-up or are using shares anyway. To keep track on the spin up / down count I made a little script of bits and pieces that I would like to share here.
It uses a virtual device QNAP and a virtual counter on that virtual device. Via CURL and JSON I plan to update that counter once a day.
That way I can look at the spin up/ down count in Domoticz and keep track on irregularities when the disks fail to spin down.
The script is placed on one of the shares, pick your own spot.
Make it executable, plan it in Crontab (do try to get the maintanance together) and do not forget to reload CRON.
#reload crontab
crontab /etc/config/crontab
#restart cron
/etc/init.d/crond.sh restart
This is the script that runs on the QNAP:
As an example My Crontab line to run it at 21:00 hrs :
Hope this works for you.
I was having some discussions with my QNAP NAS 219P as to why it would not spin down. A lot of reading can be done on this topic and long story short is that I decided to disable the cloud service and edit my CRONTAB (and reload it) with my maintanance window set to 21:00, most chances are that one ore more PC's are performing a back-up or are using shares anyway. To keep track on the spin up / down count I made a little script of bits and pieces that I would like to share here.
It uses a virtual device QNAP and a virtual counter on that virtual device. Via CURL and JSON I plan to update that counter once a day.
That way I can look at the spin up/ down count in Domoticz and keep track on irregularities when the disks fail to spin down.
The script is placed on one of the shares, pick your own spot.
Make it executable, plan it in Crontab (do try to get the maintanance together) and do not forget to reload CRON.
#reload crontab
crontab /etc/config/crontab
#restart cron
/etc/init.d/crond.sh restart
This is the script that runs on the QNAP:
Code: Select all
#!/bin/sh
#Mind you this works with Domoticz and QNAP QTS 4.1.0 - Use at your own risk -
#In Domoticz - Define a virtual device then add a counter - make it visable and then adjust to counter type
#Search the Idx value in the devices list and set the number for IDN in this script
#Does require disk to spin bescause it is a script on disk - schedule in CRONTAB during maintanance window of create TMPFS
#edit the crontab file on the QNAP with your favorite editor /etc/config/crontab to your needs
#Make sure the script is exacutable
#To make it last - be sure to restart CRON /etc/init.d/crond.sh restart
# Declare Variables
DomoticzIP="192.168.X.ZZZ" # IP of Domoticz instance
Port="8080" # Port number of Domoticz listner
IDN="ZZ" # Device number of virtual switch in Domoticz
Disk="1" # Choose a disk from your QNAP NAS to query with get_hd_smartinfo
#Proceed only if Domoticz is around in network
if ping -c 1 $DomoticzIP &> /dev/null
then
echo "host found @" $DomoticzIP
regel=`/sbin/get_hd_smartinfo -d $Disk | /bin/grep Start_Stop_Count`
# echo $regel # uncomment to see what you found
# print third string as this holds the count we look for
ststop=` echo $regel | awk '{ print $3 }' `
echo "Start Stop Count of disk no." $Disk "=" $ststop # see what you found
# Post it to Domoticz
curl -s -i -H "Accept: application/json" "http://$DomoticzIP:$Port/json.htm?type=command¶m=udevice&idx=$IDN&svalue=$ststop"
else
echo "no host found @" $DomoticzIP
fi
#nice exit no matter what
exit 0
Code: Select all
# m h dom m dow cmd
00 21 * * * /share/<<sharename-you-picked>>/PostSpinUp.sh > /dev/null 2>&1
Regards,
Bob
Bob
Who is online
Users browsing this forum: No registered users and 1 guest