HowTo: monitor QNAP NAS

Compatibility (hardware, devices and OS)
User avatar
elyannaz
Posts: 2
Joined: Thursday 09 October 2014 19:44
Target OS: Raspberry Pi
Domoticz version:
Location: FR-Annecy
Contact:

Re: HowTo: monitor QNAP NAS

Postby elyannaz » Thursday 09 October 2014 19:53

Hi Evreybody

I have problems with my QNAP monitoring.
I follow the tuto on the wiki, line after line but the script return to me this error

1.107
1
NAS already ON
41
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>curl CPU
HTTP/1.0 401 Unauthorized
Content-Length: 91
Content-Type: text/html

<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>HTTP/1.0 401 Unauthorized
Content-Length: 91
Content-Type: text/html

<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>HTTP/1.0 401 Unauthorized
Content-Length: 91
Content-Type: text/html

<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>


Any idea ???

So sorry for my "french" english

woody4165
Posts: 391
Joined: Monday 14 March 2016 14:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: HowTo: monitor QNAP NAS

Postby woody4165 » Monday 21 March 2016 16:16

Hi

just used the script for a few days and now I'm getting timeout either from script or from terminal.
Is there a way to set timeout in the snmpget command? I search but I haven't found anything.

Zoekm
Posts: 10
Joined: Friday 18 November 2016 12:34
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby Zoekm » Saturday 19 November 2016 22:28

Hello,
Trying out the script from the wiki on a rpi with Domoticz for monitoring a QNAP NAS. Testing with:

Code: Select all

snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.4.1.24681.1.2.11.1.3.1
works fine, but running the script example raised errors. I did find some errors in the wiki example (too many quotes in the Settings part), but I am unable to find what causes the last remaining error.
"./nas.sh: line 85: syntax error: unexpected end of file"

As I am not familiar with the code syntax, anyone who can tell me what causes the error?

the code:

Code: Select all

 #!/bin/bash
 # Settings
 NASIP="192.168.1.35"              # NAS IP Address
 PASSWORD="pwd"      # SNMP Password
 DOMO_IP="192.168.1.80"      # Domoticz IP Address
 DOMO_PORT="8080"         # Domoticz Port
 NAS_IDX="5"              # Virtual switch NAS STATUS
 CPU_TEMP_IDX="21"         # Virtual temerature sensor IDX NAS CPU
 HD1_TEMP_IDX="22"         # Virtual temerature sensor IDX HD1
 HD2_TEMP_IDX="23"         # Virtual temerature sensor IDX HD2
 HD_REMAIN_IDX="24"      # Virtual temerature sensor IDX HD REMAIN
 DOMO_LOGIN="login"
 DOMO_PASS="pw"
 # 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
                    # 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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$HD_REMAIN_IDX&nvalue=0&svalue=$size"
         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
              # 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_LOGIN:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$NAS_IDX&switchcmd=Off"
         fi
fi

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Monday 21 November 2016 0:54

I have copied your script-code from your post, however it is crippled badly.... {newlines and extra spaces}
You better start over with the original code...

A have corrected it myself {took me half a hour or so} and also enhanced it to my liking, and works perfectly for 4 drives instead of the only 2...

So better get the original script, prefer browser, then use winSCP to create the file, open the new file and paste the code in there.

Zoekm
Posts: 10
Joined: Friday 18 November 2016 12:34
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby Zoekm » Monday 21 November 2016 1:29

OK, thanks for your time, I will try and let you know if it works out.

Zoekm
Posts: 10
Joined: Friday 18 November 2016 12:34
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby Zoekm » Tuesday 22 November 2016 1:12

stlaha2007, thanks for your tip! It works now! Can you show us the enhancements you made, besides adding the 2 extra drives?

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: RE: Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Tuesday 22 November 2016 8:12

Zoekm wrote:stlaha2007, thanks for your tip! It works now! Can you show us the enhancements you made, besides adding the 2 extra drives?

The 2 extra drives IS the enhancement.

Still being busy with getting the mountpoint usage like the PI sensors.

After that, i'm gonna try to build some detections for those sensors, so it can also do the creation for not already existing sensors.
Got that inspiration from a thread of the Synology :-)

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Thursday 12 January 2017 2:03

stlaha2007 wrote:I have copied your script-code from your post, however it is crippled badly.... {newlines and extra spaces}
You better start over with the original code...

A have corrected it myself {took me half a hour or so} and also enhanced it to my liking, and works perfectly for 4 drives instead of the only 2...

So better get the original script, prefer browser, then use winSCP to create the file, open the new file and paste the code in there.


if i take copy / paste i think the format is'n correct .... any idea to resolv the issue ???
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: RE: Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Thursday 12 January 2017 8:23

guantolento wrote:
stlaha2007 wrote:I have copied your script-code from your post, however it is crippled badly.... {newlines and extra spaces}
You better start over with the original code...

A have corrected it myself {took me half a hour or so} and also enhanced it to my liking, and works perfectly for 4 drives instead of the only 2...

So better get the original script, prefer browser, then use winSCP to create the file, open the new file and paste the code in there.


if i take copy / paste i think the format is'n correct .... any idea to resolv the issue ???

If copy/paste results in a bad form(at), use other tools. Windows and Linux use different line endings (cariage return and newline vs. newline).

Maybe use curl on commandline to get the code (the specific post) into file and use the edit function in WinSCP to jave only the script code (delete everuthing before including

Code: Select all

 and from
till the end.

Let me know if that works. Else gonne try to post my script as a bzip or tarbal.

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Thursday 12 January 2017 22:04

Hereby attached, my modified version....

upload to the nas or better domoticz pi.

Then unzip and edit with nano or vi to include your nas and domoticz ipaddresses and your admin/password for domoticz.
Attachments
qnap-nas-monitor.zip
(1.04 KiB) Downloaded 19 times

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Friday 13 January 2017 2:35

hy stlaha2007,
thanks for all, now my 2 qnap are implemented in Domoticz. i look the 2 script (the firts from the wiki and the second .zip) and i find some difference in the syntax.
just an information. i tried to change the port from 8080 to 443 and change the setting from http to https but in this mode che script don't refresh the idx in Domoticz. so i re setting in 8080 http standard and all works.
why the sensor of hdd free space is in ° and not in % ? it's possible control the CPU and RAM value in the same mode for your experience?
that's all for now and thanks again !
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Friday 13 January 2017 8:28

had the same with https. Need to investigate, but think that has to do with selfsigned certificate.

And the degree symbol. Depends on the sensor used for Free Space. I created a Custom Sensor, because values go Up/Down, not all sensors accept that. Eg the temp-sensors can but most counters can't.

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Friday 13 January 2017 10:27

What kind of custom sensor you choose for example ???

Inviato dal mio GT-I9301I utilizzando Tapatalk
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Friday 13 January 2017 12:27

Just Click create sensor at Dummy Hardware. Choose Custom Sensor. And fill in the blanks... done that a few weeks ago, and currently not near my domoticz server.

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Sunday 15 January 2017 16:39

i think the ° sensor in not real, i try to use a % sensor. i change the idx in the script and i think work ok. this is the screenshot. the value read in smnp is already the free spase on the disk ?? or another value ???? i don't understend this.
Attachments
prova.JPG
prova.JPG (17.47 KiB) Viewed 207 times
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw

stlaha2007
Posts: 415
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: RE: Re: HowTo: monitor QNAP NAS

Postby stlaha2007 » Sunday 15 January 2017 18:43

guantolento wrote:i think the ° sensor in not real, i try to use a % sensor. i change the idx in the script and i think work ok. this is the screenshot. the value read in smnp is already the free spase on the disk ?? or another value ???? i don't understend this.

The free space which is monitored by SNMP is the real free space in MBytes. In my case 1 RAID Volume 0,92 TB.

The others are Temp (5 in my case, 1 cpu and 4 disks)

As i recall theres no calculation of the difference and percentage.

If you want other values to be monitored use a MIB-browser. Used one myself to discover the exact oid for the freespace.
For Windows there's a java-based tool mibbrowser (free) just google for it.

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Tuesday 17 January 2017 19:10

Hi i find the list of the sensor can give qnap in SMNP. for some test actually i make the CPU_USAGE sensor and it work, i have only a problem. the value read from the mib is in full farmat, so when the cpu is working for example at 4.65% in domoticz i have 4.00%. it's possible read the 2 decimal unit ??? when i finish my test i give the code used. i think is possible make a custom sensor for HD Free and RAM Free. bye bye
Attachments
prova.JPG
prova.JPG (19.24 KiB) Viewed 183 times
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw

guantolento
Posts: 126
Joined: Saturday 01 October 2016 14:48
Target OS: Raspberry Pi
Domoticz version: LastBeta
Location: Italy BG
Contact:

Re: HowTo: monitor QNAP NAS

Postby guantolento » Wednesday 18 January 2017 19:54

now i take another 2 value. ram free and hdd free.
Attachments
Cattura.JPG
Cattura.JPG (44.34 KiB) Viewed 171 times
RPI2 + Z Stick Gen 5 + System Alive Checker + Weather Underground + MB Sensor + Dummy + 1 Wall Plug NodOn + 3 Danfoss Room Sensor + 7 Danfoss Z Thermostat + 1 Swiid Chord + 9 Fibaro FGS222 2x1.5Kw


Return to “Compatibility”

Who is online

Users browsing this forum: No registered users and 1 guest