Skip to content

Instantly share code, notes, and snippets.

@apsega
Last active May 8, 2018 17:26
Show Gist options
  • Save apsega/801b09c27ccdfa4c724e0c583a771ee8 to your computer and use it in GitHub Desktop.
Save apsega/801b09c27ccdfa4c724e0c583a771ee8 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
VERSION="0.15.2"
ARCHITECTURE=$(uname -m)
if [[ ${ARCHITECTURE} == "x86_64" ]]
then
ARCHITECTURE="amd64"
fi
cd /tmp/
wget -q https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-${ARCHITECTURE}.tar.gz
tar zxfv node_exporter-${VERSION}.linux-${ARCHITECTURE}.tar.gz
mv -v /tmp/node_exporter-${VERSION}.linux-${ARCHITECTURE}/node_exporter /usr/local/bin/node-exporter
# systemd manifest
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]
ExecStart=/usr/local/bin/node-exporter
Type=simple
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# start service
systemctl enable node-exporter.service
systemctl start node-exporter.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment