summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg2021-08-03 12:11:22 +0200
committerGeorg2021-08-03 12:11:22 +0200
commit6e304a28ee3a1976ed6c9f82ce370006cccb4198 (patch)
tree18260a8087f944883f562c8922baefffb176b47d
parent11db7b721f92267f7a706568a9d537682a40c36a (diff)
parent9c35dec520f486c9657fa8abe57ba0b7c438e222 (diff)
downloadsystem-6e304a28ee3a1976ed6c9f82ce370006cccb4198.tar.gz
system-6e304a28ee3a1976ed6c9f82ce370006cccb4198.tar.bz2
system-6e304a28ee3a1976ed6c9f82ce370006cccb4198.zip
Merge branch 'master' of ssh://git.com.de:28/LibertaCasa/system
-rwxr-xr-xscripts/sh/deploy_node_exporter.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/sh/deploy_node_exporter.sh b/scripts/sh/deploy_node_exporter.sh
new file mode 100755
index 0000000..d6551f0
--- /dev/null
+++ b/scripts/sh/deploy_node_exporter.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+if [ -d /etc/systemd/system ]
+then
+if [ ! -d /opt/node_exporter ]
+then
+groupadd -g 501 prometheus
+useradd -rd /opt/node_exporter -g 501 -u 501 -s /bin/false node_exporter
+mkdir /opt/node_exporter
+curl -Lo /opt/node_exporter/LICENSE 192.168.0.120/opt/node_exporter/LICENSE
+curl -Lo /opt/node_exporter/NOTICE 192.168.0.120/opt/node_exporter/NOTICE
+curl -Lo /opt/node_exporter/node_exporter 192.168.0.120/opt/node_exporter/node_exporter
+chmod +x /opt/node_exporter/node_exporter
+chown -R node_exporter:prometheus /opt/node_exporter
+chmod 750 /opt/node_exporter
+cat <<'EOF' >/etc/systemd/system/node_exporter.service
+[Unit]
+Description=Prometheus Node Exporter
+After=network.target
+
+[Service]
+User=node_exporter
+Group=prometheus
+Type=simple
+ExecStart=/opt/node_exporter/node_exporter --web.listen-address=":9200"
+
+[Install]
+WantedBy=multi-user.target
+EOF
+systemctl enable --now node_exporter
+if [ -x $(command -v firewall-cmd) ]
+then
+firewall-cmd --zone=internal --add-port=9200/tcp --permanent
+firewall-cmd --reload
+else
+echo "No firewalld, skipping."
+fi
+echo "OK"
+else
+echo "Found traces of an existing installation. Aborted."
+fi
+else
+echo "Not compatible with this system. No systemd?"
+fi