QNAP NAS Template

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
netaddict
Posts: 4
Joined: Thu Feb 07, 2013 9:00 am

QNAP NAS Template

Post by netaddict »

* UPDATED 2013-06-04 *
  • Fixed the math to support MB/GB/TB on disk volume
  • Edited the Prerequisites and Instructions section below, hopefully there is enough instructions to help you get it going
--== PREREQUISITES ==--
  • Enable SNMP on QNAP. Port 161, SNMP V1/V2, Enter a COMMUNITY name.
    Home > Network Services > SNMP Settings
  • Install Optware
  • Install Optware's "coreutils" tool
  • Install Optware's "bc" tool
  • Install Optware's "net-snmp" tool
  • Install Cacti, use instructions from http://forum.qnap.com/viewtopic.php?t=21218
--== INSTRUCTIONS ==--
  • Edit the script qnap-cpu-cron.sh to modify the SNMP_COMMUNITY variable to match the one set in your Qnap device.
  • Edit the script qnap-temperature.sh to reflect the number of hard drives you have in the device.
  • Copy the shell scripts (.sh files) into /share/MD0_DATA/Web/cacti/script, and make sure they're mode 0755 (run "chmod 0755 qnap*.sh" in that folder).
  • Import the .XML file by using the Cacti Import Template function.
  • Configure Cacti to point to Qnap, use the template, and configure SNMP community string to match.
  • Add the crontab into the autorun.sh script to ensure it survives the reboot. Check Wiki for QNAP autorun.sh script. Example autorun.sh inclusion:
    prompt> cat >> /etc/config/crontab <<\EOF
    * * * * * /share/MD0_DATA/Web/cacti/scripts/qnap-cpu-cron.sh >/dev/null 2>&1
    EOF
    prompt> crontab /etc/config/crontab
Here's a template for monitoring the awesome QNAP NAS devices, it collects data for CPU, Memory, Temperature (disk and overall), Volume utilization, and Fan Speed. For Network utilization, use the Cacti's built-in Interface Traffic graph. I have a TS-469 Pro, but I'm pretty sure it works with all QNAP NAS devices. If you need additional Linux tools on QNAP, please install the QPKG Center and Optware in your QNAP Applications (see PREREQUISITES above).

Also note, per-minute polls is assumed, for better graphs.

For many of the shell scripts, I give credit to the original work by http://pnpk.net (Sorry, I don't read Japanese...), but I've restructured most of them and added some other scripts to make it into this host template.

I spent quite a few sleepless nights on this, so hopefully you'll find it useful. Enjoy!
Attachments
qnap-nas-cacti-template 2013-06-04.zip
This file contains the template and scripts.
(14.59 KiB) Downloaded 3341 times
Sample screenshot
Sample screenshot
qnap-cacti.jpg (137.09 KiB) Viewed 23234 times
Last edited by netaddict on Mon Jun 10, 2013 9:23 am, edited 1 time in total.
User avatar
Linegod
Developer
Posts: 1626
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

Re: QNAP NAS Template

Post by Linegod »

If you get a chance, please post these to the Templates site: http://docs.cacti.net/templates.guidelines
--
Live fast, die young
You're sucking up my bandwidth.

J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
netaddict
Posts: 4
Joined: Thu Feb 07, 2013 9:00 am

Re: QNAP NAS Template

Post by netaddict »

Linegod wrote:If you get a chance, please post these to the Templates site: http://docs.cacti.net/templates.guidelines
I don't have a credential to "Create a Page" on the Template site, that button does not show up when I try to create a template page.
User avatar
Linegod
Developer
Posts: 1626
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

Re: QNAP NAS Template

Post by Linegod »

Cacti Docs user ids are linked to your http://bugs.cacti.net account.
--
Live fast, die young
You're sucking up my bandwidth.

J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
olo
Posts: 5
Joined: Sun May 26, 2013 8:57 am

Re: QNAP NAS Template

Post by olo »

Could someone report it as working? Id didn't work for me with Qnap TS-112.
Best regards,
olo
---
cacti 0.8.8b patched @CentOS
netaddict
Posts: 4
Joined: Thu Feb 07, 2013 9:00 am

Re: QNAP NAS Template

Post by netaddict »

