Created
April 27, 2018 12:27
-
-
Save benasse/3f353f3968320b9c8245875265506e68 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
| #!/bin/bash | |
| RECORD='ip-10-252-91-139.eu-west-2.compute.internal' | |
| echo 'DATE;TIME_CMD_ELAPSED;SERVER;HEADER;TIME_DIG' | |
| while true; do | |
| date_log=$(date +%Y-%m-%d\ %H\:%M\:%S) | |
| timestamps_start=$(date +%s%3N) | |
| test_resolution=$(dig @127.0.0.1 "${RECORD}" +retry=0 +timeout=1) | |
| timestamps_end=$(date +%s%3N) | |
| dns_time=$(echo -n "${test_resolution}" | grep ';; Query time:' | awk -F ":" '{print $2}') | |
| dns_server=$(echo -n "${test_resolution}" | grep ';; SERVER:' | awk -F '[:(]' '{print $2}') | |
| dns_header=$(echo -n "${test_resolution}" | grep ';; ->>HEADER<<-' | awk -F '[:,]' '{print $4}') | |
| time_elapsed=$((${timestamps_end}-${timestamps_start})) | |
| echo "${date_log};${time_elapsed};${dns_server};${dns_header};${dns_time}" | |
| # sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment