Dernière activité 1748530138

yaisme's Avatar yaisme a révisé ce gist 1748530138. Aller à la révision

1 file changed, 47 insertions

node_exp_install.sh(fichier créé)

@@ -0,0 +1,47 @@
1 + #!/bin/bash
2 +
3 + # Define version
4 + VERSION="1.9.1"
5 +
6 + # Create user for node_exporter
7 + useradd --no-create-home --shell /usr/sbin/nologin node_exporter
8 +
9 + # Download and extract Node Exporter
10 + cd /tmp
11 + wget https://github.com/prometheus/node_exporter/releases/download/v$VERSION/node_exporter-$VERSION.linux-amd64.tar.gz
12 + tar xvf node_exporter-$VERSION.linux-amd64.tar.gz
13 +
14 + # Move binary to /usr/local/bin
15 + cp node_exporter-$VERSION.linux-amd64/node_exporter /usr/local/bin/
16 + chown node_exporter:node_exporter /usr/local/bin/node_exporter
17 +
18 + # Clean up
19 + rm -rf node_exporter-$VERSION.linux-amd64*
20 +
21 + # Create systemd service file
22 + cat <<EOF >/etc/systemd/system/node_exporter.service
23 + [Unit]
24 + Description=Prometheus Node Exporter
25 + Wants=network-online.target
26 + After=network-online.target
27 +
28 + [Service]
29 + User=node_exporter
30 + Group=node_exporter
31 + Type=simple
32 + ExecStart=/usr/local/bin/node_exporter
33 +
34 + [Install]
35 + WantedBy=default.target
36 + EOF
37 +
38 + # Reload systemd, enable and start service
39 + systemctl daemon-reexec
40 + systemctl daemon-reload
41 + systemctl enable --now node_exporter
42 +
43 + # Check status
44 + systemctl status node_exporter --no-pager
45 +
46 + echo "Node Exporter installation complete."
47 + echo "Access it via http://<server-ip>:9100/metrics"
Plus récent Plus ancien