jean-cloud-services/services/monitoring.jean-cloud.net/create_monitoring_list.sh
2025-10-31 18:49:12 +01:00

25 lines
545 B
Bash
Executable File

#!/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"