Skip to content

Instantly share code, notes, and snippets.

@egeneralov
Last active June 8, 2020 09:36
Show Gist options
  • Select an option

  • Save egeneralov/89fa20abc3fb46d2cd0b5e83c773e833 to your computer and use it in GitHub Desktop.

Select an option

Save egeneralov/89fa20abc3fb46d2cd0b5e83c773e833 to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
curl -sL https://github.com/prometheus/node_exporter/releases/download/v1.0.0/node_exporter-1.0.0.linux-amd64.tar.gz | tar xzvf - -C /opt/
cat << EOF > /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
[Service]
ExecStart=/opt/node_exporter-1.0.0.linux-amd64/node_exporter --web.listen-address=0.0.0.0:9100
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter
---
- hosts: all
gather_facts: no
tasks:
- apt:
update_cache: yes
cache_valid_time: 3600
name:
- unzip
- unarchive:
src: https://github.com/prometheus/node_exporter/releases/download/v1.0.0/node_exporter-1.0.0.linux-amd64.tar.gz
dest: /opt
remote_src: yes
- copy:
dest: /etc/systemd/system/node_exporter.service
content: |
[Unit]
Description=Node Exporter
[Service]
ExecStart=/opt/node_exporter-1.0.0.linux-amd64/node_exporter --collector.cpu.info --collector.systemd.enable-task-metrics --collector.systemd.enable-restarts-metrics --collector.systemd.enable-start-time-metrics --collector.interrupts --collector.logind --collector.mountstats --collector.ntp --collector.processes --collector.systemd --collector.tcpstat --collector.wifi --web.listen-address="0.0.0.0:9100" --web.disable-exporter-metrics --log.format=json
[Install]
WantedBy=multi-user.target
- systemd:
name: node_exporter.service
daemon_reload: yes
state: restarted
enabled: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment