From 3e78391ed46918db5c217fccf31e06114bc02013 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Wed, 5 Jan 2022 10:02:46 +0800 Subject: [PATCH] update --- node_exporter.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/node_exporter.sh b/node_exporter.sh index 72f359f..f990238 100644 --- a/node_exporter.sh +++ b/node_exporter.sh @@ -23,10 +23,14 @@ depend(){ apt-get -y update apt-get install -y wget curl fi + #获取机器IP + myip=$(curl ipv4.ip.sb) #获取INSTANCE名称,如果为空,则获取hostname if [[ "$INSTANCE" == "" ]] then - INSTANCE=$(echo $HOSTNAME) + INSTANCE=$(echo $HOSTNAME)_${myip} + else + INSTANCE=${HOSTNAME}_${myip} fi } #下载 @@ -92,7 +96,9 @@ WantedBy=default.target" > /etc/systemd/system/node_exporter.service #安装完成 install_success(){ - + echo "----------------------------" + #推送数据到普罗米修斯以自动注册 + curl -u 'xiaoz:HAKrmCM6' -X POST -d "instance=${INSTANCE}" https://prometheus.rss.ink/api/v1/push_data echo "Installation is complete, please visit http://${myip}:29100" }