Skip to content

Instantly share code, notes, and snippets.

@Erisa
Forked from galexrt/node_exporter.sh
Last active December 13, 2023 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Erisa/5690b4cec13254762217c867325b5808 to your computer and use it in GitHub Desktop.
Save Erisa/5690b4cec13254762217c867325b5808 to your computer and use it in GitHub Desktop.
Simple Prometheus node_exporter install script (Updated for 1.0.1)
#!/bin/bash
set +x
version="${VERSION:-1.6.1}"
arch="${ARCH:-linux-amd64}"
bin_dir="${BIN_DIR:-/usr/local/bin}"
wget "https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.$arch.tar.gz" \
-O /tmp/node_exporter.tar.gz
mkdir -p /tmp/node_exporter
cd /tmp || { echo "ERROR! No /tmp found.."; exit 1; }
tar xfz /tmp/node_exporter.tar.gz -C /tmp/node_exporter || { echo "ERROR! Extracting the node_exporter tar"; exit 1; }
cp "/tmp/node_exporter/node_exporter-$version.$arch/node_exporter" "$bin_dir"
chown root:staff "$bin_dir/node_exporter"
cat <<EOF > /etc/systemd/system/node_exporter.service
[Unit]
Description=Prometheus node exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOF
systemctl enable node_exporter.service
systemctl start node_exporter.service
echo "SUCCESS! Installation succeeded!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment