Instrucciones seguidas para tener una herramienta para monitorizar la infraestructura de router basado en OpenWRT. La información ha sido recomipilada de varias fuentes. Se parte de la base de:
- Servidor Debian 11 para desplegar las herramientas Prometheus + Grafana + InfluxDB
- Routers basados en OpenWRT (OpenWrt 19.07.7)
Instalación de herramientas en servidor
Referencia: https://raspiblog.noblogs.org/post/2021/01/02/installation-of-prometheus-influxdb-and-grafana-on-debian-10-without-docker/
Ejecución de comandos:
apt install prometheus influxdb influxdb-client
nano /etc/prometheus/prometheus.yml
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_timeout: 5s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: node
# If prometheus-node-exporter is installed, grab stats about the local
# machine by default.
static_configs:
- targets: ['localhost:9100']
systemctl restart prometheus
nano /etc/influxdb/influxdb.conf
# Just modify only the section of collectd, leave the others as-is
[[collectd]]
enabled = true
bind-address = ":25826"
database = "collectd"
retention-policy = ""
#
# The collectd service supports either scanning a directory for multiple types
# db files, or specifying a single db file.
typesdb = "/usr/local/share/collectd"
#
security-level = "none"
# auth-file = "/etc/collectd/auth_file"
wget https://raw.githubusercontent.com/collectd/collectd/master/src/types.db
echo "stations value:GAUGE:0:256" >> types.db
mkdir /usr/local/share/collectd/
mv types.db /usr/local/share/collectd/types.db
netstat -tulpn|egrep "8086|25826"
$ influx
> CREATE DATABASE collectd
> exit
$ apt-get install -y apt-transport-https software-properties-common wget
$ wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
$ echo "deb https://packages.grafana.com/oss/deb stable main" | tee -a /etc/apt/sources.list.d/grafana.list
$ apt-get update
$ apt-get install grafana
$ sudo systemctl daemon-reload
$ sudo systemctl enable grafana-server
$ sudo systemctl start grafana-server
netstat -tulpn|egrep 3000
Instalación de paquetes en OpenWRT
- Referenrecia: https://grafana.com/grafana/dashboards/11147
- Referencia: https://www.cloudrocket.at/posts/monitor-openwrt-nodes-with-prometheus/
prometheus-node-exporter-lua
prometheus-node-exporter-lua-nat_traffic
prometheus-node-exporter-lua-netstat
prometheus-node-exporter-lua-openwrt
prometheus-node-exporter-lua-wifi
prometheus-node-exporter-lua-wifi_stations
Comandos para ejecutar (si la interface de salida es «35PRO»)
10 cat /etc/config/network
12 sed -i.bak 's#loopback#35PRO#g' /etc/config/prometheus-node-exporter-lua
13 cat /etc/config/prometheus-node-exporter-lua
18 /etc/init.d/prometheus-node-exporter-lua restart
19 netstat -tulpn | grep 9100
20 ps | grep prometheus
Creación Dashboard
Ver referencias