Last active
October 4, 2025 18:00
-
-
Save jodersky/ccddef85efc006d90ce94943649773ac to your computer and use it in GitHub Desktop.
Gather metrics from a Zyxel AX7501-B0 router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Gather metrics from a Zyxel AX7501-B0 router and expose them in a Prometheus | |
# format. | |
# | |
# Usage: | |
# 1. create a user named "monitoring" (read-only access is sufficient) | |
# 2. change the password and IP address in this script down below | |
# 3. run this script | |
# | |
# Note that this script's output is ideally suited to be used in a | |
# textfile-collector of a Prometheus node exporter. | |
# For example, you can run this script periodically and redirect its output | |
# to a file, which can then be read by the Prometheus node exporter. | |
# We need this weird convolution, since the Zyxel device does not allow | |
# executing simple commands via SSH. It only allows running them from an | |
# interactive session, hence we force TTY allocation (via -t) and echo the | |
# command we would run to the shell. | |
echo -e "ifconfig\nexit" \ | |
| sshpass -ppassword ssh -t [email protected] \ | |
| sed -n '/^eth5\.3/,/^[^ ]/p' \ | |
| sed -n 's/.*RX bytes[: ]\{1,\}\([0-9]\+\).*TX bytes[: ]\{1,\}\([0-9]\+\).*/router_bytes_received \1\nrouter_bytes_transmitted \2/p' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment