]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tilecache/templates/tilecache-fastest-peers.erb
Remove remains of squid sibling support on tile caches
[chef.git] / cookbooks / tilecache / templates / tilecache-fastest-peers.erb
1 #!/bin/bash
2
3 # Find performance reports for last few minutes
4 # Add up total time taken to download tile grouped by remote server
5 # Remove 1 second per successful time report (de-prioritise new servers)
6 # Add 30 seconds per failed time report request
7 # Sort time reports
8 # Strip to best 4 server names
9
10 /usr/bin/find /srv/tilecache/data/ -type f -iname 'tilecache-*.txt' -mmin -10 -print0 \
11  | /usr/bin/xargs -0 --no-run-if-empty /usr/bin/tail --quiet -n 20 \
12  | /usr/bin/awk -F ',' '$2 == 200 {time[$3] += $1; time[$3] -= 1} $2 != 200 {time[$3] +=30} END{for (i in time) print time[i], i}' \
13  | /usr/bin/sort -k1n \
14  | /usr/bin/cut -d '/' -f 3 \
15  | /bin/grep -E '(openstreetmap|localhost)' \
16  | /usr/bin/head -n 4