From 362ca5184b72406e15619bd3a502095701975519 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 15:05:42 -0400 Subject: [PATCH 01/20] Install latest iiab-diagnostics to /usr/bin each time --- roles/0-init/tasks/first_run.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/roles/0-init/tasks/first_run.yml b/roles/0-init/tasks/first_run.yml index 666103396..332da85b7 100644 --- a/roles/0-init/tasks/first_run.yml +++ b/roles/0-init/tasks/first_run.yml @@ -1,8 +1,2 @@ -- name: Create symlink /usr/bin/iiab-diagnostics - file: - src: "{{ iiab_dir }}/scripts/iiab-diagnostics" - dest: /usr/bin/iiab-diagnostics - state: link - - name: Create {{ iiab_ini_file }} include_tasks: iiab_ini.yml From 21f0857fb7ece0407b5282a3a6a23203930220d2 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 15:16:50 -0400 Subject: [PATCH 02/20] Install latest iiab-diagnostics to /usr/bin if nec --- roles/0-init/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index b6e4ac735..3d7346b69 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -15,6 +15,14 @@ include_tasks: first_run.yml when: first_run | bool +# Removed from first_run.yml so the very latest version is always installed +# into /usr/bin (so iiab-diagnostics can be run even if source tree is deleted) +- name: Copy /opt/iiab/iiab/scripts/iiab-diagnostics to /usr/bin/iiab-diagnostics + copy: + src: "{{ iiab_dir }}/scripts/iiab-diagnostics" + dest: /usr/bin/ + mode: 0755 + - name: Re-read local_facts.facts from /etc/ansible/facts.d setup: filter: ansible_local From 0bd637ba9862add61aec45531179680adeb9a931 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 18:47:51 -0400 Subject: [PATCH 03/20] Create globally-writable directory /etc/iiab/diag --- roles/0-init/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index 3d7346b69..49eeeb343 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -23,6 +23,12 @@ dest: /usr/bin/ mode: 0755 +- name: Create globally-writable directory /etc/iiab/diag so non-root users can run iiab-diagnostics + file: + state: directory + path: /etc/iiab/diag + mode: 0777 + - name: Re-read local_facts.facts from /etc/ansible/facts.d setup: filter: ansible_local From 2b1ea7be0314f23c3d72c29215a9fe9822897e82 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 19:06:08 -0400 Subject: [PATCH 04/20] Prompt users to auto-publish diagnostics to a pastebin. Partially supports non-root users. --- scripts/iiab-diagnostics | 41 ++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 25d743d46..d790339dc 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -10,10 +10,13 @@ HASH1=`cd /opt/iiab/iiab; git log --pretty=format:'%H' -n 1` HASH2=`cd /opt/iiab/iiab-admin-console; git log --pretty=format:'%H' -n 1` YMDT=$(date +%F_%T_%Z) -echo -e "\nAccelerate troubleshooting by collecting your IIAB diagnostics into 1 file:" -echo -e "\n sudo iiab-diagnostics" -echo -e " sudo iiab-diagnostics PATH/FILE1 PATH/FILE2 ..." -echo -ne "\nCan you provide a \e[1mshort public nickname:\e[0m (no spaces!) " +echo -e "\nGathers IIAB diagnostics into 1 file, to accelerate troubleshooting. USAGE:" +echo +echo -e " iiab-diagnostics" +echo -e " sudo iiab-diagnostics # USE 'sudo' FOR MORE" +echo -e " sudo iiab-diagnostics PATH/FILE1 PATH/FILE2 ... # COMPLETE RESULTS !!" +echo +echo -ne "Can you provide a \e[1mshort public nickname:\e[0m (no spaces!) " read nickname < /dev/tty if [ -z "$nickname" ]; then nickname="NONAME" @@ -21,8 +24,10 @@ fi # Build up a meaningful shared filename for DEV / IMPLEM / LEARNING team(s) outfile=/etc/iiab/diag/${IIAB_RELEASE}_${OS_VER}_${YMDT}_$nickname -# System "snapshots" (time-stamped output from this 'iiab-diagnostics' command) will be stored in this directory. A bit like system logs, but only on request. -mkdir -p /etc/iiab/diag + +# System "snapshots" (time-stamped output from this 'iiab-diagnostics' command) +# will be stored in globally-writable directory /etc/iiab/diag as created by +# roles/0-init/tasks/main.yml. A bit like system logs, but only on request. function cat_file_raw() { # $1 = path/filename; $2 = # of lines, for tail if [ -f $1 ]; then @@ -175,5 +180,25 @@ cat_tail /opt/iiab/iiab-admin-console/admin-install.log 100 linecount=$(wc -l $outfile | sed 's/\s.*$//') sizecount=$(du -h $outfile | sed 's/\s.*$//') -echo -e "\n\e[32mCOMPLETE! To share this on the web ($sizecount, $linecount lines) run:\e[0m" -echo -e "\n\e[1mpastebinit < $outfile\e[0m\n" +echo -e "\n\e[32m\e[1mCOMPLETE! Your diagnostics file ($sizecount, $linecount lines) is:" +echo +echo -e " $outfile\e[0m" + +#if [ "$1" == "-y" ]; then +# ans="y" # if user ran "iiab-diganostics -y" to avoid interactive prompt +#else +echo +echo -ne "\e[42;1mPublish it to a web pastebin? [Y/n]\e[0m " +read ans < /dev/tty +#fi + +echo -e "\e[1m" +if [ "$ans" == "" ] || [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then + echo -ne "PUBLISHING TO URL... " + pastebinit < $outfile +else + echo -e "If you later decide to publish it, run:" + echo + echo -e " pastebinit < $outfile" +fi +echo -e "\e[0m" From 3cbfe0288c6cb0c8c076665719739ed655959dae Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 19:21:57 -0400 Subject: [PATCH 05/20] Link to iiab-diagnostics documentation --- scripts/iiab-diagnostics | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index d790339dc..7981b9979 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -1,7 +1,8 @@ #!/bin/bash # Collect IIAB diagnostic info into 1 file for easy online/offline circulation! -# PLEASE SEE iiab-diagnostics.README.md +# PLEASE SEE /opt/iiab/iiab/scripts/iiab-diagnostics.README.md OR ONLINE HERE: +# https://github.com/iiab/iiab/blob/master/scripts/iiab-diagnostics.README.md IIAB_RELEASE=`cat /etc/iiab/iiab.env | grep IIAB_RELEASE | cut -d'=' -f2` OS_VER=`cat /etc/iiab/iiab.env | grep OS_VER | cut -d'=' -f2` From c57806f28ce6ff59518af427eb9cc417e5cb2949 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 12 Oct 2019 19:34:38 -0400 Subject: [PATCH 06/20] Update iiab-diagnostics.README.md --- scripts/iiab-diagnostics.README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index 133939e43..6de2d8cb8 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -2,7 +2,7 @@ To streamline troubleshooting of remote Internet-in-a-Box (IIAB) installations, we bundle up common machine/software diagnostics, all together in 1 human-readable small file, that can be easily circulated online AND offline. -The ``pastebinit`` command can then be used to upload this file, creating a short URL that makes it easier to pass around. +The ``pastebinit`` command can then be used to auto-upload this file, creating a short URL that makes it easier to pass around. But first off, the file is compiled by harvesting 5 main kinds of things: @@ -20,11 +20,17 @@ But first off, the file is compiled by harvesting 5 main kinds of things: 1. Run it as follows: + ``` + iiab-diagnostics + ``` + + Better yet, for [more complete results](https://github.com/iiab/iiab/pull/2000#issue-327506999), run it as root: + ``` sudo iiab-diagnostics ``` - To bundle in more files, run: + To bundle in yet more files, run: ``` sudo iiab-diagnostics PATH/FILE1 PATH/FILE2 ... @@ -32,13 +38,15 @@ But first off, the file is compiled by harvesting 5 main kinds of things: ( All diagnostics will be bundled up into a single human-readable file, placed in: /etc/iiab/diag/ ) -2. Make sure you're online, and upload the new file using the ``pastebinit`` command: +2. Make sure you're online, as you will be prompted to auto-publish your newly-compiled diagnostics file to a web pastebin. + + Or, you can later/manually upload it using the ``pastebinit`` command: ``` pastebinit < /etc/iiab/diag/NEW-FILE-NAME ``` - - This will generate an actual web link (URL). + + Either way, this will generate an actual web link (URL). 3. Post this link (URL) to a "New issue" at https://github.com/iiab/iiab/issues @@ -48,4 +56,4 @@ But first off, the file is compiled by harvesting 5 main kinds of things: ## Source Code -Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. +Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-180 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. From 734e62f55e2235199f4f673fe349409dbe002e29 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 09:34:11 -0400 Subject: [PATCH 07/20] Swap Sections 3 & 4, so iptables info is in 1 spot --- scripts/iiab-diagnostics.README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index 6de2d8cb8..bb113705a 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -10,9 +10,9 @@ But first off, the file is compiled by harvesting 5 main kinds of things: 2. Regular Files -3. Content of Directories, 1-level deep +3. Output of Commands -4. Output of Commands +4. Content of Directories, 1-level deep 5. Log Files: (last 100 lines of each) From c7f7d6dd5b79ece6b6b48d16e11e74585615c24a Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 09:39:29 -0400 Subject: [PATCH 08/20] Swap Sections 3 & 4, so iptables info is in 1 spot --- scripts/iiab-diagnostics | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 7981b9979..57fd075ba 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -66,6 +66,17 @@ function cat_file() { cat_file_raw $1 } +function cat_cmd() { # $1 = command + params, $2 = explanation + echo " $1 # $2" + echo "=IIAB==========================================================================" >> $outfile + cmd=$(echo $1 | sed 's/\s.*$//') # Keep command on left; Drop params on right + pth=$(which $cmd | sed 's/[^/]*$//') # Keep only path on left; Drop command on right + echo "COMMAND: $pth$1 # $2" >> $outfile + echo >> $outfile + $(echo $1) >> $outfile + echo >> $outfile +} + function cat_dir() { echo " $1" echo "=IIAB==========================================================================" >> $outfile @@ -80,17 +91,6 @@ function cat_dir() { fi } -function cat_cmd() { # $1 = command + params, $2 = explanation - echo " $1 # $2" - echo "=IIAB==========================================================================" >> $outfile - cmd=$(echo $1 | sed 's/\s.*$//') # Keep command on left; Drop params on right - pth=$(which $cmd | sed 's/[^/]*$//') # Keep only path on left; Drop command on right - echo "COMMAND: $pth$1 # $2" >> $outfile - echo >> $outfile - $(echo $1) >> $outfile - echo >> $outfile -} - function cat_tail() { # $1 = path/filename; $2 = # of lines, for tail echo " $1" echo "=IIAB==========================================================================" >> $outfile @@ -148,15 +148,7 @@ cat_file /usr/bin/iiab-gen-iptables #popd > /dev/null #cat_file /tmp/all-ansible-vars -echo -e "\n 3. Content of Directories, 1-level deep:\n" -cat_dir /etc/network/interfaces.d -cat_dir /etc/systemd/network -cat_dir /etc/NetworkManager/system-connections -cat_dir /etc/netplan -#cat_dir /etc/sysconfig/network-scripts/if-cfg* # No longer common. -#cat_dir /etc/network # Above file /etc/network/interfaces suffices - -echo -e "\n 4. Output of Commands:\n" +echo -e "\n 3. Output of Commands:\n" cat_cmd 'uname -a' 'Linux kernel' cat_cmd 'free' 'RAM memory' cat_cmd 'lscpu' 'CPU details' @@ -173,6 +165,14 @@ cat_cmd 'systemctl status dnsmasq' 'Is dnsmasq Ok?' cat_cmd 'journalctl -u dnsmasq' 'dnsmasq log' #cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 15-19 lines above? +echo -e "\n 4. Content of Directories, 1-level deep:\n" +cat_dir /etc/network/interfaces.d +cat_dir /etc/systemd/network +cat_dir /etc/NetworkManager/system-connections +cat_dir /etc/netplan +#cat_dir /etc/sysconfig/network-scripts/if-cfg* # No longer common. +#cat_dir /etc/network # Above file /etc/network/interfaces suffices + echo -e "\n 5. Log Files: (last 100 lines of each)\n" cat_tail /opt/iiab/iiab/iiab-install.log 100 cat_tail /opt/iiab/iiab/iiab-network.log 100 From fe11c0d771cfff503bc9136331b93fc6505b5b3e Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 09:55:27 -0400 Subject: [PATCH 09/20] Try prefixing sudo in front of 3 cmds that partially fail (fixing incomplete results?) --- scripts/iiab-diagnostics | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 57fd075ba..46e8bda5f 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -149,6 +149,7 @@ cat_file /usr/bin/iiab-gen-iptables #cat_file /tmp/all-ansible-vars echo -e "\n 3. Output of Commands:\n" +cat_cmd 'sudo iptables-save' 'Firewall rules' cat_cmd 'uname -a' 'Linux kernel' cat_cmd 'free' 'RAM memory' cat_cmd 'lscpu' 'CPU details' @@ -159,10 +160,9 @@ cat_cmd 'ip addr' 'Network interfaces' cat_cmd 'ifconfig' 'Network interfaces (old view)' cat_cmd 'brctl show' 'Bridge for LAN side' cat_cmd 'netstat -rn' 'Routing table' -cat_cmd 'netstat -natp' 'Ports/Services in use' -cat_cmd 'iptables-save' 'Firewall rules' +cat_cmd 'sudo netstat -natp' 'Ports/Services in use' cat_cmd 'systemctl status dnsmasq' 'Is dnsmasq Ok?' -cat_cmd 'journalctl -u dnsmasq' 'dnsmasq log' +cat_cmd 'sudo journalctl -u dnsmasq' 'dnsmasq log' #cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 15-19 lines above? echo -e "\n 4. Content of Directories, 1-level deep:\n" From 2aefa0be35a42aaf8c98891b6632ef2a04626f8c Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 10:21:04 -0400 Subject: [PATCH 10/20] iiab-diagnostics output reorder per @jvonau suggestion --- scripts/iiab-diagnostics | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 46e8bda5f..65eeaa9f6 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -140,7 +140,6 @@ cat_file /etc/iiab/local_vars.yml cat_file /etc/iiab/config_vars.yml cat_file /etc/resolv.conf cat_file /etc/network/interfaces -cat_file /usr/bin/iiab-gen-iptables # Record all Ansible variables: SLOW! OUTPUT TOO LARGE? #pushd /opt/iiab/iiab > /dev/null @@ -148,8 +147,15 @@ cat_file /usr/bin/iiab-gen-iptables #popd > /dev/null #cat_file /tmp/all-ansible-vars -echo -e "\n 3. Output of Commands:\n" -cat_cmd 'sudo iptables-save' 'Firewall rules' +echo -e "\n 3. Content of Directories, 1-level deep:\n" +cat_dir /etc/network/interfaces.d +cat_dir /etc/systemd/network +cat_dir /etc/NetworkManager/system-connections +cat_dir /etc/netplan +#cat_dir /etc/sysconfig/network-scripts/if-cfg* # No longer common. +#cat_dir /etc/network # Above file /etc/network/interfaces suffices + +echo -e "\n 4. Output of Commands:\n" cat_cmd 'uname -a' 'Linux kernel' cat_cmd 'free' 'RAM memory' cat_cmd 'lscpu' 'CPU details' @@ -163,17 +169,13 @@ cat_cmd 'netstat -rn' 'Routing table' cat_cmd 'sudo netstat -natp' 'Ports/Services in use' cat_cmd 'systemctl status dnsmasq' 'Is dnsmasq Ok?' cat_cmd 'sudo journalctl -u dnsmasq' 'dnsmasq log' -#cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 15-19 lines above? +#cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 24-28 lines above? -echo -e "\n 4. Content of Directories, 1-level deep:\n" -cat_dir /etc/network/interfaces.d -cat_dir /etc/systemd/network -cat_dir /etc/NetworkManager/system-connections -cat_dir /etc/netplan -#cat_dir /etc/sysconfig/network-scripts/if-cfg* # No longer common. -#cat_dir /etc/network # Above file /etc/network/interfaces suffices +echo -e "\n 5. Firewall Rules:\n" +cat_file /usr/bin/iiab-gen-iptables +cat_cmd 'sudo iptables-save' 'Firewall rules' -echo -e "\n 5. Log Files: (last 100 lines of each)\n" +echo -e "\n 6. Log Files: (last 100 lines of each)\n" cat_tail /opt/iiab/iiab/iiab-install.log 100 cat_tail /opt/iiab/iiab/iiab-network.log 100 cat_tail /opt/iiab/iiab/iiab-debug.log 100 From 0398bfa7da44fb8c1575e4d9921265184874d64b Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 10:31:58 -0400 Subject: [PATCH 11/20] define function cat_dir() before cat_cmd() [as it was] --- scripts/iiab-diagnostics | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 65eeaa9f6..6e83b28b6 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -66,17 +66,6 @@ function cat_file() { cat_file_raw $1 } -function cat_cmd() { # $1 = command + params, $2 = explanation - echo " $1 # $2" - echo "=IIAB==========================================================================" >> $outfile - cmd=$(echo $1 | sed 's/\s.*$//') # Keep command on left; Drop params on right - pth=$(which $cmd | sed 's/[^/]*$//') # Keep only path on left; Drop command on right - echo "COMMAND: $pth$1 # $2" >> $outfile - echo >> $outfile - $(echo $1) >> $outfile - echo >> $outfile -} - function cat_dir() { echo " $1" echo "=IIAB==========================================================================" >> $outfile @@ -91,6 +80,17 @@ function cat_dir() { fi } +function cat_cmd() { # $1 = command + params, $2 = explanation + echo " $1 # $2" + echo "=IIAB==========================================================================" >> $outfile + cmd=$(echo $1 | sed 's/\s.*$//') # Keep command on left; Drop params on right + pth=$(which $cmd | sed 's/[^/]*$//') # Keep only path on left; Drop command on right + echo "COMMAND: $pth$1 # $2" >> $outfile + echo >> $outfile + $(echo $1) >> $outfile + echo >> $outfile +} + function cat_tail() { # $1 = path/filename; $2 = # of lines, for tail echo " $1" echo "=IIAB==========================================================================" >> $outfile From 29023cb697c534d76dd9735ca0a48240074d8015 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:20:39 -0400 Subject: [PATCH 12/20] iiab-diagnostics: visually separate 1+6 output sections --- scripts/iiab-diagnostics | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 6e83b28b6..888884eda 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -100,24 +100,33 @@ function cat_tail() { # $1 = path/filename; $2 = # of lines, for tail # START BUILDING UP THE FILE THAT'LL CONTAIN THE DIAGNOSTICS! echo -e "\nCompiling diagnostics..." -echo -e "\n 0. Header/Hashes/OS" +echo -e "\n 0. Filename Header + Git Hashes + OS" echo "This is: $outfile" >> $outfile echo >> $outfile +echo -e "\n\n\n\n0. GIT HASHES + OS" >> $outfile +echo >> $outfile echo "iiab commit: $HASH1" >> $outfile echo "iiab-admin-console commit: $HASH2" >> $outfile echo >> $outfile -echo -n "Checking /etc/rpi-issue for Raspbian OS version... " >> $outfile +cat_file /etc/issue.net +cat_file /etc/debian_version +#echo "Checking /etc/rpi-issue for Raspbian OS version... " >> $outfile +#echo >> $outfile +cat_file /etc/rpi-issue +echo >> $outfile if [ -f /etc/rpi-issue ]; then + echo "stage2 = Raspbian Lite" >> $outfile + echo "stage4 = Raspbian With Desktop" >> $outfile + echo "stage5 = Raspbian With Desktop + Recommended Software" >> $outfile echo >> $outfile - cat /etc/rpi-issue >> $outfile - echo >> $outfile - echo "stage2 = lite; stage5 = desktop SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy" >> $outfile + echo "SEE https://github.com/RPi-Distro/pi-gen#stage-anatomy" >> $outfile else - echo "Not a Raspberry Pi!" >> $outfile + echo "(This is NOT a Raspberry Pi!)" >> $outfile fi echo >> $outfile -echo -e '\n 1. Files specially requested: (for "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' +echo -e '\n\n 1. Files Specially Requested: (for "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' +echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FOR "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile for f in "$@"; do cat_file $f done @@ -127,6 +136,7 @@ if [ $# -eq 0 ]; then else echo -e "\n 2. Regular Files:\n" fi +echo -e "\n\n\n\n2. REGULAR FILES\n" >> $outfile #cat_file /dev/sda # Device "file" test #cat_file /nonsense # Non-existence test #cat_file /opt/iiab/iiab # Directory test @@ -147,7 +157,8 @@ cat_file /etc/network/interfaces #popd > /dev/null #cat_file /tmp/all-ansible-vars -echo -e "\n 3. Content of Directories, 1-level deep:\n" +echo -e "\n 3. Content of Directories: (1-level deep)\n" +echo -e "\n\n\n\n3. CONTENT OF DIRECTORIES (1-LEVEL DEEP)\n" >> $outfile cat_dir /etc/network/interfaces.d cat_dir /etc/systemd/network cat_dir /etc/NetworkManager/system-connections @@ -156,6 +167,7 @@ cat_dir /etc/netplan #cat_dir /etc/network # Above file /etc/network/interfaces suffices echo -e "\n 4. Output of Commands:\n" +echo -e "\n\n\n\n\n4. OUTPUT OF COMMANDS\n" >> $outfile cat_cmd 'uname -a' 'Linux kernel' cat_cmd 'free' 'RAM memory' cat_cmd 'lscpu' 'CPU details' @@ -169,13 +181,16 @@ cat_cmd 'netstat -rn' 'Routing table' cat_cmd 'sudo netstat -natp' 'Ports/Services in use' cat_cmd 'systemctl status dnsmasq' 'Is dnsmasq Ok?' cat_cmd 'sudo journalctl -u dnsmasq' 'dnsmasq log' -#cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 24-28 lines above? +cat_cmd 'env' 'Environment variables' +#cat_cmd 'ansible localhost -m setup 2>/dev/null' 'All Ansible facts' # For cleaner scraping of Ansible vars, consider "./runrole all-vars /tmp/all-ansible-vars" 27-31 lines above? echo -e "\n 5. Firewall Rules:\n" +echo -e "\n\n\n\n5. FIREWALL RULES\n" >> $outfile cat_file /usr/bin/iiab-gen-iptables cat_cmd 'sudo iptables-save' 'Firewall rules' echo -e "\n 6. Log Files: (last 100 lines of each)\n" +echo -e "\n\n\n\n6. LOG FILES (LAST 100 LINES OF EACH)\n" >> $outfile cat_tail /opt/iiab/iiab/iiab-install.log 100 cat_tail /opt/iiab/iiab/iiab-network.log 100 cat_tail /opt/iiab/iiab/iiab-debug.log 100 From 516b30c3938c7c4714f111bfd9fc344ddf7b4734 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:21:23 -0400 Subject: [PATCH 13/20] Update iiab-diagnostics.README.md --- scripts/iiab-diagnostics.README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index bb113705a..4309b375f 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -4,17 +4,21 @@ To streamline troubleshooting of remote Internet-in-a-Box (IIAB) installations, The ``pastebinit`` command can then be used to auto-upload this file, creating a short URL that makes it easier to pass around. -But first off, the file is compiled by harvesting 5 main kinds of things: +But first off, the file is compiled by harvesting 1 + 6 kinds of things: + +0. Filename Header + Git Hashes + OS 1. Files specially requested (if you run ``sudo iiab-diagnostics PATH/FILE1 PATH/FILE2``) 2. Regular Files -3. Output of Commands +3. Content of Directories (1-level deep) -4. Content of Directories, 1-level deep +4. Output of Commands -5. Log Files: (last 100 lines of each) +5. Firewall Rules + +6. Log Files (last 100 lines of each) ## Usage @@ -56,4 +60,4 @@ But first off, the file is compiled by harvesting 5 main kinds of things: ## Source Code -Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-180 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. +Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-197 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. From f01d2917160ca436f18a3c9c9823765bea810f0f Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:45:44 -0400 Subject: [PATCH 14/20] iiab-diagnostics: show RPi Model + debian_version --- scripts/iiab-diagnostics | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index 888884eda..d1cb72df1 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -100,19 +100,19 @@ function cat_tail() { # $1 = path/filename; $2 = # of lines, for tail # START BUILDING UP THE FILE THAT'LL CONTAIN THE DIAGNOSTICS! echo -e "\nCompiling diagnostics..." -echo -e "\n 0. Filename Header + Git Hashes + OS" +echo -e "\n 0. Filename Header + Git Hashes + Raspberry Pi Model + OS" echo "This is: $outfile" >> $outfile echo >> $outfile -echo -e "\n\n\n\n0. GIT HASHES + OS" >> $outfile +echo -e "\n\n\n\n0. GIT HASHES + RASPBERRY PI MODEL + OS" >> $outfile echo >> $outfile echo "iiab commit: $HASH1" >> $outfile echo "iiab-admin-console commit: $HASH2" >> $outfile echo >> $outfile -cat_file /etc/issue.net -cat_file /etc/debian_version +cat_file /sys/firmware/devicetree/base/model #echo "Checking /etc/rpi-issue for Raspbian OS version... " >> $outfile #echo >> $outfile cat_file /etc/rpi-issue +echo "-IIAB-EXPLANATION-OF-THE-ABOVE-------------------------------------------------" >> $outfile echo >> $outfile if [ -f /etc/rpi-issue ]; then echo "stage2 = Raspbian Lite" >> $outfile @@ -124,6 +124,8 @@ else echo "(This is NOT a Raspberry Pi!)" >> $outfile fi echo >> $outfile +cat_file /etc/issue.net +cat_file /etc/debian_version echo -e '\n\n 1. Files Specially Requested: (for "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FOR "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile From b3de37445233f69d8328d64079062c4cb0e81a7d Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:45:57 -0400 Subject: [PATCH 15/20] Update iiab-diagnostics.README.md --- scripts/iiab-diagnostics.README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index 4309b375f..bd3e4d53a 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -6,7 +6,7 @@ The ``pastebinit`` command can then be used to auto-upload this file, creating a But first off, the file is compiled by harvesting 1 + 6 kinds of things: -0. Filename Header + Git Hashes + OS +0. Filename Header + Git Hashes + Raspberry Pi Model + OS 1. Files specially requested (if you run ``sudo iiab-diagnostics PATH/FILE1 PATH/FILE2``) From af5d68e8c265f095355e3f3de5e27562ac8264f4 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:47:01 -0400 Subject: [PATCH 16/20] Update iiab-diagnostics.README.md --- scripts/iiab-diagnostics.README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index bd3e4d53a..0ac027677 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -60,4 +60,4 @@ But first off, the file is compiled by harvesting 1 + 6 kinds of things: ## Source Code -Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-197 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. +Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-199 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. From e38234beda0b31cfcdb5d9005c07e10ffbd2a67b Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 12:54:22 -0400 Subject: [PATCH 17/20] Verbiage cleanup in iiab-diagnostics output --- scripts/iiab-diagnostics | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index d1cb72df1..bf743e40a 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -127,8 +127,8 @@ echo >> $outfile cat_file /etc/issue.net cat_file /etc/debian_version -echo -e '\n\n 1. Files Specially Requested: (for "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' -echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FOR "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile +echo -e '\n\n 1. Files Specially Requested: (from "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' +echo -e '\n\n\n\n1. FILES SPECIALLY REQUESTED (FROM "iiab-diagnostics PATH/FILE1 PATH/FILE2")\n' >> $outfile for f in "$@"; do cat_file $f done From 947d0d55e24ba53c938a798383a1aca65ec7d26a Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 13:20:58 -0400 Subject: [PATCH 18/20] Explain iiab-diagnostics in 0-init/tasks/main.yml --- roles/0-init/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index 49eeeb343..8cfed2864 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -15,8 +15,8 @@ include_tasks: first_run.yml when: first_run | bool -# Removed from first_run.yml so the very latest version is always installed -# into /usr/bin (so iiab-diagnostics can be run even if source tree is deleted) +# Copies the latest/known version of iiab-diagnostics into /usr/bin (so it can +# be run even if local source tree /opt/iiab/iiab is deleted to conserve disk). - name: Copy /opt/iiab/iiab/scripts/iiab-diagnostics to /usr/bin/iiab-diagnostics copy: src: "{{ iiab_dir }}/scripts/iiab-diagnostics" From 0e3539bf2578a747dc618a00934bfc14c0976b4d Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 13:23:36 -0400 Subject: [PATCH 19/20] Update iiab-diagnostics --- scripts/iiab-diagnostics | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/iiab-diagnostics b/scripts/iiab-diagnostics index bf743e40a..696bf9432 100755 --- a/scripts/iiab-diagnostics +++ b/scripts/iiab-diagnostics @@ -109,8 +109,6 @@ echo "iiab commit: $HASH1" >> $outfile echo "iiab-admin-console commit: $HASH2" >> $outfile echo >> $outfile cat_file /sys/firmware/devicetree/base/model -#echo "Checking /etc/rpi-issue for Raspbian OS version... " >> $outfile -#echo >> $outfile cat_file /etc/rpi-issue echo "-IIAB-EXPLANATION-OF-THE-ABOVE-------------------------------------------------" >> $outfile echo >> $outfile From 918864179854012831b63abefdd0baa7bc3e56b0 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 13 Oct 2019 13:24:23 -0400 Subject: [PATCH 20/20] Update iiab-diagnostics.README.md --- scripts/iiab-diagnostics.README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/iiab-diagnostics.README.md b/scripts/iiab-diagnostics.README.md index 0ac027677..bd3e4d53a 100644 --- a/scripts/iiab-diagnostics.README.md +++ b/scripts/iiab-diagnostics.README.md @@ -60,4 +60,4 @@ But first off, the file is compiled by harvesting 1 + 6 kinds of things: ## Source Code -Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-199 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible. +Please look over the bottom of [iiab-diagnostics](iiab-diagnostics) (lines 100-197 especially) to learn more about which common IIAB files and commands make this rapid troubleshooting possible.