feat: Better repo count

Provides a way to count mirrors with more than one day behind
This commit is contained in:
Rodrigo de Avila 2023-08-17 10:42:02 -03:00
parent 9e21930525
commit 9422bcab52
No known key found for this signature in database
2 changed files with 37 additions and 12 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
run.md

48
run.sh
View File

@ -17,6 +17,12 @@ fi
ORIGINAL_TIME=$(curl -fsSL "https://rsync.repo.almalinux.org/almalinux/TIME")
IN_SYNC=0
UP_TO_12H=0
UP_TO_24H=0
MORE_THAN_24H=0
UNAVAILABLE=0
# Example: https://admin.fedoraproject.org/mirrormanager/propagation
# This diagram shows how many mirrors for the development branch have a repomd.xml file which is the
@ -25,18 +31,16 @@ ORIGINAL_TIME=$(curl -fsSL "https://rsync.repo.almalinux.org/almalinux/TIME")
# File names
FILES=$(curl -fsSL https://api.github.com/repos/AlmaLinux/mirrors/contents/mirrors.d | jq -r '.[].name')
TABLE=""
echo "# AlmaLinux Mirror Propagation Report"
echo ""
echo "This service provides information about the status of the AlmaLinux mirrors. The report shows the time it takes for updates to propagate to the mirrors, as well as the number of mirrors that have been updated. This information can be used to identify mirrors that are not up to date, and to troubleshoot any problems with the mirror propagation process."
echo ""
echo "## Primary mirror info"
echo ""
echo "- Address: \`rsync.repo.almalinux.org\`"
echo "- Last update: \`$(date -ud "@$ORIGINAL_TIME" +"%Y-%m-%d %H:%M:%S") UTC\`"
echo ""
echo "| Mirror Name | Sponsor | Status |"
echo "|:--|:--|:--|"
echo "- Primary mirror: \`rsync.repo.almalinux.org\`, updated at \`$(date -ud "@$ORIGINAL_TIME" +"%Y-%m-%d %H:%M:%S") UTC\`"
TABLE+=$(echo "| Mirror Name | Sponsor | Status |\n")
TABLE+=$(echo "|:--|:--|:--|\n")
for FILE in $FILES; do
DETAILS=$(curl -fsSL "https://raw.githubusercontent.com/AlmaLinux/mirrors/master/mirrors.d/$FILE")
@ -60,21 +64,41 @@ for FILE in $FILES; do
if [ "$DIFF" -eq 0 ]; then
TIME="IN SYNC"
IN_SYNC=$((IN_SYNC + 1))
else
TIME="$(date -d "@$(($DIFF))" +"%Hh %Mmin") behind"
DAYS=$((epoch / 86400))
HOURS=$(( (epoch % 86400) / 3600 ))
if [ "$DAYS" -eq 0 ]; then
if [ "$HOURS" -le 12 ]; then
UP_TO_12H=$((UP_TO_12H + 1))
else
UP_TO_24H=$((UP_TO_24H + 1))
fi
else
MORE_THAN_24H=$((MORE_THAN_24H + 1))
fi
fi
else
TIME="Unavailable"
UNAVAILABLE=$((UNAVAILABLE + 1))
fi
else
TIME="Unavailable"
UNAVAILABLE=$((UNAVAILABLE + 1))
fi
echo "| $NAME | $SPONSOR | $TIME |"
TABLE+=$(echo "| $NAME | $SPONSOR | $TIME |\n")
done
echo ""
echo "Last report update: \`$(date -u +"%Y-%m-%d %H:%M:%S") UTC\`"
echo ""
echo "- In sync: $IN_SYNC"
echo "- Up to 12h: $UP_TO_12H"
echo "- Up to 24h: $UP_TO_24H"
echo "- More than 24h: $MORE_THAN_24H"
echo "- Unavailable: $UNAVAILABLE"
echo "- Report update: \`$(date -u +"%Y-%m-%d %H:%M:%S") UTC\`"
exit 0
echo -e $TABLE
exit 0