diff options
author | Tim Biermann <tbier@posteo.de> | 2022-10-01 23:25:33 +0200 |
---|---|---|
committer | Tim Biermann <tbier@posteo.de> | 2022-10-01 23:25:33 +0200 |
commit | 31859e6e93c89f5a2ee95e46a537e58c4fe771e3 (patch) | |
tree | a1187aa7458dddc90773775f3f639d4b14398db5 /prometheus-node-exporter | |
parent | b165efef1e40cbeba2e1c5439dfa02d2018d46c5 (diff) | |
download | contrib-31859e6e93c89f5a2ee95e46a537e58c4fe771e3.tar.gz contrib-31859e6e93c89f5a2ee95e46a537e58c4fe771e3.tar.xz |
prometheus-node-exporter: initial commit, version 1.4.0
Diffstat (limited to 'prometheus-node-exporter')
-rw-r--r-- | prometheus-node-exporter/.footprint | 11 | ||||
-rw-r--r-- | prometheus-node-exporter/.signature | 8 | ||||
-rw-r--r-- | prometheus-node-exporter/Pkgfile | 36 | ||||
-rw-r--r-- | prometheus-node-exporter/README.md | 16 | ||||
-rw-r--r-- | prometheus-node-exporter/config.yml | 9 | ||||
-rwxr-xr-x | prometheus-node-exporter/gen-pass.py | 7 | ||||
-rwxr-xr-x | prometheus-node-exporter/prometheus-node-exporter.service | 33 |
7 files changed, 120 insertions, 0 deletions
diff --git a/prometheus-node-exporter/.footprint b/prometheus-node-exporter/.footprint new file mode 100644 index 000000000..35072d3a4 --- /dev/null +++ b/prometheus-node-exporter/.footprint @@ -0,0 +1,11 @@ +drwxr-xr-x root/root etc/ +drwxr-xr-x root/root etc/node-exporter/ +-rw-r--r-- root/root etc/node-exporter/config.yml +drwxr-xr-x root/root etc/rc.d/ +-rwxr-xr-x root/root etc/rc.d/prometheus-node-exporter +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/bin/ +-rwxr-xr-x root/root usr/bin/node_exporter +drwxr-xr-x root/root usr/lib/ +drwxr-xr-x root/root usr/lib/prometheus-node-exporter/ +-rw-r--r-- root/root usr/lib/prometheus-node-exporter/gen-pass.py diff --git a/prometheus-node-exporter/.signature b/prometheus-node-exporter/.signature new file mode 100644 index 000000000..b18579edb --- /dev/null +++ b/prometheus-node-exporter/.signature @@ -0,0 +1,8 @@ +untrusted comment: verify with /etc/ports/contrib.pub +RWSagIOpLGJF3/0Q7j97nMYblzGYPpkkfrUb4o4MntlMBLwu24me+zF2WsVZxMSFkCVOiS0Kp95HYuPveseRD9FB/lc1crTZfAE= +SHA256 (Pkgfile) = 491b6374718e3f303c1b4150f0c854ad0b75d7a4810a4d0174026dc556109647 +SHA256 (.footprint) = 63690ec8add40f9e66418b342db5acb1d5bfd54da5d27a5cb9fd36d4b51f0463 +SHA256 (prometheus-node-exporter-1.4.0.tar.gz) = 96f749928e3d6c952221aaca852d4c38545eaae03adc6bb925745bc3f2f827ca +SHA256 (prometheus-node-exporter.service) = 3a1afd70a728ec9c84e5bf63378fb10583672daf5e064f2561961f5fdad302bb +SHA256 (config.yml) = 7b660cee741de85009a5e1fbd0900bb70c8bea30f83131d74ea2442546546571 +SHA256 (gen-pass.py) = bc6d1e03893cc50ef9fd7491c66f66d6d0b26b7178e95016ec7c8f87cb6f2f19 diff --git a/prometheus-node-exporter/Pkgfile b/prometheus-node-exporter/Pkgfile new file mode 100644 index 000000000..6bfc02f8d --- /dev/null +++ b/prometheus-node-exporter/Pkgfile @@ -0,0 +1,36 @@ +# Description: Exporter for machine metrics +# URL: https://github.com/prometheus/node_exporter +# Maintainer: Tim Biermann, tbier at posteo dot de +# Depends on: go +# Optional: python3-bcrypt + +name=prometheus-node-exporter +version=1.4.0 +release=1 +source=(https://github.com/prometheus/node_exporter/archive/v$version/$name-$version.tar.gz + prometheus-node-exporter.service config.yml + gen-pass.py) + +build() { + cd node_exporter-$version + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" + + mkdir "$PKGMK_SOURCE_DIR/gopath" || true + export GOPATH="$PKGMK_SOURCE_DIR/gopath" + + go build \ + -trimpath \ + -buildmode=pie \ + -mod=readonly \ + -modcacherw \ + -o node_exporter . + + install -Dm755 node_exporter $PKG/usr/bin/node_exporter + + install -Dm755 $SRC/prometheus-node-exporter.service $PKG/etc/rc.d/$name + install -Dm644 $SRC/gen-pass.py $PKG/usr/lib/$name/gen-pass.py + install -Dm644 $SRC/config.yml $PKG/etc/node-exporter/config.yml +} diff --git a/prometheus-node-exporter/README.md b/prometheus-node-exporter/README.md new file mode 100644 index 000000000..e27afc09a --- /dev/null +++ b/prometheus-node-exporter/README.md @@ -0,0 +1,16 @@ +prometheus-node-exporter README +=============================== + +## Generating a password + +For generating a password you either need opt/apache installed to be able +to use `htpasswd -nBC 10 "" | tr -d ':\'; echo` or use install +`contrib/python3-bcrypt` and use +`/usr/lib/prometheus-node-exporter/gen-pass.py`. Use the generated password +hash to fill in the skeleton under `/etc/node-exporter/config.yml`. + +## Using tls + +Generate a valid certificate according to the `config.yml` or use a proper one. +If you use a self signed certificate you will make your prometheus scraper +trust it. diff --git a/prometheus-node-exporter/config.yml b/prometheus-node-exporter/config.yml new file mode 100644 index 000000000..08a1a0158 --- /dev/null +++ b/prometheus-node-exporter/config.yml @@ -0,0 +1,9 @@ +# openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout node_exporter.key -out node_exporter.crt -subj "/C=ZA/ST=CT/L=SA/O=VPN/CN=localhost" -addext "subjectAltName = DNS:localhost" +#tls_server_config: +# cert_file: node_exporter.crt +# key_file: node_exporter.key +# +#basic_auth_users: +# prometheus: encrypted_password +# +# End of file diff --git a/prometheus-node-exporter/gen-pass.py b/prometheus-node-exporter/gen-pass.py new file mode 100755 index 000000000..9b42b51e7 --- /dev/null +++ b/prometheus-node-exporter/gen-pass.py @@ -0,0 +1,7 @@ +#!/usr/bin/python3 +import getpass +import bcrypt + +password = getpass.getpass("password: ") +hashed_password = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()) +print(hashed_password.decode()) diff --git a/prometheus-node-exporter/prometheus-node-exporter.service b/prometheus-node-exporter/prometheus-node-exporter.service new file mode 100755 index 000000000..43edfce4e --- /dev/null +++ b/prometheus-node-exporter/prometheus-node-exporter.service @@ -0,0 +1,33 @@ +#!/bin/sh +# +# /etc/rc.d/prometheus-node-exporter: start/stop prometheus-node-exporter daemon +# + +SSD=/sbin/start-stop-daemon +PROG=/usr/bin/node_exporter +PORT=9100 +OPTS="--collector.processes --web.listen-address=":${PORT}" --web.config=/etc/node-exporter/config.yml" + +case $1 in + start) + $SSD --start -b --exec $PROG -- $OPTS ;; + stop) + $SSD --stop --retry 10 --exec $PROG ;; + restart) + $0 stop + $0 start + ;; + status) + $SSD --status --exec $PROG + case $? in + 0) echo "$PROG is running with pid $(pidof $PROG)" ;; + 1) echo "$PROG is not running but the pid file $PID exists" ;; + 3) echo "$PROG is not running" ;; + 4) echo "Unable to determine the program status" ;; + esac + ;; + *) + echo "usage: $0 [start|stop|restart|status]" ;; +esac + +# End of file |