This setup is basically using the configuration from https://crashlaker.github.io/2021/10/09/truenas_snmp_exporter.html
It assumes Prometheus as data backend. Also, nas.local
is the NAS machine hostname used throughout this Gist.
This note is a bit of a experiment with Gists.
The end result looks like this:
The TrueNAS SNMP MIBs live in the /usr/local/share/snmp/mibs
on the TrueNAS machine, so copy them over to the matchine that will be running the SNMP exporter:
scp -r nas.local:/usr/local/share/snmp/mibs truenas-mibs
and verify the basic functionality (assumes the net-snmp
is installed):
$ snmptranslate -M +truenas-mibs -On FREENAS-MIB::hddTempTable
.1.3.6.1.4.1.50536.3
$ snmpwalk -M +truenas-mibs -l authPriv \
-a SHA -A 'INSERT_AUTH_PASSWORD_HERE' -x AES -X 'INSERT_PRIV_PASSWORD_HERE' \
-u grafana -v 3 nas FREENAS-MIB::hddTempTable
FREENAS-MIB::hddTempDevice.1 = STRING: da0
FREENAS-MIB::hddTempDevice.2 = STRING: ada0
FREENAS-MIB::hddTempDevice.3 = STRING: ada2
FREENAS-MIB::hddTempDevice.4 = STRING: ada3
FREENAS-MIB::hddTempDevice.5 = STRING: ada1
FREENAS-MIB::hddTempDevice.6 = STRING: nvd0
FREENAS-MIB::hddTempDevice.7 = STRING: ada4
FREENAS-MIB::hddTempValue.1 = Gauge32: 43000
FREENAS-MIB::hddTempValue.2 = Gauge32: 41000
FREENAS-MIB::hddTempValue.3 = Gauge32: 40000
FREENAS-MIB::hddTempValue.4 = Gauge32: 38000
FREENAS-MIB::hddTempValue.5 = Gauge32: 38000
FREENAS-MIB::hddTempValue.6 = Gauge32: 56000
FREENAS-MIB::hddTempValue.7 = Gauge32: 42000
This assumes that SNMP exporter runs as a service.
Use the generator.yml as source file for snmp_exporter and store it under ~/truenas-snmp
directory.
cp -R truenas-mibs/* ~/.snmp/mibs/
cd ~/truenas-snmp
~/golang/bin/generator generate
This should generate the snmp.yml
file. Append the file to the snmp.yml
file used by the SNMP exporter service and restart the SNMP exporter service:
sudo systemctl restart snmp_exporter
Now test if the changes were properly put into effect:
curl 'http://localhost:9116/snmp?target=nas.local&module=freenas'
Add the following to the scrape_configs
section in /etc/prometheus/prometheus.yml
:
- job_name: nas
static_configs:
- targets:
- nas.local
scrape_interval: 15s
metrics_path: /snmp
params:
module: [freenas]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9116
and restart the service:
sudo systemctl restart prometheus
Provision Grafana with the NAS JSON file.
The TrueNAS logo needs to be stored on the Grafana instance itself per https://community.grafana.com/t/using-text-panel-to-show-image-where-to-store-image/6642
sudo mv /tmp/TrueNAS\ logo.png /usr/share/grafana/public/img/TrueNAS-logo.png
It would be nice if single stat or gauge panels supported alerting however currently (2022) this is not the case. There were issues filed and one PR however all were closed to much despair of users.