#!/bin/bash CONSUL_HTTP_TOKEN=27c74c79-467f-475b-a782-0e2a10a839e8 CONSUL_URL=http://consul-d1.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` for servicename in {node-exporter,script-exporter}; do curl -X PUT \ -H "x-consul-token: ${CONSUL_HTTP_TOKEN}" \ ${CONSUL_URL}/v1/agent/service/deregister/"${servicename}-${host}-${ipaddr}" done