#!/bin/bash
# 
# This script takes dump of various log messages
# Once the log is generated, if there is a drive in /dev/sda (usualy the USB)
# it will take the mount point out of /etc/mtab and deal with the spaces.
# Note this will not work for multiple mounts on a system.  It will always got for /dev/sda
#

FILENAME="$1/dump`date +%Ih%Mm%Ss`_`date +%d``date +%m``date +%y`.log"


exec 3<>"$FILENAME"

echo "/****** Linux Version And Release Number Info ***********/" >&3
echo >&3
cat /proc/version >&3
echo >&3
echo >&3
echo >&3

echo "/****** Pi Hardware Info ***********/" >&3
echo >&3
cat /proc/cpuinfo >&3

echo >&3
echo >&3
echo >&3

echo "/****** Active Sessions Info ***********/" >&3
echo >&3
cat /proc/consoles >&3

echo >&3
echo >&3
echo >&3

echo "/****** XM Session Log Info ***********/" >&3
echo >&3
cat /home/pi/ProgramIt/release/bin/ProgramIt/ProgramIt.log >&3

echo >&3
echo >&3
echo >&3

echo "/****** Network Configuration Info ***********/" >&3
echo >&3
ifconfig >&3

echo >&3
echo >&3
echo >&3

echo "/****** log/messages : Last 100 Lines Dump ***********/" >&3
echo >&3
tail -100 /var/log/messages >&3

echo >&3
echo >&3
echo >&3

echo "/****** log/syslog : Last 50 Lines Dump ***********/" >&3
echo >&3
tail -50 /var/log/syslog >&3

echo >&3
echo >&3
echo >&3

echo "/****** All Running Processes Dump ***********/" >&3
echo >&3
ps -ef >&3
