9
0
Fork 0

Add the secret sauce

This commit is contained in:
Lauri Võsandi 2021-06-12 20:16:15 +00:00
parent 149e3193d0
commit 8dcb6413ed
5 changed files with 74 additions and 0 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM alpine AS build
RUN apk add --no-cache \
smartmontools \
jq \
nvme-cli \
bash \
hwids-pci
COPY node-exporter-textfile-collector-scripts /scripts
COPY entrypoint.sh /entrypoint.sh
COPY bridge.sh /scripts/
RUN chmod +x /scripts/bridge.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh

17
README.md Normal file
View File

@ -0,0 +1,17 @@
# Background
Ubuntu packages are outdated and getting textfile collectors working is a hassle.
This is the only sane option for running Prometheus Node Exporter with textfile collectors
such as SMART metrics, NVMe metrics etc.
# Deploying
See supplied `docker-compose.yml`
# Security
Don't forget to add some `iptables` rules for protecting the node exporter endpoint.
![Still waiting for bearer token](https://imgflip.com/i/5d21t5)

9
bridge.sh Normal file
View File

@ -0,0 +1,9 @@
echo "# HELP node_bridge_members How many member interfaces bridge has"
echo "# TYPE node_bridge_members gauge"
for BRIDGE in $(ls /sys/devices/virtual/net); do
if [ -e /sys/devices/virtual/net/$BRIDGE/brif ]; then
echo node_bridge_members{bridge=\"$BRIDGE\"} $(/bin/ls -1 /sys/devices/virtual/net/$BRIDGE/brif 2>/dev/null | wc -l)
fi
done

25
docker-compose.yml Normal file
View File

@ -0,0 +1,25 @@
version: '3.7'
services:
app:
restart: always
image: quay.io/prometheus/node-exporter:latest
command:
- --path.rootfs=/host
- --collector.textfile.directory=/host/run/node-exporter
network_mode: host
pid: host
restart: always
volumes:
- '/:/host:ro,rslave'
collectors:
image: kspaceee:prometheus-textfile-collectors
restart: always
network_mode: none
privileged: true
volumes:
- '/dev:/dev'
- '/sys:/sys:ro,rslave'
- '/run/node-exporter:/run/node-exporter'

8
entrypoint.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
while true; do
/scripts/smartmon.sh > /run/node-exporter/smart.prom
/scripts/nvme_metrics.sh > /run/node-exporter/nvme.prom
/scripts/bridge.sh > /run/node-exporter/bridge.prom
/scripts/ipmitool > /run/node-exporter/impitool.prom
sleep 15
done