curl url | sh 方式:
install.sh
#!/bin/bash
#-------------------VAR------------------------------------------------
ABS_INSTALL_PATH=/usr/local/bin/
ABS_INSTALL_PREFIX=/usr/local/bin/node_exporter
#-------------------FUN------------------------------------------------
install_package(){
if [ -e ${ABS_INSTALL_PREFIX} ];then
echo "====================WARNING====================="
echo "you may have installed node_exporter "
else
yum install wget -y
cd ${ABS_INSTALL_PATH}
wget http://10.0.0.80/envs/yum/prometheus_node_exporter/node_exporter
if [ -e node_exporter ];then
chmod +x node_exporter
groupadd -r prometheus
useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus
cd /usr/lib/systemd/system
wget http://10.0.0.80/envs/yum/prometheus_node_exporter/node_exporter.service
systemctl start node_exporter
systemctl enable node_exporter
else
echo "=node_exporter file not exist"
fi
fi
}
main(){
install_package
}
#-------------------PROGRAM--------------------------------------------
main
node_exporter.service
[Service] User=prometheus Group=prometheus ExecStart=/usr/local/bin/node_exporter [Install] WantedBy=multi-user.target [Unit] Description=node_exporter After=network.target
手动起:
nohup /usr/local/bin/node_exporter --web.listen-address=":9101" &