diff --git a/diagnose_me.sh b/diagnose_me.sh index ff06996..9f99ed4 100755 --- a/diagnose_me.sh +++ b/diagnose_me.sh @@ -5,31 +5,62 @@ exit 1 fi +log_file=diagnose_me.log + +log() { + echo "=========================================" + echo "BEGIN $1" + echo "=========================================" + while read data + do + echo "[$(date +"%D %T")] $data" + done + echo "=========================================" + echo "END $1" + echo "=========================================" + echo + echo +} + +ask_perm() { + echo -n "$1 (Y/n): " + read ans + case "$ans" in + y|Y|yes|YES|Yes) return 0 ;; + n|N|no|NO|No) return 1 ;; + *) return 0 ;; + esac +} + + echo "Cleaning up after any previous runs..." -rm diagnose_me.zip diagnose_me.tcpdump diagnose_me.log nohup.out +rm debug.log diagnose_me.zip diagnose_me.tcpdump diagnose_me.log nohup.out &> /dev/null echo "Gathering basic system information..." -uname -a > diagnose_me.log -echo >> diagnose_me.log +uname -a | log "uname" > $log_file echo "Gathering basic network information..." -ifconfig -a >> diagnose_me.log -echo >> diagnose_me.log -netstat -rnW >> diagnose_me.log -echo >> diagnose_me.log -netstat -vnlW >> diagnose_me.log -echo >> diagnose_me.log +ifconfig -a | log "ifconfig" >> $log_file +netstat -rnW | log "routing tables" >> $log_file +netstat -vnlW | log "netstat" >> $log_file +which iptables &> /dev/null +if [[ $? -eq 0 ]]; then + iptables -nL | log "iptables" >> $log_file +fi + +echo +echo echo "Gathering process information..." -ps auxwww >> diagnose_me.log -echo >> diagnose_me.log -echo >> diagnose_me.log +echo "WARNING: Process information may contain passwords!" +echo 'Check `ps auxwww` output before sending.' +ask_perm "Would you like to send process information?" && ps auxwww | log "process information" >> $log_file echo "Starting network capture..." nohup tcpdump -e -s 1514 -w diagnose_me.tcpdump & echo "Starting pc_autobackup in debug mode..." -nohup ./pc_autobackup.py --debug --log_file=diagnose_me.log & +nohup ./pc_autobackup.py --debug --log_file=debug.log & sleep 3 echo @@ -45,8 +76,14 @@ echo "Shutting down network capture..." pkill tcpdump +cat debug.log | log "pc_autobackup debug output" >> $log_file + echo "Archiving diagnostic files..." -zip -9 diagnose_me.zip diagnose_me.tcpdump diagnose_me.log nohup.out +zip -9 diagnose_me.zip diagnose_me.log diagnose_me.tcpdump nohup.out echo "Deleting diagnostic files..." -rm diagnose_me.tcpdump diagnose_me.log nohup.out \ No newline at end of file +rm debug.log diagnose_me.tcpdump diagnose_me.log nohup.out + +echo +echo +echo "Please email diagnose_me.zip to jeff@rebeiro.net" \ No newline at end of file