#!/bin/bash
#	http://paste.ubuntu.com/628120/

ETH=$1
LINE=`ethtool -i $ETH | grep driver`
DRIVER=${LINE##*:}
BASE=$DRIVER-`uname -n`-log

OUTPUT=$BASE.basic
echo "--- BASIC ---"

cat /etc/lsb-release >> $OUTPUT
uname -a >> $OUTPUT

OUTPUT=$BASE.bios
echo "--- BIOS ---"
dmidecode >> $OUTPUT

FILE='/var/log/dmesg'
set -- `wc -l $FILE`
LEN=$1

rmmod $DRIVER
OUTPUT=$BASE.modprobe
echo "--- MODPROBE ---"
modprobe -v $DRIVER debug=21 >> $OUTPUT

OUTPUT=$BASE.dmesg
echo "--- DMESG ---"
set -- `wc -l $FILE`
NEWLEN=$1
tail -$((NEWLEN-LEN)) $FILE >> $OUTPUT

OUTPUT=$BASE.ethtool
echo "--- ETHTOOL ---"
ethtool $ETH >> $OUTPUT
ethtool -i $ETH >> $OUTPUT
ethtool -e $ETH >> $OUTPUT

OUTPUT=$BASE.lspci
echo "--- VERBOSE LSPCI ---"
lspci -v -v >> $OUTPUT

OUTPUT=$BASE.interrupts
echo "--- INTERRUPTS ---"
cat /proc/interrupts >> $OUTPUT

OUTPUT=$BASE.tar.gz
tar --remove-files -czf $OUTPUT $BASE.*
echo "--- DONE $OUTPUT ---"


syntax highlighted by Code2HTML, v. 0.9.1