rougail/bin/gen_rpt

138 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
###########################################################################
# EOLE - 2010
# Copyright Pole de Competence Eole (Ministere Education - Academie Dijon)
# Licence CeCill cf /root/LicenceEole.txt
# eole@ac-dijon.fr
#
# gen_rpt
#
# Génère un rapport d'anomalie
#
###########################################################################
TestConf()
{
[ -e "$1" ] && return 0
tput setaf 3
echo "* Erreur $0 : le fichier de configuration $1 absent"
echo "* Instanciez votre serveur"
tput sgr0
exit 1
}
clear
. /usr/lib/eole/ihm.sh
. /usr/lib/eole/utils.sh
only_root
numero_etab=$(CreoleGet numero_etab)
CONFIGEOL='/etc/eole/config.eol'
EOLEDIRS="/usr/share/eole/creole/dicos"
PATCHDIR="/usr/share/eole/creole/patch"
TestConf $CONFIGEOL
EOLERELEASE="/etc/eole/release"
if [ ! -e $EOLERELEASE ]; then
EchoRouge "Fichier $EOLERELEASE est introuvable"
exit 1
fi
. $EOLERELEASE
Module="${EOLE_MODULE}-${EOLE_VERSION}"
echo "Récupération des informations ..."
RepRpt="/tmp/GenRpt"
rm -fr $RepRpt 2> /dev/null
mkdir $RepRpt
mkdir $RepRpt/log
mkdir $RepRpt/eole
mkdir $RepRpt/system
Rpt=$RepRpt"/Rpt-"$Module"-"$numero_etab
Mel="eole@ac-dijon.fr"
# les fichiers texte
echo "Config.eol"
/bin/cp -f $CONFIGEOL $RepRpt/eole
echo "Diagnose"
/usr/bin/diagnose -LT >> $RepRpt/diagnose.txt 2>&1
echo Pstree
pstree >> $RepRpt/system/pstree.txt 2>&1
echo Lshw
lshw >> $RepRpt/system/lshw.txt 2>&1
echo Lsusb
lsusb >> $RepRpt/system/lsusb.txt 2>&1
echo Lspci
lspci >> $RepRpt/system/lspci.txt 2>&1
echo Iptables
iptables -nvL > $RepRpt/system/iptables.txt 2>&1
iptables -nvL -t nat >> $RepRpt/system/iptables.txt 2>&1
echo History
grep -v "^#" /root/.bash_history > $RepRpt/system/history.txt
echo Paquets
dpkg-query -W > $RepRpt/system/packages.txt 2>&1
# les gz
echo Syslog
for log in rsyslog su sudo kernel cron auth chpasswd exim ; do
[ -d /var/log/rsyslog/local/$log ] && gzip -rc /var/log/rsyslog/local/$log > $RepRpt/log/$log.gz
done
echo Dmesg
dmesg > $RepRpt/log/dmesg.log 2>&1
gzip $RepRpt/log/dmesg.log
echo Creole.log
gzip -c /var/log/reconfigure.log > $RepRpt/log/reconfigure.log.gz
echo Dicos
gzip -rc $EOLEDIRS > $RepRpt/eole/dicos.gz
echo Patch
gzip -rc $PATCHDIR > $RepRpt/eole/patch.gz
echo Stats
gzip -rc /usr/share/zephir/monitor/stats > $RepRpt/stats.gz
# spécifique Scribe
if [ -f /var/www/ead/extraction/tmp/rapport.txt ];then
echo "Rapport d'extraction"
gzip -rc /var/www/ead/extraction/tmp/rapport.txt > $RepRpt/log/extraction.log.gz
fi
if [ -f /var/log/controle-vnc/main.log ];then
echo 'Log client scribe'
gzip -rc /var/log/controle-vnc/main.log > $RepRpt/log/controle-vnc.log.gz
fi
# spécifique Scribe/Horus/Eclair
if [ -d /var/lib/eole/reports ];then
echo "Rapport (sauvegarde/maj/...)"
gzip -rc /var/lib/eole/reports > $RepRpt/log/rapport.log.gz
fi
# spécifique Amon
if [ -f '/usr/share/eole/test-rvp' ];then
echo 'Rvp'
/usr/sbin/ipsec status &> $RepRpt/ipsec.status 2>&1
fi
# Rapport debsums
if [ -x '/usr/share/eole/debsums/show-reports.py' ]; then
echo "Rapport debsums"
/usr/share/eole/debsums/show-reports.py > ${RepRpt}/log/rapport-debsums.log 2>&1
fi
echo
Archive=$Module-$numero_etab".tar.gz"
echo "Création de l'archive locale $Archive"
tar -C /tmp -czf $Archive GenRpt
echo
Question_ouinon "Envoyer l'archive par email ?"
if [ $? -eq 1 ];then
exit 0
fi
echo "Destinataire du message : "
echo -n "[$Mel] : "
read mail
if [ "$mail" == "" ];then
mail=$Mel
fi
echo -n "Commentaire : "
read comment
echo "$comment"|mutt -a $Archive -s "Rapport $Module de $numero_etab" -c $mail -e "set copy=no"