prometheus-with-blackbox/cron/bin/dump-registry-targets.sh
Eliezer Croitoru c8e9cc2cc9 1
2024-06-18 18:53:38 +03:00

16 lines
546 B
Bash
Executable File

#!/usr/bin/env bash
array=( blackbox-tcp_connect_tls blackbox-tcp blackbox-http_2xx_3xx_403 blackbox-icmp node_exporter mysqld_exporter )
for i in "${array[@]}"
do
RES=$(ruby /usr/local/bin/dump-targets-by-target-type.rb ${i})
echo "${RES}" > "/var/www/html/blackbox/${i}.json.in"
diff "/var/www/html/blackbox/${i}.json" "/var/www/html/blackbox/${i}.json.in" >/dev/null
if [ "$?" -gt "0" ];then
mv -vf "/var/www/html/blackbox/${i}.json.in" "/var/www/html/blackbox/${i}.json"
else
rm -vf "/var/www/html/blackbox/${i}.json.in"
fi
done