From e623185d963edf953f63a8338bfe12b5da3f2d8e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 9 Dec 2019 17:09:56 -0700 Subject: [PATCH] Removed old HW script wrappers --- scripts/hw-drive-info | 39 ++++++++++ scripts/{outer_scripts_to_review => }/hw-info | 72 +++++++++---------- .../hw-diags-iobenchmark | 18 ----- scripts/outer_scripts_to_review/hw-diags-menu | 66 ----------------- .../outer_scripts_to_review/hw-diags-network | 48 ------------- .../outer_scripts_to_review/hw-diags-prime95 | 19 ----- scripts/outer_scripts_to_review/hw-drive-info | 39 ---------- scripts/outer_scripts_to_review/hw-sensors | 10 --- .../hw-sensors-monitor | 36 ---------- 9 files changed, 75 insertions(+), 272 deletions(-) create mode 100755 scripts/hw-drive-info rename scripts/{outer_scripts_to_review => }/hw-info (53%) delete mode 100755 scripts/outer_scripts_to_review/hw-diags-iobenchmark delete mode 100755 scripts/outer_scripts_to_review/hw-diags-menu delete mode 100755 scripts/outer_scripts_to_review/hw-diags-network delete mode 100755 scripts/outer_scripts_to_review/hw-diags-prime95 delete mode 100755 scripts/outer_scripts_to_review/hw-drive-info delete mode 100755 scripts/outer_scripts_to_review/hw-sensors delete mode 100755 scripts/outer_scripts_to_review/hw-sensors-monitor diff --git a/scripts/hw-drive-info b/scripts/hw-drive-info new file mode 100755 index 00000000..a1c051d8 --- /dev/null +++ b/scripts/hw-drive-info @@ -0,0 +1,39 @@ +#!/bin/bash +# + +BLUE='\033[34m' +CLEAR='\033[0m' +IFS=$'\n' + +# List devices +for line in $(lsblk -do NAME,TRAN,SIZE,VENDOR,MODEL,SERIAL); do + if [[ "${line:0:4}" == "NAME" ]]; then + echo -e "${BLUE}${line}${CLEAR}" + else + echo "${line}" + fi +done +echo "" + +# List loopback devices +if [[ "$(losetup -l | wc -l)" > 0 ]]; then + for line in $(losetup -lO NAME,PARTSCAN,RO,BACK-FILE); do + if [[ "${line:0:4}" == "NAME" ]]; then + echo -e "${BLUE}${line}${CLEAR}" + else + echo "${line}" | sed -r 's#/dev/(loop[0-9]+)#\1 #' + fi + done + echo "" +fi + +# List partitions +for line in $(lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT); do + if [[ "${line:0:4}" == "NAME" ]]; then + echo -e "${BLUE}${line}${CLEAR}" + else + echo "${line}" + fi +done +echo "" + diff --git a/scripts/outer_scripts_to_review/hw-info b/scripts/hw-info similarity index 53% rename from scripts/outer_scripts_to_review/hw-info rename to scripts/hw-info index 8321e7aa..8a909c67 100755 --- a/scripts/outer_scripts_to_review/hw-info +++ b/scripts/hw-info @@ -9,20 +9,20 @@ YELLOW="\e[33m" BLUE="\e[34m" function print_in_columns() { - string="$1" - label="$(echo "$string" | sed -r 's/^\s*(.*:).*/\1/')" - value="$(echo "$string" | sed -r 's/^\s*.*:\s*(.*)/\1/')" - printf ' %-18s%s\n' "$label" "$value" + string="$1" + label="$(echo "$string" | sed -r 's/^\s*(.*:).*/\1/')" + value="$(echo "$string" | sed -r 's/^\s*.*:\s*(.*)/\1/')" + printf ' %-18s%s\n' "$label" "$value" } function print_dmi_value() { - name="$1" - file="/sys/devices/virtual/dmi/id/$2" - value="UNKNOWN" - if [[ -e "$file" ]]; then - value="$(cat "$file")" - fi - print_in_columns "$name: $value" + name="$1" + file="/sys/devices/virtual/dmi/id/$2" + value="UNKNOWN" + if [[ -e "$file" ]]; then + value="$(cat "$file")" + fi + print_in_columns "$name: $value" } # System @@ -50,58 +50,58 @@ echo "" # Processor echo -e "${BLUE}Processor${CLEAR}" lscpu | grep -E '^(Arch|CPU.s.|Core|Thread|Model name|Virt)' \ - | sed -r 's/\(s\)(.*:)/s\1 /' \ - | sed -r 's/CPUs: /Threads:/' \ - | sed -r 's/^(.*:) / \1/' + | sed -r 's/\(s\)(.*:)/s\1 /' \ + | sed -r 's/CPUs: /Threads:/' \ + | sed -r 's/^(.*:) / \1/' echo "" # Memory echo -e "${BLUE}Memory${CLEAR}" first_device="True" while read -r line; do - if [[ "$line" == "Memory Device" ]]; then - if [[ "$first_device" == "True" ]]; then - first_device="False" - else - # Add space between devices - echo "" - fi + if [[ "$line" == "Memory Device" ]]; then + if [[ "$first_device" == "True" ]]; then + first_device="False" else - print_in_columns "$line" + # Add space between devices + echo "" fi + else + print_in_columns "$line" + fi done <<< $(sudo dmidecode -t memory \ - | grep -E '^(Memory Device|\s+(Type|Size|Speed|Manuf.*|Locator|Part Number):)') + | grep -E '^(Memory Device|\s+(Type|Size|Speed|Manuf.*|Locator|Part Number):)') echo "" # Graphics echo -e "${BLUE}Graphics${CLEAR}" -lspci | grep 'VGA' | sed -r 's/^.*:/ Device: /' \ - | sed 's/Intel Corporation/Intel/' \ - | sed 's/Generation Core Processor Family/Gen/' \ - | sed 's/Integrated Graphics Controller.*/iGPU/' -glxinfo 2>/dev/null | grep 'OpenGL renderer' | sed -r 's/^.*:/ OpenGL Renderer: /' \ - | sed 's/Mesa DRI //' +lspci | grep 'VGA' | sed -r 's/^.*:/ Device: /' \ + | sed 's/Intel Corporation/Intel/' \ + | sed 's/Generation Core Processor Family/Gen/' \ + | sed 's/Integrated Graphics Controller.*/iGPU/' +glxinfo 2>/dev/null | grep 'OpenGL renderer' | sed -r 's/^.*:/ OpenGL Renderer: /' \ + | sed 's/Mesa DRI //' echo "" # Audio echo -e "${BLUE}Audio${CLEAR}" while read -r line; do - if [[ "$line" =~ .*no.soundcards.found.* ]]; then - echo " No soundcards found" - else - print_in_columns "$line" - fi + if [[ "$line" = .*no.soundcards.found.* ]]; then + echo " No soundcards found" + else + print_in_columns "$line" + fi done <<< $(aplay -l 2>&1 | grep -Ei '(^card|no soundcards found)' | sed -r 's/.*\[(.*)\].*\[(.*)\].*/\1: \2/') echo "" # Network echo -e "${BLUE}Network${CLEAR}" lspci | grep -Ei '(ethernet|network|wireless|wifi)' \ - | sed -r 's/.*: (.*)$/ \1/' + | sed -r 's/.*: (.*)$/ \1/' echo "" # Drives echo -e "${BLUE}Drives${CLEAR}" -hw-drive-info | sed 's/^/ /' +hw-drive-info | sed 's/^/ /' echo "" diff --git a/scripts/outer_scripts_to_review/hw-diags-iobenchmark b/scripts/outer_scripts_to_review/hw-diags-iobenchmark deleted file mode 100755 index 6821b1a4..00000000 --- a/scripts/outer_scripts_to_review/hw-diags-iobenchmark +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -## Wizard Kit: HW Diagnostics - Benchmarks - -function usage { - echo "Usage: ${0} device log-file" - echo " e.g. ${0} /dev/sda /tmp/tmp.XXXXXXX/benchmarks.log" -} - -# Bail early -if [ ! -b "${1}" ]; then - usage - exit 1 -fi - -# Run Benchmarks -echo 3 | sudo tee -a /proc/sys/vm/drop_caches >/dev/null 2>&1 -sudo dd bs=4M if="${1}" of=/dev/null status=progress 2>&1 | tee -a "${2}" diff --git a/scripts/outer_scripts_to_review/hw-diags-menu b/scripts/outer_scripts_to_review/hw-diags-menu deleted file mode 100755 index 7a122ae7..00000000 --- a/scripts/outer_scripts_to_review/hw-diags-menu +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/python3 -# -## Wizard Kit: HW Diagnostics - Menu - -import os -import sys - -# Init -sys.path.append(os.path.dirname(os.path.realpath(__file__))) -from functions.hw_diags import * -from functions.tmux import * -init_global_vars() - -if __name__ == '__main__': - # Show menu - try: - state = State() - menu_diags(state, sys.argv) - except KeyboardInterrupt: - print_standard(' ') - print_warning('Aborted') - print_standard(' ') - sleep(1) - pause('Press Enter to exit...') - except SystemExit as sys_exit: - tmux_switch_client() - exit_script(sys_exit.code) - except: - # Cleanup - tmux_kill_all_panes() - - if DEBUG_MODE: - # Custom major exception - print_standard(' ') - print_error('Major exception') - print_warning(SUPPORT_MESSAGE) - print(traceback.format_exc()) - print_log(traceback.format_exc()) - - # Save debug reports and upload data - try_and_print( - message='Saving debug reports...', - function=save_debug_reports, - state=state, global_vars=global_vars) - question = 'Upload crash details to {}?'.format(CRASH_SERVER['Name']) - if ENABLED_UPLOAD_DATA and ask(question): - try_and_print( - message='Uploading Data...', - function=upload_logdir, - global_vars=global_vars) - - # Done - sleep(1) - pause('Press Enter to exit...') - exit_script(1) - - else: - # "Normal" major exception - major_exception() - - # Done - tmux_kill_all_panes() - tmux_switch_client() - exit_script() - -# vim: sts=2 sw=2 ts=2 diff --git a/scripts/outer_scripts_to_review/hw-diags-network b/scripts/outer_scripts_to_review/hw-diags-network deleted file mode 100755 index 138ea67e..00000000 --- a/scripts/outer_scripts_to_review/hw-diags-network +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/python3 -# -## Wizard Kit: HW Diagnostics - Network - -import os -import sys - -# Init -sys.path.append(os.path.dirname(os.path.realpath(__file__))) -from functions.network import * - - -def check_connection(): - if not is_connected(): - # Raise to cause NS in try_and_print() - raise Exception - - -if __name__ == '__main__': - try: - # Prep - clear_screen() - print_standard('Hardware Diagnostics: Network\n') - - # Connect - print_standard('Initializing...') - connect_to_network() - - # Tests - try_and_print( - message='Network connection:', function=check_connection, cs='OK') - show_valid_addresses() - try_and_print(message='Internet connection:', function=ping, - addr='8.8.8.8', cs='OK') - try_and_print(message='DNS Resolution:', function=ping, cs='OK') - try_and_print(message='Speedtest:', function=speedtest, - print_return=True) - - # Done - print_standard('\nDone.') - #pause("Press Enter to exit...") - exit_script() - except SystemExit as sys_exit: - exit_script(sys_exit.code) - except: - major_exception() - -# vim: sts=2 sw=2 ts=2 diff --git a/scripts/outer_scripts_to_review/hw-diags-prime95 b/scripts/outer_scripts_to_review/hw-diags-prime95 deleted file mode 100755 index 4927da76..00000000 --- a/scripts/outer_scripts_to_review/hw-diags-prime95 +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# -## Wizard Kit: HW Diagnostics - Prime95 - -function usage { - echo "Usage: $0 log-dir" - echo " e.g. $0 /tmp/tmp.7Mh5f1RhSL9001" -} - -# Bail early -if [ ! -d "$1" ]; then - usage - exit 1 -fi - -# Run Prime95 -cd "$1" -mprime -t | grep -iv --line-buffered 'stress.txt' | tee -a "prime.log" - diff --git a/scripts/outer_scripts_to_review/hw-drive-info b/scripts/outer_scripts_to_review/hw-drive-info deleted file mode 100755 index df1e1748..00000000 --- a/scripts/outer_scripts_to_review/hw-drive-info +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# - -BLUE='\033[34m' -CLEAR='\033[0m' -IFS=$'\n' - -# List devices -for line in $(lsblk -do NAME,TRAN,SIZE,VENDOR,MODEL,SERIAL); do - if [[ "${line:0:4}" == "NAME" ]]; then - echo -e "${BLUE}${line}${CLEAR}" - else - echo "${line}" - fi -done -echo "" - -# List loopback devices -if [[ "$(losetup -l | wc -l)" > 0 ]]; then - for line in $(losetup -lO NAME,PARTSCAN,RO,BACK-FILE); do - if [[ "${line:0:4}" == "NAME" ]]; then - echo -e "${BLUE}${line}${CLEAR}" - else - echo "${line}" | sed -r 's#/dev/(loop[0-9]+)#\1 #' - fi - done - echo "" -fi - -# List partitions -for line in $(lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT); do - if [[ "${line:0:4}" == "NAME" ]]; then - echo -e "${BLUE}${line}${CLEAR}" - else - echo "${line}" - fi -done -echo "" - diff --git a/scripts/outer_scripts_to_review/hw-sensors b/scripts/outer_scripts_to_review/hw-sensors deleted file mode 100755 index 39ca7147..00000000 --- a/scripts/outer_scripts_to_review/hw-sensors +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -## Wizard Kit: Sensor monitoring tool - -WINDOW_NAME="Hardware Sensors" -MONITOR="hw-sensors-monitor" - -# Start session -tmux new-session -n "$WINDOW_NAME" "$MONITOR" - diff --git a/scripts/outer_scripts_to_review/hw-sensors-monitor b/scripts/outer_scripts_to_review/hw-sensors-monitor deleted file mode 100755 index ffdbbad3..00000000 --- a/scripts/outer_scripts_to_review/hw-sensors-monitor +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/python3 -# -## Wizard Kit: Sensor monitoring tool - -import os -import sys - -# Init -sys.path.append(os.path.dirname(os.path.realpath(__file__))) -from functions.sensors import * -from functions.tmux import * -init_global_vars(silent=True) - -if __name__ == '__main__': - background = False - try: - if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): - background = True - monitor_file = sys.argv[1] - monitor_pane = None - else: - result = run_program(['mktemp']) - monitor_file = result.stdout.decode().strip() - if not background: - monitor_pane = tmux_split_window( - percent=1, vertical=True, watch=monitor_file) - cmd = ['tmux', 'resize-pane', '-Z', '-t', monitor_pane] - run_program(cmd, check=False) - monitor_sensors(monitor_pane, monitor_file) - exit_script() - except SystemExit as sys_exit: - exit_script(sys_exit.code) - except: - major_exception() - -# vim: sts=2 sw=2 ts=2