Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vi7/bc27529bd4803576fefc479dbd326dfa to your computer and use it in GitHub Desktop.
Save vi7/bc27529bd4803576fefc479dbd326dfa to your computer and use it in GitHub Desktop.
Prometheus Node Exporter installer script for AsusWRT Merlin routers with config examples

Prometheus Node Exporter installer script for AsusWRT Merlin

Installation

curl -sL https://gist.githubusercontent.com/vi7/bc27529bd4803576fefc479dbd326dfa/raw/node_exporter_installer_asuswrt_merlin.sh | sh \
&& rm -f node_exporter_installer_asuswrt_merlin.sh

Running Node Exporter

Create launcher script /jffs/addons/node_exporter/node_exporter.sh with the following contents:

#!/usr/bin/env sh

nohup /jffs/addons/node_exporter/node_exporter \
  --log.level=error \
  --collector.filesystem.mount-points-exclude='^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)' \
  --collector.filesystem.fs-types-exclude='^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$' \
  --no-collector.bcache \
  --no-collector.btrfs \
  --no-collector.dmi \
  --no-collector.fibrechannel \
  --no-collector.infiniband \
  --no-collector.ipvs \
  --no-collector.mdadm \
  --no-collector.nvme \
  --no-collector.rapl \
  --no-collector.tapestats \
  --no-collector.xfs \
  --no-collector.zfs |\
  logger -s -c -t node_exporter

Add following lines to the services start script /jffs/scripts/services-start:

logger -c -t services-start "Starting Node Exporter"
/jffs/addons/node_exporter/node_exporter.sh &

Reboot router

Node Exporter metrics will be available on <your-router-address>:9100/metrics

#!/usr/bin/env sh
#############
### USAGE ###
#############
# 1. Modify version, arch and install path vars below if needed
#
# 2. SSH to the router, `cd /jffs` and run:
#
# curl -sL https://gist.githubusercontent.com/vi7/bc27529bd4803576fefc479dbd326dfa/raw/node_exporter_installer_asuswrt_merlin.sh | sh && rm -f node_exporter_installer_asuswrt_merlin.sh
VERSION="1.3.1"
ARCH="linux-arm64"
INSTALL_PATH="/jffs/addons/node_exporter"
mkdir -p "$INSTALL_PATH"
cd "$INSTALL_PATH"
if [ ! -f node_exporter ]
then
curl -LO "https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.${ARCH}.tar.gz"
tar xzvf node_exporter-"${VERSION}"."${ARCH}".tar.gz
mv node_exporter-"${VERSION}"."${ARCH}"/node_exporter .
chmod a+x node_exporter
rm -rvf node_exporter-"${VERSION}"."${ARCH}"*
echo "Node Exporter is installed to the $INSTALL_PATH"
else
echo "SKIPPING! Node Exporter seems to be present in the $INSTALL_PATH"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment