From 9137b544e2de86789d56bf0ae175737bceac3e31 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 14 Jul 2023 23:01:16 +0200 Subject: [PATCH] feat: monitor openwrt routers with prometheus --- knowledge base/openwrt.md | 73 ++++++++++++++++++++++++++++++++++++ knowledge base/prometheus.md | 5 +++ knowledge base/turris os.md | 4 +- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 knowledge base/openwrt.md diff --git a/knowledge base/openwrt.md b/knowledge base/openwrt.md new file mode 100644 index 0000000..e0e7396 --- /dev/null +++ b/knowledge base/openwrt.md @@ -0,0 +1,73 @@ +# OpenWrt + +Linux operating system targeting embedded devices, providing a fully writable filesystem with package management. + +## Table of contents + +1. [Monitoring](#monitoring) + 1. [Prometheus](#prometheus) +1. [Further readings](#further-readings) +1. [Sources](#sources) + +## Monitoring + +### Prometheus + +On the router: + +```sh +opkg install \ + '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' +sed -E -i'.bak' "s/(option listen_interface) 'loopback'/\1 'lan'/" /etc/config/prometheus-node-exporter-lua +/etc/init.d/prometheus-node-exporter-lua start +curl 'router.fqdn:9100/metrics' +``` + +In Prometheus'configuration file: + +```yml +scrape_configs: + - job_name: OpenWrt + static_configs: + - targets: [ 'router.fqdn:9100' ] +``` + +Dashboard for grafana: [11147-openwrt](https://grafana.com/grafana/dashboards/11147-openwrt/). + +## Further readings + +- [Website] +- [`opkg`][opkg] +- [UCI] +- [LXC] +- [Turris OS] + +## Sources + +All the references in the [further readings] section, plus the following: + +- [How I monitor my OpenWrt router with Grafana Cloud and Prometheus] + + + + +[website]: https://openwrt.org/ + + +[further readings]: #further-readings + + +[lxc]: lxc.md +[opkg]: opkg.md +[turris os]: turris%20os.md +[uci]: uci.md + + +[how i monitor my openwrt router with grafana cloud and prometheus]: https://grafana.com/blog/2021/02/09/how-i-monitor-my-openwrt-router-with-grafana-cloud-and-prometheus/ diff --git a/knowledge base/prometheus.md b/knowledge base/prometheus.md index 2eaee22..81e33dd 100644 --- a/knowledge base/prometheus.md +++ b/knowledge base/prometheus.md @@ -42,6 +42,9 @@ scrape_configs: - targets: - fqdn:9100 - host.local:9100 + - job_name: router + static_configs: + - targets: [ 'openwrt.local:9100' ] ``` ## Queries @@ -96,6 +99,7 @@ All the references in the [further readings] section, plus the following: - [SNMP monitoring and easing it with Prometheus] - [`prometheus/node_exporter`][prometheus/node_exporter] - [`prometheus/snmp_exporter`][prometheus/snmp_exporter] +- [How I monitor my OpenWrt router with Grafana Cloud and Prometheus] [getting started with prometheus]: https://opensource.com/article/18/12/introduction-prometheus +[how i monitor my openwrt router with grafana cloud and prometheus]: https://grafana.com/blog/2021/02/09/how-i-monitor-my-openwrt-router-with-grafana-cloud-and-prometheus/ [ordaa/boinc_exporter]: https://gitlab.com/ordaa/boinc_exporter [snmp monitoring and easing it with prometheus]: https://medium.com/@openmohan/snmp-monitoring-and-easing-it-with-prometheus-b157c0a42c0c diff --git a/knowledge base/turris os.md b/knowledge base/turris os.md index 4e0ba4e..4183aa7 100644 --- a/knowledge base/turris os.md +++ b/knowledge base/turris os.md @@ -456,9 +456,10 @@ luci-reload - [How to control LED diodes] - [Factory reset on Turris Omnia] - [Supported SFP modules] +- [Home NAS] +- [OpenWrt] - [`opkg`][opkg] - [UCI] -- [Home NAS] - [LXC] ## Sources @@ -487,6 +488,7 @@ All the references in the [further readings] section, plus the following: [lxc]: lxc.md +[openwrt]: openwrt.md [opkg]: opkg.md [pi-hole]: pi-hole.md [ssh]: ssh.md