successfully got node_exporter on RT-AX58U

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

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
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

  • Grafana.png
    Grafana.png
    142.5 KB · Views: 135
Last edited:

Palanivelrajan

New Around Here
Awesome. I was trying to get this working on my RT-88u and never got it working. I followed the above instructions and it worked perfectly!

Do you know if we have a way to export router specific stats like no of client connected, no in 2gz , 5gz, lan connections, upstream ip address etc. ??
 

beep

New Around Here
I just notice that it probably would need to add & at the end to fork it.
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 &
 
Last edited:

beep

New Around Here
Palanivelrajan
Awesome. I was trying to get this working on my RT-88u and never got it working. I followed the above instructions and it worked perfectly!

Do you know if we have a way to export router specific stats like no of client connected, no in 2gz , 5gz, lan connections, upstream ip address etc. ??
Hi Palanivelrajan,
If you can get that information via command line we can use --collector.textfile.directory= and node_exporter will include it. http://prometheus.io/docs/instrumenting/exposition_formats/
 

Jason A

Occasional Visitor
Hi there,

Does this setup show network traffic by IP address?

Thanks

Jason

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
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
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top