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

Merge pull request #259 from georgejhunt/flat

sync from georgejhunt:flat
This commit is contained in:
A Holt 2019-06-22 15:39:33 -04:00 committed by GitHub
commit 74a68bed56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 238 additions and 140 deletions

View file

@ -0,0 +1,35 @@
## Objective
* Creates a flat file which can be uploaded to pastebinit. Gathers the following:
1. /etc/iiab/iiab.ini
2. /etc/iiab/iiab.env
3. Output of /sbin/ip addr command
4. Output of /sbin/ifconfig command
5. Output of /sbin/brctl show
6. /etc/resolv.conf
7. Output of /bin/netstat -rn (routing table)
8. Output from /bin/netstat -natp (which services have which ports)
9. /opt/iiab/iiab-install.log
10. /opt/iiab/iiab-debug.log
11. /opt/iiab-network.log
12. all ansible facts
contents of following directories:
1. /etc/network/interfaces.d (and interfaces)
2. /etc/sysconfig/network-scripts/if-cfg*
3. /etc/NetworkManager/system-connections
4. /etc/systemd/network/
#### Suggested Usage
1. Create a diagnostic package
```
sudo iiab-diagnostics
```
(this will generate a new file with the collected information and place it into /etc/iiab/diagnostics/)
2. Upload the diagnostics you have just generated to pastebinit.
```
pastebinit -i /etc/iiab/diagnostics/<name of file you just created>
```
3. Email a description of the symptoms, and how to generate them, along with the URL which was returned by the "pastebinit" command, to bugs@iiab.io.

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

168
scripts/iiab-diagnostics Executable file
View file

@ -0,0 +1,168 @@
#!/bin/bash
# create a diagnostic collection, and documet OS settings
read -p "\n\nPlease provide a name or nickname: (8 characters or less, no spaces) " who
if [ -z "$who" ]; then
who="noname"
fi
# 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)
diagnostics_name=${OS_VER}-$YMD-$who
outfile=$diagnostics_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 >>/tmp/$outfile
echo "=IIAB=====================================================" >> /tmp/$outfile
if [ -d "$1" ];then
echo "Printing files in $1 directory" >> /tmp/$outfile
echo >>/tmp/$outfile
filelist=$(ls $1)
if [ ! -z "$filelist" ]; then
pushd $1
for f in `ls *`;do
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
}
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
cat << EOF > /tmp/diagnostics_script
#!/bin/bash
# generate the body overview part diagnostic package about network
echo "=IIAB====================================================="
echo Diagnostics submitted by:
echo $who
echo "Identifier: $diagnostics_name"
echo "=IIAB====================================================="
echo Output from /sbin/ifconfig command
echo
ifconfig
echo
echo "=IIAB====================================================="
echo Output fro /sbin/ip addr
echo
ip addr
echo
echo "=IIAB====================================================="
echo Checking for information about raspberry pi base image
echo Output from command 'cat /etc/rpi-issue'
echo
if [ -f /etc/rpi-issue ];then
cat /etc/rpi-issue
echo "stage2 = lite; stage5 = desktop SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy"
else
echo "not a raspberry pi"
fi
echo "=IIAB====================================================="
echo "/sbin/brctl show"
echo
brctl show
echo
echo "=IIAB====================================================="
echo Output from /bin/netstat -rn
echo "routing table"
netstat -rn
echo
echo "=IIAB====================================================="
echo "Output of /sbin/iptables-save"
echo
iptables-save
echo
echo "=IIAB====================================================="
if [ -f /.iiab-image ];then
echo "Output of /bin/cat /.iiab-image command."
echo
cat /.iiab-image
else
echo /.iiab-image does not exist.
fi
echo
echo "=IIAB====================================================="
echo "systemctl status dnsmasq"
echo
systemctl status dnsmasq
echo
echo "=IIAB====================================================="
echo "journalctl -u dnsmasq"
echo
journalctl -u dnsmasq
echo
echo "=IIAB====================================================="
echo "Output of command /bin/netstat -natp showing port usage"
echo
netstat -natp
echo
echo "=IIAB====================================================="
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/systemd/network
cat_dir /etc/NetworkManager/system-connections
cat_dir /etc/sysconfig/network-scripts/if-cfg*
cat_file /opt/iiab/iiab/iiab-debug.log last
cat_file /opt/iiab/iiab/iiab-install.log last
cat_file /opt/iiab/iiab-admin-console/admin-install.log last
#if [ -f "$VARS_VALUES" ]; then
# cat "$VARS_VALUES" >> /tmp/$outfile
#fi
mkdir -p /etc/iiab/diagnostics
if [ ! -z $diagnostics_name ];then
pushd /tmp > /dev/null
cp /tmp/$outfile /etc/iiab/diagnostics/
popd > /dev/null
#rm -rf /tmp/$outfile
exit 0
fi