Last active
April 5, 2021 06:04
-
-
Save kanishkatn/fa5accb043a4544199d8fd6e8ec6b381 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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