olo wrote:Could someone report it as working? Id didn't work for me with Qnap TS-112.
olo, I just updated the script and provided instructions. Try following the instructions now.
shpokas01
Posts: 1
Joined: Sun Nov 17, 2013 5:44 pm

Re: QNAP NAS Template

Post by shpokas01 »

Imported template, got some unmet dependencies (below). Is this OK?

Cacti has imported the following items:

CDEF

[success] Turn Bytes into Bits [update]
[success] Multiply by 1000000 (MB to GB on base 1000) [update]
GPRINT Preset

[success] Normal [update]
[success] TB [update]
[success] Celsius [update]
[success] Exact Numbers [update]
[success] Percent(Round down to the nearest decimal) [update]
[success] GB [update]
Data Input Method

[success] Get SNMP Data (Indexed) [update]
[success] QNAP - Disk Volume [new]
[success] QNAP - Temperature [new]
[success] QNAP - Fan [new]
[success] QNAP - CPU [new]
[success] QNAP - Memory [new]
Data Template

[success] Interface - Traffic [update]
[success] QNAP - Volume [new]
+ Found Dependency: (Data Input Method) QNAP - Disk Volume
+ Unmet Dependency: (Data Input Field)
+ Found Dependency: (Data Input Field) Volume Total Size
+ Found Dependency: (Data Input Field) Volume Used Size
+ Found Dependency: (Data Input Field) snmp_community
+ Found Dependency: (Data Input Field) hostname
[success] QNAP - Temperature [new]
[success] QNAP - Fan [new]
[success] QNAP - CPU [new]
[success] QNAP - Memory [new]
+ Found Dependency: (Data Input Method) QNAP - Memory
+ Found Dependency: (Data Input Field) Memory Used
+ Found Dependency: (Data Input Field) Memory Total
+ Unmet Dependency: (Data Input Field)
+ Found Dependency: (Data Input Field) snmp_community
+ Found Dependency: (Data Input Field) hostname
Graph Template

[success] Interface - Traffic (bits/sec) [update]
[success] Interface - Traffic (bytes/sec) [update]
[success] QNAP - Disk Volume Usage [update]
[success] QNAP - Temperature [update]
[success] QNAP - Fan Speed [update]
[success] QNAP - CPU Utilization [new]
[success] QNAP - Memory [new]
Host Template

[success] QNAP NAS TS-x69 Pro [update]
netaddict
Posts: 4
Joined: Thu Feb 07, 2013 9:00 am

Re: QNAP NAS Template

Post by netaddict »

It should work... have you tried it yet?
feliXYZ
Posts: 1
Joined: Sun Feb 01, 2015 2:51 pm

Re: QNAP NAS Template

Post by feliXYZ »

To log more then only a local QNAP-NAS I modified the script so it accepts <host> <snmp_community> as parameters like the other scripts does.
By using this new script be shure to add also this two Input Fields to the Data Input Methodes.

There is no need to shedule a cronjob exept on the local NAS. The script now detects if it is sampling datas for the local machine or not.

Thanks to netaddict for the templates.

Felix

[qnap-cpu.sh]

Code: Select all

#!/bin/sh

#########################################################################
# cacti script for QNAP NAS
# Author: Bruce Cheng <email at brucecheng.com>, January 2013
#
# REQUIREMENT: Run qnap-cpu-cron.sh from crontab
# PURPOSE: Obtain CPU utilization from about 1 minute ago
# Usage: <path_cacti>/scripts/qnap-cpu.sh
#
#########################################################################

# Cacti spikes CPU when poller is run, offload it to external process at
# different time, by running it in cronjob every minute, storing it to /tmp file

myip=$( /sbin/ifconfig eth0 | sed -n '/inet addr:/ { s# *inet addr:##; s# .*##p }' )

if [ $1 = $myip ]; then
     if [ ! -e /tmp/systemcpu.cacti ]; then
       systemcpu="Error: Create a cronjob"
       exit 1
     else
       systemcpu=`cat /tmp/systemcpu.cacti`
     fi
else
     systemcpu=`/opt/bin/snmpget -v1 -t 3 -c $2 $1 .1.3.6.1.4.1.24681.1.2.1.0 |cut -d\" -f2 | cut -d' ' -f1 |awk '{ printf($1) }'`
fi

printf ' systemcpu:'$systemcpu

exit 0
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests