commit 5a07d2b6284988a370491d84c33dc25640e09dc2 Author: Ama Date: Sun Sep 14 08:57:23 2025 +0200 init prometheus node exporter installation diff --git a/install-node-exporter b/install-node-exporter new file mode 100644 index 0000000..b12cc0c --- /dev/null +++ b/install-node-exporter @@ -0,0 +1,13 @@ +#!/bin/bash +PROM_DIR=/var/prometheus-node-exporter + +mkdir $PROM_DIR/ + +apt install prometheus-node-exporter + +chown prometheus:prometheus $PROM_DIR + +echo "ARGS+= --collector.textfile.directory $PROM_DIR" \ + >> /etc/default/prometheus-node-exporter + +install rdl_prometheus /usr/local/bin/ diff --git a/rdl_prometheus b/rdl_prometheus new file mode 100755 index 0000000..6061526 --- /dev/null +++ b/rdl_prometheus @@ -0,0 +1,66 @@ +#!/bin/bash +# rdl_prometheus + +PROM_DIR=/var/prometheus-node-exporter + +help() { + cat -v < test.sh; chmod 777 test.sh + $ $(basename "$0") ./test.sh + $ cat /var/prometheus-node-exporter/test.prom + test_completion_time 1757754118 + test_status 1 + + $ foo() { RDL_PROM_LINES='bar 1'; return 33; } + $ export -f foo + $ $(basename "$0") foo + $ cat /var/prometheus-node-exporter/foo.prom + foo_completion_time 1757755470 + foo_status 33 + bar 1 +EOF +} + +test "$1" = "--help" && help +test -z "$1" && { help; exit 1; } + +eval "$@" + +RETURN=$? + +NAME=$(basename "$1") +NAME=${NAME%%.*} +allowed_characters='^[a-z_]+$' + +[[ "$NAME" =~ $allowed_characters ]] || { help; exit 1; } + +{ + echo "$NAME"_completion_time $(date +%s) + echo "$NAME"_status $RETURN + test -z "$RDL_PROM_LINES" || echo "$RDL_PROM_LINES" +} > /tmp/"$NAME".prom.$$ + +mv /tmp/"$NAME".prom.$$ "$PROM_DIR"/"$NAME".prom +chown prometheus:prometheus "$PROM_DIR"/"$NAME".prom