1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

create flat file with all info

This commit is contained in:
George Hunt 2019-06-21 07:12:57 -07:00
parent fc69ccbb28
commit d155e8a113
2 changed files with 111 additions and 109 deletions

9
scripts/filelist Normal file
View file

@ -0,0 +1,9 @@
/etc/iiab/iiab.env
/etc/iiab/local_vars.yml
/etc/iiab/config_vars.yml
/etc/iiab/iiab.ini
/usr/bin/iiab-gen-iptables
/etc/network/interfaces
/etc/resolv.conf
/etc/iiab/openvpn_handle

View file

@ -1,12 +1,11 @@
#!/bin/bash #!/bin/bash
# create a diagnostic footprint of network, and OS settings # create a diagnostic collection, and documet OS settings
read -p "\n\nPlease provide a name or nickname: (8 characters or less, no spaces) " who read -p "\n\nPlease provide a name or nickname: (8 characters or less, no spaces) " who
if [ -z "$who" ]; then if [ -z "$who" ]; then
who="noname" who="noname"
fi fi
read -p "\n\nIf this is a request for help, what is your email address? " email
# Build up a meaningful name for transmission back to the development team # 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` OS_VER=`cat /etc/iiab/iiab.env | grep OS_VER | cut -d'=' -f2`
pushd /opt/iiab/iiab pushd /opt/iiab/iiab
@ -16,160 +15,154 @@ popd
SCRIPTDIR=$(cd `dirname $0` pwd) SCRIPTDIR=$(cd `dirname $0` pwd)
diagnostics_name=${OS_VER}-$YMD-$who diagnostics_name=${OS_VER}-$YMD-$who
basket=$diagnostics_name.$$ outfile=$diagnostics_name.$$
VARS_VALUES=/tmp/all-vars VARS_VALUES=/tmp/all-vars
# record all the ansible variables # record all the ansible variables
pushd /opt/iiab/iiab > /dev/null pushd /opt/iiab/iiab > /dev/null
./runrole all-vars $VARS_VALUES # ./runrole all-vars $VARS_VALUES
popd > /dev/null popd > /dev/null
# cat files in this direcory # cat files in this direcory
function cat_dir(){ function cat_dir(){
echo "==========================================================" echo >>/tmp/$outfile
echo "Printing contents of $1" echo "=IIAB=====================================================" >> /tmp/$outfile
filelist=$(ls $1) if [ -d "$1" ];then
if [ ! -z "$filelist" ]; then echo "Printing files in $1 directory" >> /tmp/$outfile
pushd $1 echo >>/tmp/$outfile
for f in `ls *`;do filelist=$(ls $1)
echo $f if [ ! -z "$filelist" ]; then
cat $f pushd $1
done for f in `ls *`;do
popd echo "Printing contents of $f" >> /tmp/$outfile
echo >>/tmp/$outfile
cat $f | iconv -t UTF-8//IGNORE >> /tmp/$outfile
done
popd
fi
else
echo "Directory $1 does not exist" >> /tmp/$outfile
fi fi
} }
function cat_file(){
echo >>/tmp/$outfile
echo "=IIAB====================================================" >> /tmp/$outfile
if [ -f $1 ];then
echo "Printing contents of $1" >> /tmp/$outfile
echo >>/tmp/$outfile
if [ $# -eq 2 ];then
echo "Printing last 100 lines" >> /tmp/$outfile
tail -100 $1 | iconv -t UTF-8//IGNORE >> /tmp/$outfile
else
cat $1 | iconv -t UTF-8//IGNORE >> /tmp/$outfile
fi
else
echo "File $1 does not exists" >> /tmp/$outfile
fi
}
function cat_file_list(){
for f in $(cat filelist);do
cat_file $f
done
}
# collect all the network info in one place # collect all the network info in one place
mkdir -p /tmp/$basket cat << EOF > /tmp/diagnostics_script
cat << EOF > /tmp/script2overview
#!/bin/bash #!/bin/bash
# generate the body overview part diagnostic package about network # generate the body overview part diagnostic package about network
echo "==========================================================" echo "=IIAB====================================================="
echo Diagnostics submitted by: echo Diagnostics submitted by:
echo $who echo $who
echo $email echo "Identifier: $diagnostics_name"
echo "==========================================================" echo "=IIAB====================================================="
echo iiab.env echo Output from /sbin/ifconfig command
cat /etc/iiab/iiab.env echo
echo "=========================================================="
echo /etc/iiab/local_vars.yml
cat /etc/iiab/local_vars.yml
echo "=========================================================="
echo /etc/iiab/openvpn_handle
cat /etc/iiab/openvpn_handle
echo "=========================================================="
echo ifconfig
ifconfig ifconfig
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo ip addr echo Output fro /sbin/ip addr
echo
ip addr ip addr
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo Checking for information about raspberry pi base image echo Checking for information about raspberry pi base image
echo Output from command 'cat /etc/rpi-issue'
echo
if [ -f /etc/rpi-issue ];then if [ -f /etc/rpi-issue ];then
cat /etc/rpi-issue cat /etc/rpi-issue
echo "stage 2 = lite; stage 3 = desktop SEE github.com/RPi-Distro/pi-gen#stage-anatomy" echo "stage2 = lite; stage5 = desktop SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy"
else else
echo "not a raspberry pi" echo "not a raspberry pi"
fi fi
echo "==========================================================" echo "=IIAB====================================================="
echo "brctl show" echo "/sbin/brctl show"
echo
brctl show brctl show
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo "/etc/resolv.conf" echo Output from /bin/netstat -rn
cat /etc/resolv.conf
echo
echo "=========================================================="
echo "/etc/iiab_ini_file "
cat /etc/iiab/iiab.ini
echo
echo "=========================================================="
echo "routing table" echo "routing table"
netstat -rn netstat -rn
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo "iptales-save output" echo "Output of /sbin/iptables-save"
echo
iptables-save iptables-save
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo "/usr/bin/iiab-gen-iptable" if [ -f /.iiab-image ];then
cat /usr/bin/iiab-gen-iptables echo "Output of /bin/cat /.iiab-image command."
echo echo
echo "=========================================================="
echo "/.iiab-image"
cat /.iiab-image cat /.iiab-image
echo else
echo "==========================================================" echo /.iiab-image does not exist.
echo "systemctl status dnsmasq"
systemctl status dnsmasq
echo
echo "=========================================================="
echo "journalctl -u dnsmasq"
journalctl -u dnsmasq
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 fi
echo echo
echo "==========================================================" echo "=IIAB====================================================="
echo "Contents of /etc/network/interfaces" echo "systemctl status dnsmasq"
cat /etc/network/interfaces echo
echo "End of Contents of /etc/network/interfaces" systemctl status dnsmasq
echo "==========================================================" echo
# cat files in this direcory echo "=IIAB====================================================="
function cat_dir(){ echo "journalctl -u dnsmasq"
echo "==========================================================" echo
echo "Printing contents of Directory \$1" journalctl -u dnsmasq
filelist=\$(ls \$1) echo
if [ ! -z "\$filelist" ]; then echo "=IIAB====================================================="
for f in \$filelist;do echo "Output of command /bin/netstat -natp showing port usage"
echo ===== Contents of file: \$base/\$f echo
cat \$1/\$f netstat -natp
echo ===== End of Contents of file: \$f echo
done echo "=IIAB====================================================="
fi echo "Output of command /ansible -i localhost -m setup showing all local facts."
} echo
ansible localhost -m setup 2>/dev/null
echo
EOF
chmod 755 /tmp/diagnostics_script
/tmp/diagnostics_script > /tmp/$outfile
cat_file_list
cat_dir /etc/network/interfaces.d cat_dir /etc/network/interfaces.d
cat_dir /etc/systemd/network cat_dir /etc/systemd/network
cat_dir /etc/NetworkManager/system-connections cat_dir /etc/NetworkManager/system-connections
cat_dir /etc/sysconfig/network-scripts/if-cfg* 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 cat_file /opt/iiab/iiab/iiab-debug.log last
cp /opt/iiab/iiab/iiab-debug.log /tmp/$basket cat_file /opt/iiab/iiab/iiab-install.log last
else cat_file /opt/iiab/iiab-admin-console/admin-install.log last
touch /tmp/$basket/no_iiab-network.log
fi
if [ -f /opt/iiab/iiab/iiab-install.log ]; then #if [ -f "$VARS_VALUES" ]; then
cp -p /opt/iiab/iiab/iiab-install.log /tmp/$basket # cat "$VARS_VALUES" >> /tmp/$outfile
fi #fi
if [ -f "$VARS_VALUES" ]; then
cp -p "$VARS_VALUES" /tmp/$basket
fi
mkdir -p /etc/iiab/diagnostics mkdir -p /etc/iiab/diagnostics
if [ ! -z $diagnostics_name ];then if [ ! -z $diagnostics_name ];then
pushd /tmp > /dev/null pushd /tmp > /dev/null
tar czf /etc/iiab/diagnostics/$basket.tgz $basket/* cp /tmp/$outfile /etc/iiab/diagnostics/
popd > /dev/null popd > /dev/null
rm -rf /tmp/$basket #rm -rf /tmp/$outfile
exit 0 exit 0
fi fi