ninjaserif / TIP-QNAP-resource-usage-snmp

Telegraf Input Plugin - QNAP resource usage SNMP
GNU General Public License v3.0
1 stars 0 forks source link

TIP-QNAP-resource-usage-snmp

Telegraf Input Plugin (TIP) to collect resource usage of a QNAP NAS via SNMP. My use case was to create this script to collect resource usage data of my QNAP NAS to be stored in InfluxDB - visualized in Grafana. The script could be used for other uses if you just need the json output.

I used a snmpwalk application to gather the "oid" (Object Identifier) for the snmp values I was interested in tracking.

The script returns the below output:

{
    "hostname": "<server name>",
    "systemCPU_Usage": 8.40,
    "systemTotalMem": 7860.7,
    "systemFreeMem": 3873.3,
    "systemUptime": 95420670,
    "cpu_Temperature": 34,
    "systemTemperature": 35,
    "hdTemperature_HDD1": 27,
    "hdTemperature_HDD2": 26,
    "hdTemperature_HDD3": 27,
    "hdTemperature_HDD4": 27,
    "sysFanSpeed": 522,
    "sysVolumeTotalSize": 2.67,
    "sysVolumeFreeSize": 775.37
}

Features

Prerequisite

Install:

Setup

Below is a "one-liner" to download the latest release

LOCATION=$(curl -s https://api.github.com/repos/ninjaserif/TIP-QNAP-resource-usage-snmp/releases/latest \
| grep "tag_name" \
| awk '{print "https://github.com/ninjaserif/TIP-QNAP-resource-usage-snmp/archive/" substr($2, 2, length($2)-3) ".tar.gz"}') \
; curl -L -o TIP-QNAP-resource-usage-snmp_latest.tar.gz $LOCATION
sudo mkdir /usr/local/bin/TIP-QNAP-resource-usage-snmp && sudo tar -xvzf TIP-QNAP-resource-usage-snmp_latest.tar.gz --strip=1 -C /usr/local/bin/TIP-QNAP-resource-usage-snmp
cp config-sample.sh config.sh
HOST_IP="<server IP>"               # your QNAP NAS IP
HOST_NAME="<server name>"           # your QNAP name
COMMUNITY="<snmp password>"         # SNMP password
[[inputs.exec]]
  commands = ["/usr/local/bin/TIP-QNAP-resource-usage-snmp/TIP-QNAP-resource-usage-snmp.sh"]
  timeout = "10s"
  data_format = "json"
  name_suffix = "_QNAPsnmp"
  tag_keys = ["hostname"]

Change log

-END-