Skip to content

Instantly share code, notes, and snippets.

@kanishkatn
Last active April 5, 2021 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanishkatn/fa5accb043a4544199d8fd6e8ec6b381 to your computer and use it in GitHub Desktop.
Save kanishkatn/fa5accb043a4544199d8fd6e8ec6b381 to your computer and use it in GitHub Desktop.
#!/bin/bash
NODE_EXPORTER_VERSION="0.18.0"
wget https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
tar -xzvf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
cd node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64
sudo cp node_exporter /usr/local/bin
# create user
sudo useradd --no-create-home --shell /bin/false node_exporter
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
echo '[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9500
[Install]
WantedBy=multi-user.target' > temp_node_exp
sudo cp temp_node_exp /etc/systemd/system/node_exporter.service
# enable node_exporter in systemctl
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
echo "Setup complete.
Add the following lines to /etc/prometheus/prometheus.yml:
sudo systemctl restart prometheus
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment