1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00
iiab/scripts/iiab-footprint
2019-04-15 19:05:24 +01:00

149 lines
4.1 KiB
Bash
Executable file

#!/bin/bash
# create a diagnostic footprint of network, and OS settings
read -p "\n\nPlease identiy yourself (<8 characters, no spaces)" who
if [ -z "$who" ]; then
who="noname"
fi
read -p "\n\nIf this is a request for help, what email addr for response" email
# Build up a meaningful name for transmission back to the development team
OS_VER=`cat /etc/iiab/iiab.env | grep OS_VER | cut -d'=' -f2`
pushd /opt/iiab/iiab
HASH=`git log --pretty=format:'g%h' -n 1`
YMD=$(date +%y%m%d)
popd
SCRIPTDIR=$(cd `dirname $0` pwd)
footprint_name=${OS_VER}-$YMD-$who
basket=$footprint_name.$$
VARS_VALUES=/tmp/all-vars
# record all the ansible variables
pushd /opt/iiab/iiab > /dev/null
./runrole all-vars $VARS_VALUES
popd > /dev/null
# cat files in this direcory
function cat_dir(){
echo "=========================================================="
echo "Printing contents of $1"
filelist=$(ls $1)
if [ ! -z "$filelist" ]; then
pushd $1
for f in `ls *`;do
echo $f
cat $f
done
popd
fi
}
# collect all the network info in one place
mkdir -p /tmp/$basket
cat << EOF > /tmp/script2overview
#!/bin/bash
# generate the body overview part diagnostic package about network
echo "=========================================================="
echo Footprint submitted by:
echo $who
echo $email
echo "=========================================================="
echo iiab.env
cat /etc/iiab/iiab.env
echo "=========================================================="
echo ifconfig
ifconfig
echo
echo "=========================================================="
echo ip addr
ip addr
echo
echo "=========================================================="
echo Checking for information about raspberry pi base image
if [ -f /etc/rpi-issue ];then
cat /etc/rpi-issue
echo "stage 2 = lite; stage 3 = desktop"
else
echo "not a raspberry pi"
fi
echo "=========================================================="
echo "brctl show"
brctl show
echo
echo "=========================================================="
echo "/etc/resolv.conf"
cat /etc/resolv.conf
echo
echo "=========================================================="
echo "cat iiab_ini_file "
cat /etc/iiab/iiab.ini
echo
echo "=========================================================="
echo "routing table"
netstat -rn
echo
echo "=========================================================="
echo "port usage"
netstat -natp
echo
echo "=========================================================="
echo "install log -- last 50 lines"
tail -50 /opt/iiab/iiab/iiab-install.log
echo
echo "=========================================================="
echo "iiab-network log -- last 50 lines"
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
tail -50 /opt/iiab/iiab/iiab-network.log
else
echo no iiab-network.log
fi
echo
echo "=========================================================="
echo "Contents of /etc/network/interfaces"
cat /etc/network/interfaces
echo "End of Contents of /etc/network/interfaces"
echo "=========================================================="
# cat files in this direcory
function cat_dir(){
echo "=========================================================="
echo "Printing contents of Directory \$1"
filelist=\$(ls \$1)
if [ ! -z "\$filelist" ]; then
for f in \$filelist;do
echo ===== Contents of file: \$base/\$f
cat \$1/\$f
echo ===== End of Contents of file: \$f
done
fi
}
cat_dir /etc/network/interfaces.d
cat_dir /etc/systemd/network
cat_dir /etc/NetworkManager/system-connections
cat_dir /etc/sysconfig/network-scripts/if-cfg*
EOF
chmod 755 /tmp/script2overview
/tmp/script2overview > /tmp/$basket/overview
if [ -f /opt/iiab/iiab/iiab-debug.log ]; then
cp /opt/iiab/iiab/iiab-debug.log /tmp/$basket
else
touch /tmp/$basket/no_iiab-network.log
fi
if [ -f /opt/iiab/iiab/iiab-install.log ]; then
cp -p /opt/iiab/iiab/iiab-install.log /tmp/$basket
fi
if [ -f "$VARS_VALUES" ]; then
cp -p "$VARS_VALUES" /tmp/$basket
fi
mkdir -p /etc/iiab/footprint
if [ ! -z $footprint_name ];then
pushd /tmp > /dev/null
tar czf /etc/iiab/footprint/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
exit 0
fi