Skip to content
Snippets Groups Projects
Verified Commit 6dad5b84 authored by David Beniamine's avatar David Beniamine
Browse files

Retrieve upgrade logs and summary from all schools

parent 1ab65a48
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
SCHOOLS=$(/usr/bin/ls *.log | grep -v "getlogs.log" | sed 's/\.log$//')
for school in $SCHOOLS
do
UPDATED=""
FAILED=""
file="$school.log"
MACS=$(awk '/^Trying/{print $5}' $file | sed -e 's/(//' -e 's/)//')
for mac in $MACS
do
name=$(grep "^Trying to boot .* ($mac)" $file | cut -d ' ' -f 4)
host="$name-$mac"
if [ $(grep "Begin host $name ($mac" -A 1 $file | grep "End host $name" -c) -eq 0 ]
then
UPDATED="$UPDATED $host"
else
FAILED="$FAILED $host"
fi
done
nUpdated=$(echo $UPDATED | wc -w)
nUpdatedTot=$(( $nUpdatedTot + $nUpdated))
nFailed=$(echo $FAILED | wc -w)
nFailedTot=$(( $nFailedTot + $nFailed))
if [ $nFailed -gt 0 ]
then
SCHOOLS_FAILED="$SCHOOLS_FAILED $school"
fi
echo "===================== $school ============================"
echo "Resultats pour l'école '$school'"
echo -e "\tsur un total de $(( $nUpdated + $nFailed )) postes"
echo -e "\t$nUpdated postes mis à jour ($UPDATED)"
echo -e "\t$nFailed postes non contactés ($FAILED)"
echo "========================================================="
done
nSchools=$(echo $SCHOOLS | wc -w)
nFailedSchools=$(echo $SCHOOLS_FAILED | wc -w)
echo "===================== Total ============================"
echo "Resultats globaux"
echo -e "\tsur un total de $(( $nUpdatedTot + $nFailedTot )) postes dans $nSchools écoles"
echo -e "\t$nUpdatedTot postes mis à jour"
echo -e "\t$nFailedTot postes non contactés dans $nFailedSchools écoles ($SCHOOLS_FAILED)"
echo "========================================================="
#!/bin/bash
ECOLES="alphonse-daudet ampere anatole-france anthoard bajatiere beauvert bizanet christophe-turc-vm christophe-turc-vo clemenceau diderot elisee-chatin ferdinand-buisson grand-chatelet houille-blanche jean-jaures joseph-vallier jules-ferry fontaine lac verderet leon-jouhaux buttes trembles liberation lucie-aubrac malherbe menon-sg menon-sh nicolas-chorier paul-bert paul-painleve saint-laurent sidi-brahim simone-lagrange"
for e in $ECOLES
do
echo "Retrieving logs for $e"
file=$(ssh -o "StrictHostKeyChecking=no" root@$e.ecole.grenoble.fr \
ssh partage ls -ltr /var/log/ | grep 'upgrade_all' \
| tail -n 1 | rev | cut -d ' ' -f 1 | rev)
ssh -o "StrictHostKeyChecking=no" root@$e.ecole.grenoble.fr ssh partage cat /var/log/$file > $e.log
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment