From 7715d9bc3029ddc628c5e6316e3c562461d88e39 Mon Sep 17 00:00:00 2001 From: Harald Hope Date: Sun, 29 Oct 2017 09:59:43 -0700 Subject: [PATCH] branch one: current inxi added to avoid errors. --- inxi | 418 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 285 insertions(+), 133 deletions(-) diff --git a/inxi b/inxi index 0cacf3f..85bba5b 100755 --- a/inxi +++ b/inxi @@ -2,9 +2,9 @@ ######################################################################## SELF_NAME='inxi' # don't quote the following, parsers grab these too -SELF_VERSION=2.3.35 -SELF_DATE=2017-08-11 -SELF_PATCH=03 +SELF_VERSION=2.3.41 +SELF_DATE=2017-10-29 +SELF_PATCH=00-b1 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -28,7 +28,7 @@ SELF_PATCH=03 #### Jarett.Stevens - dmidecde -M patch for older systems with the /sys #### #### Current script home page/wiki/git: https://github.com/smxi/inxi -#### Documentation/wiki pages will move to http://smxi.org soon. +#### Documentation/wiki pages will move to https://smxi.org soon. #### Script forums: http://techpatterns.com/forums/forum-33.html #### IRC support: irc.oftc.net channel #smxi #### Version control: @@ -52,7 +52,6 @@ SELF_PATCH=03 #### If you don't understand what Free Software is, please read (or reread) #### this page: http://www.gnu.org/philosophy/free-sw.html ######################################################################## - #### #### PACKAGE NAME NOTES #### * Package names in (...) are the Debian Squeeze package name. Check your @@ -312,6 +311,7 @@ B_LABEL_SET='false' B_LSPCI='false' B_LOG_COLORS='false' B_LOG_FULL_DATA='false' +B_MAN='true' B_MAPPER_SET='false' B_OUTPUT_FILTER='false' B_OVERRIDE_FILTER='false' @@ -489,14 +489,11 @@ SELF_DOWNLOAD='https://github.com/smxi/inxi/raw/master/' SELF_DOWNLOAD_BRANCH_1='https://github.com/smxi/inxi/raw/one/' SELF_DOWNLOAD_BRANCH_2='https://github.com/smxi/inxi/raw/two/' SELF_DOWNLOAD_BRANCH_3='https://github.com/smxi/inxi/raw/three/' -SELF_DOWNLOAD_BRANCH_4='https://github.com/smxi/inxi/raw/four/' -SELF_DOWNLOAD_BRANCH_BSD='https://github.com/smxi/inxi/raw/bsd/' -SELF_DOWNLOAD_BRANCH_GNUBSD='https://github.com/smxi/inxi/raw/gnubsd/' -SELF_DOWNLOAD_DEV='http://smxi.org/test/' +SELF_DOWNLOAD_DEV='https://smxi.org/test/' # note, you can use any ip url here as long as it's the only line on the output page. # Also the ip address must be the last thing on that line. If you abuse this ip tool # you will be banned from further access. Most > 24x daily automated queries to it are abuse. -WAN_IP_URL='http://smxi.org/opt/ip.php' +WAN_IP_URL='https://smxi.org/opt/ip.php' KONVI_CFG="konversation/scripts/$SELF_NAME.conf" # relative path to $(kde-config --path data) ### INITIALIZE VARIABLES NULL ### @@ -1323,7 +1320,7 @@ select_default_color_scheme() ;; esac set_color_scheme $i - print_screen_output "$irc_clear $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}X.Org${C2} 1.7.7" + print_screen_output "$irc_clear $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}Display Server${C2} x11 (X.Org 1.7.7)" done set_color_scheme 0 @@ -1659,7 +1656,9 @@ script_self_updater() print_screen_output "To run the new version, just start $SELF_NAME again." print_screen_output "----------------------------------------" print_screen_output "Starting download of man page file now." - if [[ ! -d $man_file_location ]];then + if [[ $B_MAN == 'false' ]];then + print_screen_output "Skipping man download because branch version is being used." + elif [[ ! -d $man_file_location ]];then print_screen_output "The required man directory was not detected on your system, unable to continue: $man_file_location" else if [[ $B_ROOT == 'true' ]];then @@ -1764,12 +1763,12 @@ set_man_location() # args: $1 - debug data type: sys|xorg|disk debug_data_collector() { - local xiin_app='' xiin_data_file='' error='' b_run_xiin='false' b_xiin_downloaded='false' + local xiin_app='' sys_data_file='' error='' b_run_xiin='false' b_xiin_downloaded='false' local Debug_Data_Dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids='' local completed_gz_file='' Xiin_File='xiin.py' ftp_upload='ftp.techpatterns.com/incoming' local Line='-------------------------' local start_directory=$( pwd ) - local host='' debug_i='' root_string='' + local host='' debug_i='' root_string='' b_perl_worked='false' b_uploaded='false' if (( "$BASH" >= 4 ));then host="${HOSTNAME,,}" @@ -1802,7 +1801,7 @@ debug_data_collector() echo "Starting debugging data collection type: $1" cd $SELF_DATA_DIR if [[ -d $SELF_DATA_DIR/$Debug_Data_Dir ]];then - echo 'Deleting previous xiin data directory...' + echo "Deleting previous $SELF_NAME debugger data directory..." rm -rf $SELF_DATA_DIR/$Debug_Data_Dir fi mkdir $SELF_DATA_DIR/$Debug_Data_Dir @@ -1891,6 +1890,7 @@ debug_data_collector() ps aux &> $Debug_Data_Dir/ps-aux.txt ps -e &> $Debug_Data_Dir/ps-e.txt ps -p 1 &> $Debug_Data_Dir/ps-p-1.txt + echo "Collecting init data..." cat /proc/1/comm &> $Debug_Data_Dir/proc-1-comm.txt runlevel &> $Debug_Data_Dir/runlevel.txt if type -p rc-status &>/dev/null;then @@ -1961,7 +1961,11 @@ debug_data_collector() else touch $Debug_Data_Dir/systemd-detect-virt-absent fi - + if type -p perl &>/dev/null;then + perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' &> $Debug_Data_Dir/perl-modules.txt + else + touch $Debug_Data_Dir/perl-missing.txt + fi cat /etc/src.conf &> $Debug_Data_Dir/bsd-etc-src-conf.txt cat /etc/make.conf &> $Debug_Data_Dir/bsd-etc-make-conf.txt cat /etc/issue &> $Debug_Data_Dir/etc-issue.txt @@ -2157,29 +2161,41 @@ debug_data_collector() cat /proc/ide/*/* &> $Debug_Data_Dir/proc-ide-hdx-cat.txt cat /etc/fstab &> $Debug_Data_Dir/etc-fstab.txt cat /etc/mtab &> $Debug_Data_Dir/etc-mtab.txt + if type -p nvme &>/dev/null; then + touch $Debug_Data_Dir/nvme-present + else + touch $Debug_Data_Dir/nvme-absent + fi fi if [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then echo 'Collecting networking data...' ifconfig &> $Debug_Data_Dir/ifconfig.txt ip addr &> $Debug_Data_Dir/ip-addr.txt fi - # first download and verify xiin + # create the error file in case it's needed if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then touch $SELF_DATA_DIR/$Debug_Data_Dir/xiin-error.txt fi # note, only bash 4> supports ;;& for case, so using if/then here if [[ -z $BSD_TYPE ]] && [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then echo $Line - xiin_data_file=$SELF_DATA_DIR/$Debug_Data_Dir/xiin-sys.txt - touch $xiin_data_file + sys_data_file=$SELF_DATA_DIR/$Debug_Data_Dir/xiin-sys.txt + echo "Getting file paths in /sys..." + ls_sys 1 + ls_sys 2 + ls_sys 3 + ls_sys 4 + # note, this generates more lines than the full sys parsing, so only use if required + # ls_sys 5 + touch $sys_data_file if type -p perl &>/dev/null;then - echo "Collecting data from /sys..." + echo "Parsing /sys files..." echo -n "Using Perl: " && perl --version | grep -oE 'v[0-9.]+' - xiin_data="$( perl -e ' + sys_traverse_data="$( perl -e ' use File::Find; use strict; # use warnings; - # use 5.010; + use 5.010; my @content = (); find( \&wanted, "/sys"); process_data( @content ); @@ -2192,7 +2208,8 @@ debug_data_collector() # a few variables. Since inxi does not need to see that file, we will # not use it. Also do not need . files or __ starting files return if $File::Find::name =~ /\/(\.[a-z]|__|parameters\/|debug\/)/; - # comment this one out if you experience hangs + # comment this one out if you experience hangs or if + # we discover syntax of foreign language characters return unless -T; # Must be ascii like # print $File::Find::name . "\n"; push @content, $File::Find::name; @@ -2221,17 +2238,18 @@ debug_data_collector() # print scalar @content . "\n"; print "$result"; } ' )" - if [[ -z "$xiin_data" ]];then + if [[ -z "$sys_traverse_data" ]];then echo -e "ERROR: failed to generate /sys data - removing data file.\nContinuing with incomplete data collection." echo "Continuing with incomplete data collection." - rm -f $xiin_data_file + rm -f $sys_data_file echo "/sys data generation failed. No data collected." >> $Debug_Data_Dir/xiin-error.txt else + b_perl_worked='true' echo 'Completed /sys data collection.' - echo -n "$xiin_data" > $xiin_data_file + echo -n "$sys_traverse_data" > $sys_data_file fi fi - if [[ -z "$xiin_data" ]];then + if [[ -z "$sys_traverse_data" ]];then download_xiin 'sys' if [[ $? -eq 0 ]];then b_run_xiin='true' @@ -2239,11 +2257,11 @@ debug_data_collector() echo "Running $Xiin_File tool now on /sys..." echo -n "Using " && python --version python --version &> $Debug_Data_Dir/python-version.txt - python ./$Xiin_File -d /sys -f $xiin_data_file + python ./$Xiin_File -d /sys -f $sys_data_file if [[ $? -ne 0 ]];then error=$? echo -e "ERROR: $Xiin_File exited with error $error - removing data file.\nContinuing with incomplete data collection." - rm -f $xiin_data_file + rm -f $sys_data_file echo "$Xiin_File data generation failed with python error $error" >> $Debug_Data_Dir/xiin-error.txt fi fi @@ -2252,7 +2270,7 @@ debug_data_collector() fi # has to be before gz cleanup if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then - if [[ $b_xiin_downloaded == 'false' ]];then + if [[ $b_xiin_downloaded == 'false' && $b_perl_worked == 'false' ]];then echo $Line download_xiin 'upload' if [[ $? -eq 0 ]];then @@ -2289,18 +2307,30 @@ debug_data_collector() echo $completed_gz_file if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then echo $Line - if [[ $b_run_xiin == 'true' ]];then - echo "Running automatic upload of data to remote server $ftp_upload now..." - python ./$Xiin_File --version - python ./$Xiin_File -u $completed_gz_file $ftp_upload + if [[ $b_perl_worked == 'true' ]];then + upload_debugger_data "$completed_gz_file" if [[ $? -gt 0 ]];then - echo $Line - echo "Error: looks like the ftp upload failed. Error number: $?" - # echo "The ftp upload failed. Error number: $?" >> $Debug_Data_Dir/xiin-error.txt + echo "Error: looks like the Perl ftp upload failed. Error number: $?" + else + b_uploaded='true' + echo "Hurray! Looks like the Perl ftp upload worked!" + fi + fi + if [[ $b_uploaded == 'false' ]];then + if [[ $b_run_xiin == 'true' ]];then + echo "Running automatic upload of data to remote server $ftp_upload now..." + python ./$Xiin_File --version + python ./$Xiin_File -u $completed_gz_file $ftp_upload + if [[ $? -gt 0 ]];then + echo $Line + echo "Error: looks like the Python ftp upload failed. Error number: $?" + # echo "The ftp upload failed. Error number: $?" >> $Debug_Data_Dir/xiin-error.txt + fi + else + echo 'Unable to run the automatic ftp upload because no uploaders appear to be working or available.' + # that has been removed at this point, so no more logging + # echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $Debug_Data_Dir/xiin-error.txt fi - else - echo 'Unable to run the automatic ftp upload because of an error with the xiin download.' - # echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $Debug_Data_Dir/xiin-error.txt fi else echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming' @@ -2312,8 +2342,85 @@ debug_data_collector() fi exit 0 } +## args: $1 - level +ls_sys() +{ + local files='' + case $1 in + 1)files='/sys/';; + 2)files='/sys/*/';; + 3)files='/sys/*/*/';; + 4)files='/sys/*/*/*/';; # this should be enough for most use cases + 5)files='/sys/*/*/*/*/';; # very large file, shows best shortcuts though + 6)files='/sys/*/*/*/*/*/';; # slows down too much, too big, can cause ls error + 7)files='/sys/*/*/*/*/*/*/';; # impossibly big, will fail + esac + ls -l $files 2>/dev/null | awk '{ + if (NF > 7) { + if ($1 ~/^d/){ + f="d - " + } + else if ($1 ~/^l/){ + f="l - " + } + else { + f="f - " + } + # includes -> target for symbolic link if present + print "\t" f $9 " " $10 " " $11 + } + else if (!/^total / ) { + print $0 + } + }' &> $Debug_Data_Dir/sys-level-$1.txt +} + +## args: $1 - debugger file name +upload_debugger_data() +{ + local result='' debugger_file=$1 + + if ! type -p perl &>/dev/null;then + echo "Perl is not installed!" + return 2 + elif ! perl -MNet::FTP -e 1 &>/dev/null;then + echo "Required Perl module Net::FTP not installed." + return 3 + fi + export debugger_file + echo "Starting Perl Uploader..." + + result="$( perl -e ' + use strict; + use warnings; + use Net::FTP; + my ($ftp, $host, $user, $pass, $dir, $fpath, $error); + $host = "ftp.techpatterns.com"; + $user = "anonymous"; + $pass = "anonymous\@techpatterns.com"; + $dir = "incoming"; + $fpath = $ENV{debugger_file}; + # NOTE: important: must explicitly set to passive true/1 + $ftp = Net::FTP->new($host, Debug => 0, Passive => 1); + $ftp->login($user, $pass) || die $ftp->message; + $ftp->binary(); + $ftp->cwd($dir); + print "Connected to FTP server.\n"; + $ftp->put($fpath) || die $ftp->message; + $ftp->quit; + print "Uploaded file.\n"; + print $ftp->message; + ' )" + + echo "$result" + if [[ "$result" == *Goodbye* ]];then + return 0 + else + return 1 + fi +} # $1 - download type [sys|upload] -function download_xiin() +download_xiin() { local xiin_download='' xiin_url="https://github.com/smxi/inxi/raw/xiin/$Xiin_File" local downloader_error=0 download_type='uploader' @@ -2390,17 +2497,18 @@ check_recommends_user_output() ftp:ftp-OpenBSD-only~ftp-OpenBSD-only~ftp-OpenBSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(OpenBSD_only)' fi initialize_paths - print_lines_basic "0" "" "$SELF_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SELF_NAME uses. Python is only for debugging data collection." + print_lines_basic "0" "" "$SELF_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SELF_NAME uses. Python is only for debugging data uploads unless Perl is missing." echo $Line echo "Bash version: $( bash --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU bash/ {print $4}' )" if type -p gawk &>/dev/null;then gawk_version=$( gawk --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU Awk/ {print $3}' ) fi if type -p sed &>/dev/null;then - sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU sed version/ {print $4}' ) + # sed (GNU sed) 4.4 OR GNU sed version 4.4 + sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^(GNU sed version|sed)/ {print $4;exit}' ) if [[ -z $sed_version ]];then # note: bsd sed shows error with --version flag - sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^sed: illegal option/ {print "BSD sed"}' ) + sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^sed: illegal option/ {print "BSD sed";exit}' ) fi fi if type -p sudo &>/dev/null;then @@ -2416,8 +2524,8 @@ check_recommends_user_output() echo "Gawk version: $gawk_version" echo "Sed version: $sed_version" echo "Sudo version: $sudo_version" - echo "Python version: $python_version" - echo "Perl version: $perl_versio" + echo "Python version: $python_version (deprecated)" + echo "Perl version: $perl_version" echo $Line echo "Test One: Required System Directories (Linux Only)." @@ -2888,7 +2996,6 @@ get_parameters() use_short='false' ;; M) B_SHOW_MACHINE='true' - B_SHOW_BATTERY='true' use_short='false' ;; n) B_SHOW_ADVANCED_NETWORK='true' @@ -3096,32 +3203,28 @@ get_parameters() 3) B_TESTING_1='true' B_TESTING_2='true' ;; - 1[0-6]|http*) + 1[0-3]|http*) if [[ $B_ALLOW_UPDATE == 'true' ]];then case $OPTARG in 10) script_self_updater "$SELF_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG" + B_MAN='false' ;; 11) script_self_updater "$SELF_DOWNLOAD_BRANCH_1" 'branch one server' "$opt $OPTARG" + B_MAN='false' ;; 12) script_self_updater "$SELF_DOWNLOAD_BRANCH_2" 'branch two server' "$opt $OPTARG" + B_MAN='false' ;; 13) script_self_updater "$SELF_DOWNLOAD_BRANCH_3" 'branch three server' "$opt $OPTARG" - ;; - 14) - script_self_updater "$SELF_DOWNLOAD_BRANCH_4" 'branch four server' "$opt $OPTARG" - ;; - 15) - script_self_updater "$SELF_DOWNLOAD_BRANCH_BSD" 'branch bsd server' "$opt $OPTARG" - ;; - 16) - script_self_updater "$SELF_DOWNLOAD_BRANCH_GNUBSD" 'branch gnubsd server' "$opt $OPTARG" + B_MAN='false' ;; http*) script_self_updater "$OPTARG" 'alt server' "$opt " + B_MAN='false' ;; esac else @@ -3291,7 +3394,7 @@ show_options() print_lines_basic "2" "-A" "Chip vendor:product ID for each audio device." print_lines_basic "2" "-B" "serial number, voltage (if available)." print_lines_basic "2" "-C" "Minimum CPU speed, if available." - print_lines_basic "2" "-D" "Disk serial number." + print_lines_basic "2" "-D" "Disk serial number; Firmware rev. if available." print_lines_basic "2" "-G" "Chip vendor:product ID for each video card; (mir/wayland only) compositor (alpha test); OpenGL compatibility version, if free drivers and available." print_lines_basic "2" "-I" "Other detected installed gcc versions (if present). System default runlevel. Adds parent program (or tty) for shell info if not in IRC (like Konsole or Gterm). Adds Init/RC (if found) version number." print_lines_basic "2" "-m" "Manufacturer, Serial Number, single/double bank (if found)." @@ -3332,9 +3435,9 @@ show_options() print_lines_basic "2" "10" "Color logging." print_lines_basic "1" "" "The following create a tar.gz file of system data, plus collecting the inxi output to file. To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi^-xx@^<11-14>" print_lines_basic "1" "" "For alternate ftp upload locations: Example:^inxi^-!^ftp.yourserver.com/incoming^-xx@^14" - print_lines_basic "2" "11" "With data file of xiin read of /sys." + print_lines_basic "2" "11" "With data file of tree traverse read of /sys." print_lines_basic "2" "12" "With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc." - print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus xiin data file." + print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus /sys tree traverse data file." print_lines_basic "2" "14" "Everything, full data collection." print_screen_output " " print_screen_output "Advanced Options:" @@ -3355,9 +3458,6 @@ show_options() print_lines_basic "1" "-! 11" "Triggers an update from source branch one - if present, of course." print_lines_basic "1" "-! 12" "Triggers an update from source branch two - if present, of course." print_lines_basic "1" "-! 13" "Triggers an update from source branch three - if present, of course." - print_lines_basic "1" "-! 14" "Triggers an update from source branch four - if present, of course." - print_lines_basic "1" "-! 15" "Triggers an update from source branch BSD - if present, of course." - print_lines_basic "1" "-! 16" "Triggers an update from source branch GNUBSD - if present, of course." print_lines_basic "1" "-! " " Triggers an update from whatever server you list." print_lines_basic "1" "" "Example: inxi^-!^http://yourserver.com/testing/inxi" fi @@ -3518,7 +3618,7 @@ print_version_info() print_lines_basic "0" "" "$SELF_NAME - the universal, portable, system information tool for console and irc." print_screen_output " " print_lines_basic "0" "" "This program started life as a fork of Infobash 3.02: Copyright^(C)^2005-2007^Michiel^de^Boer^a.k.a.^locsmif." - print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright^(C)^2008-${year_modified%%-*}^Harald^Hope,^Scott^Rogers,^aka^h2^&trash80." + print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright^(C)^2008-${SELF_DATE%%-*}^Harald^Hope^aka^h2. CPU/Konversation^fixes:^Scott^Rogers^aka^trash80. USB^audio^fixes:^Steven^Barrett^aka^damentz." print_screen_output " " print_lines_basic "0" "" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. (http://www.gnu.org/licenses/gpl.html)" fi @@ -4516,6 +4616,7 @@ get_cpu_architecture() { eval $LOGFS case $1 in + # https://en.wikipedia.org/wiki/List_of_AMD_CPU_microarchitectures amd) case $2 in 4) @@ -4557,16 +4658,16 @@ get_cpu_architecture() ;; 11) case $3 in - 3)ARCH='K8 rev.E+';; + 3)ARCH='Turion X2 Ultra';; esac ;; - 12) + 12) # might also need cache handling like 14/16 case $3 in - 1)ARCH='K10';; - *)ARCH='K10';; + 1)ARCH='Fusion';; + *)ARCH='Fusion';; esac ;; - 14) + 14) # SOC, apu case $3 in 1|2)ARCH='Bobcat';; *)ARCH='Bobcat';; @@ -4574,17 +4675,17 @@ get_cpu_architecture() ;; 15) case $3 in - 0|1)ARCH='Bulldozer';; - 2|10|13)ARCH='Piledriver';; - 30|38)ARCH='Steamroller';; - 60|65|70)ARCH='Excavator';; + 0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)ARCH='Bulldozer';; + 10|11|12|13|14|15|16|17|18|19|1A|1B|1C|1D|1E|1F)ARCH='Piledriver';; + 30|31|32|33|34|35|36|37|38|39|3A|3B|3C|3D|3E|3F)ARCH='Steamroller';; + 60|61|62|63|64|65|66|67|68|69|6A|6B|6C|6D|6E|6F|70|71|72|73|74|75|76|77|78|79|7A|7B|7C|7D|7E|7F)ARCH='Excavator';; *)ARCH='Bulldozer';; esac ;; - 16) + 16) # SOC, apu case $3 in - 0)ARCH='Jaguar';; - 30)ARCH='Puma';; + 0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)ARCH='Jaguar';; + 30|31|32|33|34|35|36|37|38|39|3A|3B|3C|3D|3E|3F)ARCH='Puma';; *)ARCH='Jaguar';; esac ;; @@ -4659,10 +4760,13 @@ get_cpu_architecture() 3C|3F|45|46)ARCH='Haswell';; 3D|47|4F|56)ARCH='Broadwell';; 4E|55|9E)ARCH='Skylake';; + 5E)ARCH='Skylake-S';; 4C|5D)ARCH='Airmont';; 8E|9E)ARCH='Kaby Lake';; 57)ARCH='Knights Landing';; 85)ARCH='Knights Mill';; + # product codes: https://en.wikipedia.org/wiki/List_of_Intel_microprocessors + # coming: coffee lake; cannonlake; icelake; tigerlake esac ;; B) @@ -7228,17 +7332,17 @@ get_hdd_data_basic() fi if swapctl -l -k &>/dev/null;then swap_size=$( swapctl -l -k 2>/dev/null | gawk ' - BEGIN { - swapSize=0 - total=0 - } - ( $1 ~ /^\/dev/ ) && ( $2 ~ /^[0-9]+$/ ) { - total += $2 - } - END { - # result in blocks already - print total - }' ) +BEGIN { +swapSize=0 +total=0 +} +( $1 ~ /^\/dev/ ) && ( $2 ~ /^[0-9]+$/ ) { + total += $2 +} +END { + # result in blocks already + print total +}' ) fi fi # echo ss: $swap_size @@ -7333,12 +7437,13 @@ get_hdd_data_basic() printf( $NF",%.1fGB,,\n", driveSize ) } # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below + # See https://www.mjmwired.net/kernel/Documentation/devices.txt for kernel 4.x device numbers # $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 { # size += $3 # } # special case from this data: 8 0 156290904 sda - # note: vm has 252/253/254 known starter, grsec has 202 - $1 ~ /^(3|8|22|33|202|252|253|254)$/ && $NF ~ /[hsv]d[a-z]+$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { + # note: known starters: vm: 252/253/254; grsec: 202; nvme: 259 + $1 ~ /^(3|8|22|33|202|252|253|254|259)$/ && $NF ~ /(nvme[0-9]+n[0-9]+|[hsv]d[a-z]+)$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { size += $3 } END { @@ -7385,21 +7490,22 @@ get_hard_drive_data_advanced() local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j='' local sd_ls_by_id='' ls_disk_by_id='' ls_disk_by_path='' usb_exists='' a_temp='' local firewire_exists='' thunderbolt_exists='' thunderbolt_exists='' hdd_temp hdd_serial='' + local firmware_rev='' working_path='' block_type='' ## check for all ide type drives, non libata, only do it if hdx is in array ## this is now being updated for new /sys type paths, this may handle that ok too - if [[ -n $( grep -E 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then + if [[ -n $( grep -Es 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then # remember, we're using the last array item to store the total size of disks for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) do IFS="," a_temp_working=( ${A_HDD_DATA[i]} ) IFS="$ORIGINAL_IFS" - if [[ -n $( grep -E '^hd[a-z]' <<< ${a_temp_working[0]} ) ]];then + if [[ -z ${a_temp_working[0]/*hd[a-z]*/} ]];then if [[ -e /proc/ide/${a_temp_working[0]}/model ]];then a_temp_working[2]="$( remove_erroneous_chars /proc/ide/${a_temp_working[0]}/model )" else - a_temp_working[2]="Name n/a" + a_temp_working[2]='' fi # these loops are to easily extend the cpu array created in the gawk script above with more fields per cpu. for (( j=0; j < ${#a_temp_working[@]}; j++ )) @@ -7448,23 +7554,42 @@ get_hard_drive_data_advanced() log_function_data 'cat' "$FILE_SCSI" fi IFS="$ORIGINAL_IFS" - ## then we'll loop through that array looking for matches. - if [[ -n $( grep -E 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then + if [[ -n $( grep -Es 'sd[a-z]|nvme' <<< ${A_HDD_DATA[@]} ) ]];then # first pack the main ls variable so we don't have to keep using ls /dev... # not all systems have /dev/disk/by-id ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )" ls_disk_by_path="$( ls -l /dev/disk/by-path 2>/dev/null )" for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) do - if [[ -n $( grep -E '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then + firmware_rev='' + hdd_temp='' + hdd_serial='' + temp_name='' + working_path='' + block_type='' + if [[ -z ${A_HDD_DATA[$i]/*nvme*/} ]];then + block_type='nvme' + elif [[ -z ${A_HDD_DATA[$i]/*sd[a-z]*/} ]];then + block_type='sdx' + fi + if [[ -n $block_type ]];then IFS="," a_temp_working=( ${A_HDD_DATA[$i]} ) IFS="$ORIGINAL_IFS" + if [[ $block_type == 'sdx' ]];then + working_path=/sys/block/${a_temp_working[0]}/device/ + elif [[ $block_type == 'nvme' ]];then + # this results in: + # /sys/devices/pci0000:00/0000:00:03.2/0000:06:00.0/nvme/nvme0/nvme0n1 + # but we want to go one level down so slice off trailing nvme0n1 + working_path=$(readlink -f /sys/block/${a_temp_working[0]} 2>/dev/null ) + working_path=${working_path%nvme*} + fi # /sys/block/[sda,hda]/device/model # this is handles the new /sys data types first - if [[ -e /sys/block/${a_temp_working[0]}/device/model ]];then - temp_name="$( remove_erroneous_chars /sys/block/${a_temp_working[0]}/device/model )" + if [[ -e ${working_path}model ]];then + temp_name="$( remove_erroneous_chars ${working_path}model )" temp_name=$( cut -d '-' -f 1 <<< ${temp_name// /_} ) elif [[ ${#a_temp_scsi[@]} -gt 0 ]];then for (( j=0; j < ${#a_temp_scsi[@]}; j++ )) @@ -7485,15 +7610,14 @@ get_hard_drive_data_advanced() fi done fi - - if [[ -z $temp_name ]];then - temp_name="Name n/a" - # maybe remove this from the conditional, detection of usb may not depend on the name - else # + # I don't know identifier for thunderbolt in /dev/disk/by-id / /dev/disk/by-path + if [[ -n $temp_name && -n "$ls_disk_by_id" ]];then usb_exists=$( grep -Em1 "usb-.*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) firewire_exists=$( grep -Em1 "ieee1394-.*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) # thunderbolt_exists=$( grep -Em1 "ieee1394-.*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) # note: sometimes with wwn- numbering usb does not appear in by-id but it does in by-path + fi + if [[ -n "$ls_disk_by_path" ]];then if [[ -z $usb_exists ]];then usb_exists=$( grep -Em1 "usb-.*${a_temp_working[0]}$" <<< "$ls_disk_by_path" ) fi @@ -7508,7 +7632,6 @@ get_hard_drive_data_advanced() fi fi a_temp_working[2]=$temp_name - # these loops are to easily extend the cpu array created in the gawk script above with more fields per cpu. for (( j=0; j < ${#a_temp_working[@]}; j++ )) do if [[ $j -gt 0 ]];then @@ -7523,15 +7646,21 @@ get_hard_drive_data_advanced() a_temp_working=( ${A_HDD_DATA[i]} ) # echo "a:" ${a_temp_working[@]} IFS="$ORIGINAL_IFS" - hdd_temp='' - hdd_serial='' + if [[ -n ${a_temp_working[1]} ]];then hdd_temp=$( get_hdd_temp_data "/dev/${a_temp_working[0]}" ) fi if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then - hdd_serial=$( get_hdd_serial_number "${a_temp_working[0]}" ) + if [[ -e ${working_path}serial ]];then + hdd_serial="$( remove_erroneous_chars ${working_path}serial )" + else + hdd_serial=$( get_hdd_serial_number "${a_temp_working[0]}" ) + fi + if [[ -e ${working_path}firmware_rev ]];then + firmware_rev="$( remove_erroneous_chars ${working_path}firmware_rev )" + fi fi - A_HDD_DATA[i]="${a_temp_working[0]},${a_temp_working[1]},${a_temp_working[2]},${a_temp_working[3]},$hdd_serial,$hdd_temp" + A_HDD_DATA[i]="${a_temp_working[0]},${a_temp_working[1]},${a_temp_working[2]},${a_temp_working[3]},$hdd_serial,$hdd_temp,$firmware_rev" # echo b: ${A_HDD_DATA[i]} fi done @@ -7608,7 +7737,7 @@ get_hard_drive_data_bsd() if ( aDisks[aIds[key], "model"] !~ /raid/ ) { workingSize = aDisks[aIds[key], "size"]/1000 workingSize = sprintf( "%.1fGB", workingSize ) - print aDisks[aIds[key], "id"] "," workingSize "," aDisks[aIds[key], "model"] "," "," aDisks[aIds[key], "serial"] "," + print aDisks[aIds[key], "id"] "," workingSize "," aDisks[aIds[key], "model"] "," "," aDisks[aIds[key], "serial"] ",," } } size = size/1000 # calculate size in GB size @@ -7655,10 +7784,11 @@ get_hdd_serial_number() get_partition_dev_data 'id' # lrwxrwxrwx 1 root root 9 Apr 26 09:32 scsi-SATA_ST3160827AS_5MT2HMH6 -> ../../sdc + # exception: ata-InnoDisk_Corp._-_mSATA_3ME3_BCA34401050060191 -> ../../sda # exit on the first instance hdd_serial=$( gawk ' /'$1'$/ { - serial=gensub( /^(.+)_([^_]+)$/, "\\2", 1, $9 ) + serial=gensub( /(.+)_([^_]+)$/, "\\2", 1, $9 ) print serial exit }' <<< "$DEV_DISK_ID" ) @@ -7673,29 +7803,45 @@ get_hdd_serial_number() get_hdd_temp_data() { eval $LOGFS - local hdd_temp='' sudo_command='' + local hdd_temp='' sudo_command='' device=$1 - if [[ $B_HDDTEMP_TESTED != 'true' ]];then - B_HDDTEMP_TESTED='true' - HDDTEMP_PATH=$( type -p hddtemp ) - fi if [[ $B_SUDO_TESTED != 'true' ]];then B_SUDO_TESTED='true' SUDO_PATH=$( type -p sudo ) fi - - if [[ -n $HDDTEMP_PATH && -n $1 ]];then - # only use sudo if not root, -n option requires sudo -V 1.7 or greater. sudo will just error out - # which is the safest course here for now, otherwise that interactive sudo password thing is too annoying - # important: -n makes it non interactive, no prompt for password - if [[ $B_ROOT != 'true' && -n $SUDO_PATH ]];then - sudo_command='sudo -n ' + # only use sudo if not root, -n option requires sudo -V 1.7 or greater. sudo will just error out + # which is the safest course here for now, otherwise that interactive sudo password thing is too annoying + # important: -n makes it non interactive, no prompt for password + if [[ $B_ROOT != 'true' && -n $SUDO_PATH ]];then + sudo_command='sudo -n ' + fi + # try this to see if hddtemp gives result for the base name + if [[ -z ${device/*nvme*/} ]];then + if type -p nvme &>/dev/null;then + device=${device%n[0-9]} + # this will fail if regular user and no sudo present, but that's fine, it will just return null + hdd_temp=$( eval $sudo_command nvme smart-log $device 2>/dev/null | gawk -F ':' ' + BEGIN { + IGNORECASE=1 + } + # other rows may have: Temperature sensor 1 : + /^temperature\s*:/ { + gsub(/^[[:space:]]+|[[:space:]]*C$/,"",$2) + print $2 + }' ) fi - # this will fail if regular user and no sudo present, but that's fine, it will just return null - hdd_temp=$( eval $sudo_command $HDDTEMP_PATH -nq -u C $1 ) - if [[ -n $hdd_temp && -n $( grep -E '^([0-9\.]+)$' <<< $hdd_temp ) ]];then - echo $hdd_temp + else + if [[ $B_HDDTEMP_TESTED != 'true' ]];then + B_HDDTEMP_TESTED='true' + HDDTEMP_PATH=$( type -p hddtemp ) fi + if [[ -n $HDDTEMP_PATH && -n $device ]];then + # this will fail if regular user and no sudo present, but that's fine, it will just return null + hdd_temp=$( eval $sudo_command $HDDTEMP_PATH -nq -u C $device ) + fi + fi + if [[ -n $hdd_temp && -z ${hdd_temp//[0-9]/} ]];then + echo $hdd_temp fi eval $LOGFE } @@ -7858,7 +8004,6 @@ get_kernel_compiler_version() echo $compiler_version } - get_kernel_version() { eval $LOGFS @@ -8594,12 +8739,11 @@ get_networking_wan_ip_data() # get ip using wget redirect to stdout. This is a clean, text only IP output url, # single line only, ending in the ip address. May have to modify this in the future # to handle ipv4 and ipv6 addresses but should not be necessary. - # awk has bad regex handling so checking it with grep -E instead # ip=$( echo 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | gawk --re-interval ' # ip=$( wget -q -O - $WAN_IP_URL | gawk --re-interval ' - # this generates a direct dns based ipv4 ip address, but if opendns.com goes down, the fall + # this generates a direct dns based ipv4 ip address, but if opendns.com goes down, + # the fall backs will still work. # note: consistently slower than domain based: dig +short +time=1 +tries=1 myip.opendns.com. A @208.67.222.222 - # backs will still work. if [[ -n $DNSTOOL ]];then ip=$( dig +short +time=1 +tries=1 myip.opendns.com @resolver1.opendns.com 2>/dev/null) fi @@ -12563,7 +12707,6 @@ print_short_data() fi fi - #set_color_scheme 12 if [[ $B_IRC == 'true' ]];then for i in $C1 $C2 $CN @@ -13050,7 +13193,10 @@ print_cpu_data() # note that we need to multiply by number of actual cpus here to get true cache size if [[ -n ${a_cpu_working[2]} ]];then if [[ -z $BSD_TYPE ]];then - if [[ $cpu_vendor != 'intel' ]];then + # AMD SOS chips appear to report full L2 cache per core + if [[ "${a_cpu_info[3]}" == 'amd' ]] && [[ "${a_cpu_info[4]}" == '14' || "${a_cpu_info[4]}" == '16' ]];then + cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" ) + elif [[ $cpu_vendor != 'intel' ]];then cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" ) else cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" ) @@ -13603,7 +13749,7 @@ print_hard_disk_data() { eval $LOGFS local hdd_data='' hdd_data_2='' a_hdd_working='' hdd_temp_data='' hdd_string='' - local hdd_serial='' dev_string='/dev/' + local hdd_serial='' dev_string='/dev/' firmware_rev='' local dev_data='' size_data='' hdd_model='' usb_data='' hdd_name='' local Line_Starter='Drives:' # inherited by print_optical_drives # load A_HDD_DATA - this will also populate the full bsd disk data array values @@ -13668,6 +13814,12 @@ print_hard_disk_data() hdd_serial='N/A' fi hdd_serial="${C1}serial$SEP3${C2} $hdd_serial " + if [[ -n ${a_hdd_working[6]} ]];then + firmware_rev=${a_hdd_working[6]} + firmware_rev="${C1}firmware$SEP3${C2} $firmware_rev " + else + firmware_rev='' + fi fi dev_data="$dev_string${a_hdd_working[0]} " fi @@ -13680,7 +13832,7 @@ print_hard_disk_data() hdd_name="${C1}model$SEP3${C2} $hdd_name_temp" hdd_string="${C1}ID-$((i+1))$SEP3${C2} $usb_data$dev_data$hdd_name$size_data" part_1_data="$hdd_model$hdd_string " - part_2_data="$hdd_serial$hdd_temp_data" + part_2_data="$hdd_serial$hdd_temp_data$firmware_rev" ## Forcing the capacity to print on its own row, and the first drive on its own ## then each disk prints on its own line, or two lines, depending on console/output width if [[ $i -eq 0 ]];then