[CT420]: Add ./assignments/assignment1/code/query.sh

This commit is contained in:
2025-02-22 01:48:24 +00:00
parent fc8f91fe0e
commit 00ee323fe5

View File

@ -0,0 +1,19 @@
#!/bin/sh
file="results.tsv"
printf "timestamp\tremote\trefid\tst\tt\twhen\tpoll\treach\tdelay\toffset\tjitter\n" > "$file" # add headings to results file
# every 20 minutes for 8 hours
for i in $(seq 1 24); do
# add the ntpq peers data in TSV format to file with timestamp prepended
ntpq --peers | awk '
(NR > 2 ) {
timestamp = systime();
gsub(/ +/, "\t");
print(timestamp "\t" $0);
}
' >> "$file"
# do nothing for 20 minutes
sleep 20m
done