CONSUL_HTTP_TOKEN=27c74c79-467f-475b-a782-0e2a10a839e8 CONSUL_URL=http://consul-d0.uenpay.com ipaddr=`ip addr show $(ip route | grep default | awk '{print $5}') | awk '/inet / {split($2, a, "/"); print a[1]}'|head -n1` host=`hostname` tag=d0-others servicename=node-exporter portnum=29100 ##--------------- curl -H "x-consul-token: ${CONSUL_HTTP_TOKEN}" \ -X PUT \ -d '{ "id": "'"$servicename"'-'"$host"'-'"$ipaddr"'", "name": "'"$servicename"'", "address": "'"$ipaddr"'", "port": '"$portnum"', "tags": ["'"$tag"'"], "Meta": { "hostname": "'"$host"'" }, "checks": [ { "tcp": "'"$ipaddr"':'"$portnum"'", "interval": "10s", "timeout": "5s" } ] }' \ "${CONSUL_URL}/v1/agent/service/register"