Home‎ > ‎Scripts‎ > ‎

Linux System Crash Report

echo ----------------------------------;\
echo - System Crash Report 3.1 Beta ;\
echo - Not Ready For Production ;\
echo - Written by Joe Ciancimino 2009 ;\
echo ----------------------------------;\
dep_0_GET_ANYKEY(){
tput smso
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
ANYIN=`dd bs=1 count=1 2>/dev/null`
stty "$oldstty"
} ;\
dep_1_GET_KEY(){
tput smso
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
USERIN=`dd bs=1 count=1 2>/dev/null`
stty "$oldstty"
} ;\
dep_2_SETUP(){
BOOTCOUNT=0
LOG=0
LOOPA=0
LOOPB=0
MESSEGES[1]=0
TIMESTAMP=0
USERIN=9999
USEROUT=0
} ;\
dep_3_EXIT(){
unset BOOTCOUNT LOG LOOPA LOOPB MESSEGES TIMESTAMP USERIN USEROUT
unset dep_1_GET_KEY dep_2_SETUP dep_3_EXIT MENU SEARCH MAIN_LOOP_dep
} ;\
dep_4_LOOPA(){
for LOOPA in `echo ${MESSEGES[@]}` ; do \
LOOPB=`wc -l $LOOPA \
|awk '{print $1}'` ; \
tail -n $(($LOOPB-1)) $LOOPA |\
grep restart ;\
done
} ;\
dep_5_BOOT_COUNT(){
dep_4_LOOPA |wc -l
} ;\
dep_6_TIMESTAMP(){
for LOOPA in `echo ${MESSEGES[@]}` ; do \
LOOPB=`wc -l $LOOPA \
|awk '{print $1}'` ; \
tail -n $(($LOOPB-1)) $LOOPA \
|grep -B1 restart ; \
done | head -n $(($USERIN*2)) |tail -n 2 |head -n1 | cut -b1-12
} ;\
MENU(){
if [ $USERIN -eq $USEROUT ] ; then return ; fi
clear
MESSEGES[1]=`find /var/log/messages* | xargs file | awk '{ if ( $2 == "ASCII" ) print $1 }'| cut -d: -f1`
BOOTCOUNT=`dep_5_BOOT_COUNT`
echo The system has booted $BOOTCOUNT times from the information in the logs.
echo
echo ---- 0 Exit Program
dep_4_LOOPA | cat -n
echo
echo Select which occurrence to show a report on - 0 through $BOOTCOUNT
echo
dep_1_GET_KEY
if [ $USERIN -eq $USEROUT ] ; then dep_3_EXIT ; fi
} ;\
SEARCH(){
if [ $USERIN -eq $USEROUT ] ; then return ; fi
TIMESTAMP=`dep_6_TIMESTAMP`
echo
echo This will take a few moments. Please wait.
LOG[1]=`find /var/log/. | xargs file | awk '{ if ( $2 == "ASCII" ) print $1 }'| cut -d: -f1`
echo ${LOG[@]} | xargs grep -h "$TIMESTAMP" | sort
USERIN=9999
echo
echo Press Any Key
dep_0_GET_ANYKEY
} ;\
MAIN_LOOP_1_dep(){
dep_2_SETUP
while [ $USERIN != $USEROUT ] ; do \
MENU
if [ $USERIN -eq $USEROUT ] ; then return ; fi
SEARCH
done
dep_3_EXIT
} ;\
MAIN_LOOP_1_dep ;\
Comments