beep
New Around Here
Hi,
This is just to share the way i got this working,
node_exporter is a service that publish metrics from the system to Prometheus.
Prometheus is a open-source monitoring solution. Where you can get alerts and graph on system metrics.
https://prometheus.io/
Prerequisite:
Enable JFFS custom scripts and configs
install entware
entware applications:
go (currently 1.14-2)
Download and extract node_exporter 1.0.0 ( RT-AX58U have armv7 other routers may be different)
filter the Architecture at https://prometheus.io/download/ to find node_exporter
untar it to your entware opt directory /opt/opt
mkdir /opt/opt
cd /opt/opt
wget https://github.com/prometheus/node_...v1.0.0/node_exporter-1.0.0.linux-armv7.tar.gz
tar xfzv node_exporter-1.0.0.linux-armv7.tar.gz
Autostart node_exporter on boot:
place this line after entware in /jffs/scripts/post-mount
The default port for node_exporter is 9100 but is currently being used by lpd so we use 9101 and turn off some collectors that doesn't exists.
Optional you can silence the alerts when you reboot the router by calling alertmanager API to add a silent for your devices when the router reboots and network connection is absent.
For this you need additional entware app to handle dates "coreutils-date"
In /jffs/scripts/services-stop add this
and for there you can integrate Prometheus with grafana to get nice graphs from your router. see grafana.png
cheers,
beep
This is just to share the way i got this working,
node_exporter is a service that publish metrics from the system to Prometheus.
Prometheus is a open-source monitoring solution. Where you can get alerts and graph on system metrics.
https://prometheus.io/
Prerequisite:
Enable JFFS custom scripts and configs
install entware
entware applications:
go (currently 1.14-2)
Download and extract node_exporter 1.0.0 ( RT-AX58U have armv7 other routers may be different)
filter the Architecture at https://prometheus.io/download/ to find node_exporter
untar it to your entware opt directory /opt/opt
mkdir /opt/opt
cd /opt/opt
wget https://github.com/prometheus/node_...v1.0.0/node_exporter-1.0.0.linux-armv7.tar.gz
tar xfzv node_exporter-1.0.0.linux-armv7.tar.gz
Autostart node_exporter on boot:
place this line after entware in /jffs/scripts/post-mount
Code:
ps | grep "node_exporter" | grep -v -q "grep" || /opt/opt/node_exporter-1.0.0.linux-armv7/node_exporter --web.listen-address=:9101 --no-collector.powersupplyclass --no-collector.mdadm
The default port for node_exporter is 9100 but is currently being used by lpd so we use 9101 and turn off some collectors that doesn't exists.
Optional you can silence the alerts when you reboot the router by calling alertmanager API to add a silent for your devices when the router reboots and network connection is absent.
For this you need additional entware app to handle dates "coreutils-date"
In /jffs/scripts/services-stop add this
Code:
#add your instance device list to get silenced while rebooting, separated with space
instances="192.168.0.1:9001"
matchers=""
for ins in ${instances}
do
matchers="${matchers}
{
\"isRegex\": false,
\"name\": \"instance\",
\"value\": \"${ins}\"
},"
done
#starts now
startsAt="$(date -u +%Y-%m-%dT%H:%M:%S)"
#ends after 10 minutes
endsAt="$(/opt/bin/date -u --date="+10 minutes" +%Y-%m-%dT%H:%M:%S)"
silence="
{
\"comment\": \"Router rebooting\",
\"createdBy\": \"services-stop\",
\"startsAt\": \"${startsAt}\",
\"endsAt\": \"${endsAt}\",
\"matchers\": [
${matchers}
]
}
"
silence=$(echo ${silence} | sed 's/}, ]/} ]/g')
# if you need to debug the POST
#echo -e "${silence}" > /opt/opt/silence-post
#change your alertmanager address and port, you will get a silence id stored at /opt/opt/silence-id
curl -s -X POST -H "Content-Type: application/json" http://192.168.0.2:9093/api/v2/silences -d "${silence}" > /opt/opt/silence-id
and for there you can integrate Prometheus with grafana to get nice graphs from your router. see grafana.png
cheers,
beep
Attachments
Last edited: