Last active
May 22, 2017 05:17
-
-
Save iiidefix/a466c65a9f49370f6a8d8fba493587d6 to your computer and use it in GitHub Desktop.
DNSDIST Dashboard
This file contains 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 | |
csv-table2 () { | |
awk \ | |
-F':' \ | |
'{ printf "%-*s%*s\n",'$1',$1,'$2',$2}' | |
} | |
csv-table4 () { | |
awk \ | |
'{ printf "%*s %-*s%*s%*s\n",'$1',$1,'$2',$2,'$3',$3,'$4',$4}' | |
} | |
box-title () { | |
sed \ | |
-e '1 s/\[/\\e['$1'm/g' \ | |
-e '1 s/\]/\\e['$2'm/g' | |
} | |
box-title1 () { | |
sed \ | |
-e '1 s/^/\\e['$1'm/g' \ | |
-e '1 s/$/\\e['$2'm/g' | |
} | |
box-size () { | |
awk '{printf "%-*s\n",'$1',$0}' | |
} | |
box-color () { | |
sed \ | |
-e 's/^/ \\e['$1'm /' \ | |
-e 's/$/ \\e[0m /' | |
} | |
box-move () { | |
sed \ | |
-e 's/^/\\e['$1'C/' \ | |
-e 's/$/\\e[K/' | |
} | |
box-moveS () { | |
local s=$(printf "%*s" ${1}) | |
sed \ | |
-e "s/^/${s}/" \ | |
-e 's/$//' | |
} | |
out-echo () { | |
xargs --null echo -ne | |
} | |
n=-1 | |
while true ; do | |
n=$(( ($n + 1) % 14 )) | |
[[ $n == 0 ]] \ | |
&& clear \ | |
&& echo -ne "\e[0m" | |
tput cup 0 0 | |
hostname \ | |
| box-color '37;44' \ | |
| out-echo | |
tput cup 0 0 | |
{ | |
uptime -p | xargs echo -n | |
echo -n " since " | |
uptime -s | |
} \ | |
| box-color '37;44' \ | |
| box-move $((3 + $(hostname | wc -m))) \ | |
| out-echo | |
tput cup 0 0 | |
date --rfc-2822 \ | |
| box-color '37;44' \ | |
| box-move 148 \ | |
| out-echo | |
tput cup 2 0 | |
dnsdist -e "showServers()" \ | |
| box-size 147 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;46' \ | |
| out-echo | |
tput cup 8 0 | |
dnsdist -e "showResponseLatency()" \ | |
| sed -e 's/\t/ /' \ | |
| box-size 80 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;41' \ | |
| box-moveS 67 \ | |
| out-echo | |
tput cup 8 0 | |
if [[ $n -le 1 ]]; then | |
echo "[Top Queries] Serverfail NXDOMAIN Refused Slow Clients Bandwith" | |
dnsdist -e "topQueries(15)" \ | |
| csv-table4 3 46 6 7 | |
elif [[ $n -le 3 ]]; then | |
echo "[Top Serverfail] NXDOMAIN Refused Slow Clients Bandwith Queries" | |
dnsdist -e "topResponses(15, 2)" \ | |
| csv-table4 3 46 6 7 | |
elif [[ $n -le 5 ]]; then | |
echo "[Top NXDOMAIN] Refused Slow Clients Bandwith Queries Serverfail" | |
dnsdist -e "topResponses(15, 3)" \ | |
| csv-table4 3 46 6 7 | |
elif [[ $n -le 7 ]]; then | |
echo "[Top Refused] Slow Clients Bandwith Queries Serverfail NXDOMAIN" | |
dnsdist -e "topResponses(15, 5)" \ | |
| csv-table4 3 46 6 7 | |
elif [[ $n -le 9 ]]; then | |
echo "[Top Slow] Clients Bandwith Queries Serverfail NXDOMAIN Refused" | |
dnsdist -e "topSlow(15)" \ | |
| csv-table4 3 46 6 7 | |
elif [[ $n -le 11 ]]; then | |
echo "[Top Clients] Bandwith Queries Serverfail NXDOMAIN Refused Slow" | |
dnsdist -e "topClients(15)" \ | |
| csv-table4 3 46 6 7 | |
else | |
echo "[Top Bandwith] Queries Serverfail NXDOMAIN Refused Slow Clients" | |
dnsdist -e "topBandwidth(15)" \ | |
| csv-table4 3 46 6 7 | |
fi \ | |
| box-size 63 \ | |
| box-title '1' '22' \ | |
| box-color '30;43' \ | |
| out-echo | |
tput cup 26 0 | |
dnsdist -e "grepq('', 13)" \ | |
| box-size 166 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;42' \ | |
| out-echo | |
tput cup 2 0 | |
{ | |
echo "Stats" | |
dnsdist -e 'getStatisticsCounters()' \ | |
| sed \ | |
-e 's/[{"}]//g' \ | |
-e 's/, /\n/g' \ | |
| csv-table2 22 6 | |
} \ | |
| box-size 28 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;45' \ | |
| box-move 151 \ | |
| out-echo | |
tput cup 30 0 | |
{ | |
echo "Cache" | |
dnsdist -e 'getPool(""):getCache():printStats()' \ | |
| csv-table2 17 9 | |
} \ | |
| box-size 26 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;43' \ | |
| box-move 153 \ | |
| out-echo | |
tput cup 40 0 | |
{ | |
echo "Cache iiidefix" | |
dnsdist -e 'getPool("iiidefix"):getCache():printStats()' \ | |
| csv-table2 17 9 | |
} \ | |
| box-size 26 \ | |
| box-title1 '1' '22' \ | |
| box-color '30;43' \ | |
| box-move 153 \ | |
| out-echo | |
tput cup 52 175 | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment