Installation snmp La base :
https://wiki.debian.org/SNMP
nano /etc/apt/sources.list
deb http://ftp.debian.org/debian buster main contrib non-free deb http://ftp.debian.org/debian buster-updates main contrib non-free deb http://security.debian.org buster/updates main contrib non-free apt-get update apt-get -y install snmp snmp-mibs-downloader
Faire un test
snmpwalk -v1 -c public 127.0.0.1
Recuperer NAS-MIB sur le serveur Qnap et activer le service SNMP v2
http://irp.nain-t.net/doku.php/215snmp:40_les_mibs
Nous reviendrons sur la partie SNMP une fois le module telegraf (collecteur snmp) installé. Installation InfluxDB
wget https://dl.influxdata.com/influxdb/releases/influxdb_1.7.8_amd64.deb dpkg -i influxdb_1.7.8_amd64.deb systemctl enable influxd systemctl start influxd influx -execute "CREATE DATABASE influx_db_telegraf" influx -execute "CREATE USER telegraf_user WITH PASSWORD 'telegraf_password'" influx -execute "GRANT ALL ON influx_db_telegraf TO telegraf_user" influx -execute 'CREATE RETENTION POLICY "one_year" ON "influx_db_telegraf" DURATION 365d'
Faire un test de connexion
influx
show databases use influx_db_telegraf show measurements
Supprimer mesure dans Influx
DROP MEASUREMENT "snmp.snap.SystemVolumeTable"
Installation telegraf
wget https://dl.influxdata.com/telegraf/releases/telegraf_1.12.3-1_amd64.deb dpkg -i telegraf_1.12.3-1_amd64.deb systemctl enable telegraf systemctl start telegraf
Faire un test
telegraf --test
telegraf --config /etc/telegraf/telegraf.d/qnap.telegraf.conf --test
Si rien ne s’affiche ou alors si des données sont manquantes bien vérifier l’oid les derniers chiffres peuvent être manquants
Ex :
snmpwalk -v 2c -c public localhost NAS-MIB::modelNameEX NAS-MIB::modelNameEX.0 = STRING: « TS-439 »
Il faut rajouter le .0 dans le cadre d’une récupération via snmpget Configuration Telegraf pour InfluxDB
nano /etc/telegraf/telegraf.conf
[[outputs.influxdb] database = "influx_db_telegraf" username = "telegraf_user" password = "telegraf_password"
Ajouter MIB pour Telegraf
mkdir /etc/telegraf/.snmp/mibs
Ajouter y les MIB
Chercher une information dans la MIB
snmptranslate -m NAS-MIB -On -Tt
ou en filtrant par un nom
snmptranslate -m NAS-MIB -On -Tt | grep Table
Afficher l’arbre de cette information
snmptranslate -m NAS-MIB -Tp NAS-MIB::systemIfTableEx
Afficher la table
snmptable -v 2c -c public -Os -Cw 70 10.168.50.18 NAS-MIB::systemIfTable SNMP table: systemIfTable ifIndex ifDescr ifPacketsReceived ifPacketsSent ifErrorPackets 1 « eth0 » 524317838 353815965 0 2 « eth1 » 123523902 121040192 0
snmptable -v 2c -c public -Os -Cw 70 localhost NAS-MIB::systemIfTableEx SNMP table: systemIfTableEx ifIndexEX ifDescrEX ifPacketsReceivedEX ifPacketsSentEX 1 « eth0 » 524317831 353815962 2 « eth1 » 123523897 121040188 SNMP table systemIfTableEx, part 2 ifErrorPacketsEX 0 0
Il ya deux type de table pour les interfaces, Volumes et HD ( NAS-MIB::systemIfTable et NAS-MIB::systemIfTableEx), il faut choisir celle correspondant au besoin
Remplacer dans le fichier de configuration Telegraf l’input souhaité Installation Grafana
apt-get install libfontconfig wget https://dl.grafana.com/oss/release/grafana_6.1.4_amd64.deb dpkg -i grafana_6.1.4_amd64.deb cp grafana.ini /etc/grafana/grafana.ini systemctl daemon-reload systemctl enable grafana-server systemctl start grafana-server systemctl status grafana-server
Aller sur http://IP_server:3000 (User:admin, MDP: admin) Ajouter dans grafana la source de données influx_db_telegraf
Autre moyen :
https://github.com/sandrotosi/qnap-dashboards