Hoping someone can help me here, I have CheckMK raw:latest running in a docker container and monitoring my home network along with my QNAP.
I have managed to enable SNMP on the QNAP and have CheckMK pulling out all the disk information etc, and have also managed to get the CheckMK Agent installed.
However, the QNAP also has an expansion shelf with 4 disks but the health of those disks aren’t present in CheckMK.
I had a dig around and found them during an SNMP walk and they are listed below.
Also, the CPU Temp, System Temp, QNAP Model and Expansion shelf aren’t present, so managed to find those as well.
I’ve gone through trying to add them in CheckMK and went round and round with ChatGPT trying to create a custom plugin in several different ways but I couldn’t get it to work.
Can someone point me in a starting place to add these in please? Should I be trying to modify an existing plugin, contacting an author, or create a new plugin, or run it as a script on the agent…?
I had another go with ChatGPT and got the data I needed onto CheckMK via a script it wrote, but I couldn’t get CheckMK to pick it up and display it with the host.
Here’s the script in case it’s helpful, it said to put it in cmk/local/share/check_mk/agents/local but I’m not sure that’s correct.
#!/bin/bash
# CheckMK local agent plugin for QNAP expansion and system info
# Place in: /omd/sites/cmk/local/share/check_mk/agents/local/qnap_expansion
# -----------------------------
# Configuration
# -----------------------------
SNMP_HOST="192.168.202.103" # change to your QNAP IP if running remotely
COMMUNITY="public" # SNMP community
SNMP_VER="-v2c"
# -----------------------------
# Helper function
# -----------------------------
snmpget_value() {
local oid=$1
snmpget $SNMP_VER -c $COMMUNITY $SNMP_HOST $oid -Oqv 2>/dev/null
}
# -----------------------------
# CPU and System Temperature
# -----------------------------
CPU_TEMP=$(snmpget_value .1.3.6.1.4.1.24681.1.2.5.0 | awk '{print $1}' | tr -d '"')
SYS_TEMP=$(snmpget_value .1.3.6.1.4.1.24681.1.2.6.0 | awk '{print $1}' | tr -d '"')
echo "0 QNAP_CPU_Temp temp=${CPU_TEMP}"
echo "0 QNAP_System_Temp temp=${SYS_TEMP}"
# -----------------------------
# Expansion Shelf Model
# -----------------------------
EXP_MODEL=$(snmpget_value .1.3.6.1.4.1.24681.1.4.1.1.1.1.1.2.1.3.2 | tr -d '"')
echo "0 QNAP_Expansion_Model info=\"${EXP_MODEL}\""
# -----------------------------
# Expansion Shelf HDDs
# -----------------------------
HDD_INDEXES=$(snmpwalk -v2c -c $COMMUNITY $SNMP_HOST .1.3.6.1.4.1.24681.1.2.18.3.1.1 -Oqv 2>/dev/null)
echo "$HDD_INDEXES" | while read i; do
[[ -z "$i" ]] && continue
HDD_NAME=$(snmpget_value .1.3.6.1.4.1.24681.1.2.18.3.1.2.$i.0 | tr -d '"')
HDD_TEMP=$(snmpget_value .1.3.6.1.4.1.24681.1.2.18.3.1.3.$i.0 | awk '{print $1}' | tr -d '"')
HDD_STATUS=$(snmpget_value .1.3.6.1.4.1.24681.1.2.18.3.1.7.$i.0 | tr -d '"')
STATE=0
[[ "$HDD_STATUS" != "Good" ]] && STATE=2
echo "$STATE QNAP_HDD_$i temp=${HDD_TEMP} status=$STATE info=\"$HDD_NAME\""
done
Your script is a local check script and needs to be executed by an CMK agent.
You can use the agent running on the CMK host for this.
The correct script location should be then → /usr/lib/check_mk_agent/local/
It needs only to be checked that “snmpget” is also available outside of your CMK site as the script runs with a local system user (root).
The data will then be shown as checks on the CMK host inside your instance.
I got as far as creating the script, but can’t run it on the QNAP because it won’t let me install snmpget which is super annoying. I tried to use opkg to install additional packages but couldn’t find snmpget in any available.
And lol at hallucinating parrot, that’s exactly what it is - it lead me around in circles and I often had to tell it that we had already tried what it was trying to do and it hadn’t worked.
That link is great though, I’ll try and write my own plugin using those examples and let you know how I get on.
I managed to get snmpget installed on the QNAP by running: sudo /opt/bin/opkg install snmp-utils
The script is now working and showing me what I need in CheckMK, thank guys!
Just for my own information, for things like this is it best to do it like I’ve done it with a script on the agent or should I have created my own plugin? Presumably because I have the agent that seems the easiest way of getting the information and if I didn’t then I’d have to use a plugin…?