1 |
commit: 088314f7ed8c809b1ea61e9586bbd96b0f36e5c8 |
2 |
Author: Theo Chatzimichos <tampakrap <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Dec 25 19:53:38 2012 +0000 |
4 |
Commit: Theo Chatzimichos <tampakrap <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Dec 25 19:53:38 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-mirrorstats.git;a=commit;h=088314f7 |
7 |
|
8 |
Add script to catch bad mirrors |
9 |
|
10 |
--- |
11 |
validation/mirror-validate.sh | 41 +++++++++++++++++++++++++++++++++++++++++ |
12 |
1 files changed, 41 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/validation/mirror-validate.sh b/validation/mirror-validate.sh |
15 |
new file mode 100755 |
16 |
index 0000000..bd63d17 |
17 |
--- /dev/null |
18 |
+++ b/validation/mirror-validate.sh |
19 |
@@ -0,0 +1,41 @@ |
20 |
+#!/bin/bash |
21 |
+ |
22 |
+. /etc/init.d/functions.sh |
23 |
+ |
24 |
+if [[ $1 == "distfiles" ]]; then |
25 |
+ MIRMON_PATH="source" |
26 |
+elif [[ $1 == "rsync" ]]; then |
27 |
+ MIRMON_PATH="portage" |
28 |
+else |
29 |
+ echo "Need to specify distfiles or rsync" |
30 |
+ exit 1 |
31 |
+fi |
32 |
+ |
33 |
+STATE_FILE="/var/www/mirrorstats.gentoo.org/gentoo-mirrorstats/${MIRMON_PATH}_mirrors/var/mirmon.state" |
34 |
+ |
35 |
+count_bad_status() { |
36 |
+ BAD_STATUS_COUNT=0 |
37 |
+ i=0 |
38 |
+ while (( i++ < ${#FULL_STATUS} )); do |
39 |
+ echo $(expr substr "$FULL_STATUS" $i 1) | grep -v -q s && \ |
40 |
+ BAD_STATUS_COUNT=$((BAD_STATUS_COUNT + 1)) |
41 |
+ done |
42 |
+ [ $BAD_STATUS_COUNT -ge 10 ] && echo $NAME |
43 |
+} |
44 |
+ |
45 |
+while read mirror; do |
46 |
+ NAME=`echo $mirror | cut -d' ' -f1` |
47 |
+ FULL_STATUS=`echo $mirror | cut -d' ' -f6 | cut -d'-' -f2` |
48 |
+ if [[ $1 == "distfiles" ]]; then |
49 |
+ LATEST_STATUS="${FULL_STATUS:9:5}" |
50 |
+ LATEST_STATUS_EXP="sssss" |
51 |
+ elif [[ $1 == "rsync" ]]; then |
52 |
+ LATEST_STATUS="${FULL_STATUS:13:1}" |
53 |
+ LATEST_STATUS_EXP="s" |
54 |
+ fi |
55 |
+ if [[ $FULL_STATUS != "ssssssssssssss" ]]; then |
56 |
+ if [[ $LATEST_STATUS != $LATEST_STATUS_EXP ]]; then |
57 |
+ count_bad_status |
58 |
+ fi |
59 |
+ fi |
60 |
+done < $STATE_FILE |