Created
October 16, 2021 20:56
-
-
Save Voronenko/f635061573d68b328557b8c8094ef41c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HELP node_nslookup dns lookup time in ms | |
# TYPE node_nslookup gauge | |
node_nslookup{ns="1.2.3.4",record="api.cloudpayments.ru"} 0 | |
node_nslookup{ns="8.8.8.8",record="api.cloudpayments.ru"} 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
prom_file="nslookup_exporter.prom" | |
TEXTFILE_COLLECTOR_DIR="/var/prometheus/textfile_exporter" | |
lookup () { | |
rm ${TEXTFILE_COLLECTOR_DIR}/${prom_file}.* 2>/dev/null || true | |
echo "# HELP node_nslookup dns lookup time in ms" >> "${TEXTFILE_COLLECTOR_DIR}/${prom_file}.$$" | |
echo "# TYPE node_nslookup gauge" >> "${TEXTFILE_COLLECTOR_DIR}/${prom_file}.$$" | |
r="api.cloudpayments.ru"; query=$(dig $r | awk '/Query time/||/SERVER/'); echo $query | awk -F'[ #]' -v "r=$r" '{print "node_nslookup{ns=\""$8"\",record=\""r"\"} "$4}' >> "${TEXTFILE_COLLECTOR_DIR}/${prom_file}.$$" | |
r="api.cloudpayments.ru"; query=$(dig $r @8.8.8.8 | awk '/Query time/||/SERVER/'); echo $query | awk -F'[ #]' -v "r=$r" '{print "node_nslookup{ns=\""$8"\",record=\""r"\"} "$4}' >> "${TEXTFILE_COLLECTOR_DIR}/${prom_file}.$$" | |
mv "${TEXTFILE_COLLECTOR_DIR}/${prom_file}.$$" "${TEXTFILE_COLLECTOR_DIR}/${prom_file}" | |
} | |
for i in $(seq 6); do | |
lookup | |
sleep 10s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment