#!/bin/bash # The blackbox target file as it will be read by prometheus blackbox=$DATA_DIR/all-targets.yml echo '- targets:' > "$blackbox" # Find each service and its target while IFS=';' read -r _ _ service target do # Find all ips of this target IFS=';' read -ra ips < <(grep "$target" /docker/servers.csv) ips=("${ips[@]:6}") [ -z "$ips" ] && continue for ip in ${ips[@]} do # Monitor each ip the service must answer on echo " - $service@$ip" >> "$blackbox" done done < <(grep -v '^#' /docker/services.csv) echo "$blackbox"