systemd 管理node_exporter
https://prometheus.io/download/#node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
~]# tar -xf node_exporter-1.7.0.linux-amd64.tar.gz
node_exporter-1.7.0.linux-amd64 node_exporter-1.7.0.linux-amd64.tar.gz
~]# cd node_exporter-1.7.0.linux-amd64
node_exporter-1.7.0.linux-amd64]# mv node_exporter /usr/bin/
cat > /usr/lib/systemd/system/node_exporter.service <<EOF
[Unit]
Description=node_exporter
After=syslog.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/node_exporter
Restart=always
RestartSec=10
StartLimitInterval=100
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
ss -lntup | grep 9100
tcp LISTEN 0 1024 [::]:9100 [::]:* users:(("node_exporter",pid=22493,fd=3))
docker 启动systemd
docker run -d --name node_exporter --restart=always --net="host" --pid="host" -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter --path.procfs=/host/proc --path.rootfs=/rootfs --path.sysfs=/host/sys --collector.filesystem.ignored-mount-points='^/(sys|proc|dev|host|etc)($$|/)'
mysql 监控
docker run -d --name mysqld_exporter -p 9104:9104 --restart always --network host -e DATA_SOURCE_NAME='exporter:2Pn284jV@(127.0.0.1:3306)/' prom/mysqld-exporter:v0.14.0 --collect.info_schema.processlist
systemd mysqld_expoter
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.1/mysqld_exporter-0.15.1.linux-amd64.tar.gz
cat /etc/mysqld_exporter.conf
[client]
user = exporter
password = 2Pn284jV
cat /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=node_exporter
After=syslog.target
After=network.target
[Service]
Type=simple
Environment="DATA_SOURCE_NAME=exporter:2Pn284jV@(127.0.0.1:3306)/"
ExecStart=/usr/bin/mysqld_exporter --collect.info_schema.processlist --config.my-cnf=/etc/mysqld_exporter.conf
Restart=always
RestartSec=10
StartLimitInterval=100
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start mysqld_exporter
systemctl enable mysqld_exporter