Created
October 22, 2018 15:49
-
-
Save jamo/29b4e5108a12b333542bfbad0c270fcb 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 | |
plot() { | |
key=$1 | |
files=$(ls ./work/$key* | awk '{ split($0, ar, " "); printf("%s ", ar[1] ) }') | |
gnuplot -e "set timefmt '%Y-%m-%d-%H-%M'; set terminal svg size 1280,500 fname 'Verdana' fsize 10; set xdata time; set datafile sep ','; set key noenhanced ; files=\"$files \"; plot for [file in files] file using 1:2 w lines title substr(file, 8, 200)" | |
} | |
pods=($(kubectl get pods --no-headers -l app=now-proxy-production | awk '{ split($0, ar, " "); print(ar[1]) }')) | |
getData() { | |
for pod in "${pods[@]}"; do | |
kubectl exec -it "$pod" -c nginx -- curl "127.0.0.1:1235/$1" | head -n -1 | tail -n+2 | | |
awk ' | |
{ | |
split($0, ar, "\n"); | |
} | |
{ | |
for(i in ar) { | |
split(ar[i], res, ";") | |
printf("%s, %d\n", strftime("%Y-%m-%d-%H-%M", res[1]), res[2]) | |
} | |
}' > work/"$key-$pod" | |
done | |
} | |
now=$(date +%s) | |
pass() { | |
while read line; do | |
p $line | |
done | |
} | |
p() { | |
echo $@ >> index.html | |
} | |
cacheData() { | |
metrics=(aliases certs deployments deployment_paths) | |
suffixes=(_cache_miss_by_id _cache_miss_by_hostname _cache_hits_by_id _cache_hits_by_hostname _cache_stale_refresh_by_id _cache_stale_refresh_by_hostname _cache_lock_locks_claimed _cache_lock_miss) | |
cosmosprefix=('-westeurope_now-prod_' '_now-prod_') | |
cosmossuffix=(_cosmos_ru _cosmos_count _cosmos_status_200 _cosmos_status_404 _cosmos_status_429) | |
for metric in "${metrics[@]}"; do | |
p "<div>" | |
p "<h2>$metric</h2>" | |
for suffix in "${suffixes[@]}"; do | |
key=$metric$suffix | |
p "<div>" | |
p "<h3>$key $suffix</h3>" | |
p "<figure>" | |
getData $key | |
plot $key | pass | |
p "</figure>" | |
p "</div>" | |
done | |
for cprefix in "${cosmosprefix[@]}"; do | |
for csuffix in "${cosmossuffix[@]}"; do | |
key=$cprefix$metric$csuffix | |
p "<div>" | |
p "<h3>$key</h3>" | |
p "<figure>" | |
getData $key | |
plot $key | pass | |
p "</figure>" | |
p "</div>" | |
done | |
done | |
p "</div>" | |
done | |
} | |
rm index.html | |
mkdir work | |
p '<body>' | |
cacheData | |
p '</body>' | |
rm -rf work | |
#plot aliases_cache_miss_by_hostname | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment