Bug fixes, feature updates, changes!!

Bugs:
1. There was a glitch in the pattern that made -D samsung / seagate not ID right,
fixed.

2. I  do not like calling this a bug, because it's not an inxi bug, it's an upstream
regression in the syntax used in /proc/version, they changed a fully predictable
gcc version .... to a random series of embedded/nested parentheses and other random
junk. inxi tries to deal with this regression, which will be perceived as a bug in
systems running kernel 5.8 or newer and inxi 3.1.06 or older, since it will fail to
show the kernel build compiler version since it can't find it in the string.

I really dislike these types of regressions caused by bad ideas done badly and
without any thought to the transmitted knowledge base, but that's how it goes,
no discipline, I miss the graybeards, who cared about things like this.

Fixes:
1. more -D nvme id changes, intel in this case.

2. FreeBSD lsusb changed syntax, which triggered a series of errors when run.
Since I never really got the required data [hint bsd users, do NOT file issues
that you want fixed and then not provide all the data required, otherwise, really,
why did you file the issue? did you expect magic pixies to fly in with the required
data?] See the README.txt for what to do to get issues really handed in BSDs.

tldr; version: if you won't spend the time providing data and access required,
I won't spend the time on the issue, period, since if you don't care enough to
do those simple steps, why on earth do you expect me to?

Changes:
1. -C 'boost' option changed from -xxx feature to -x feature.
Consider it a promotion!

2. Added --dbg 19 switch to enable smart data debugging for -Da.

3. Some new tools to handle impossible data values for some -D situations for SMART
where the smart report contains gibberish values, that was issue #225 -- tools were
convert_hex and is_Hex. The utility for these is limited, but might be of use in
some cases, like handling the above gibberish data value.
This commit is contained in:
Harald Hope 2020-09-29 16:22:15 -07:00
parent ddbd8e8679
commit ef428e75e1
3 changed files with 114 additions and 32 deletions

86
inxi
View file

@ -26,7 +26,7 @@ use 5.008;
# no multidimensional;
# no bareword::filehandle;
use Cwd qw(abs_path); # qw(abs_path);#abs_path realpath getcwd
use Cwd qw(abs_path); # #abs_path realpath getcwd
use Data::Dumper qw(Dumper); # print_r
use File::Find;
use File::stat; # needed for Xorg.0.log file mtime comparisons
@ -39,8 +39,8 @@ use POSIX qw(uname strftime ttyname);
## INXI INFO ##
my $self_name='inxi';
my $self_version='3.1.06';
my $self_date='2020-08-17';
my $self_version='3.1.07';
my $self_date='2020-09-29';
my $self_patch='00';
## END INXI INFO ##
@ -1386,11 +1386,11 @@ sub new {
sub run_debugger {
#require File::Find;
#import File::Find::Functions;
#File::Find::Functions->import;
require File::Copy;
import File::Copy;
File::Copy->import;
require File::Spec::Functions;
import File::Spec::Functions;
File::Spec::Functions->import;
print "Starting $self_name debugging data collector...\n";
create_debug_directory();
@ -2179,7 +2179,7 @@ sub wanted {
# NOTE: must be in format: ftp.site.com/incoming
sub upload_file {
require Net::FTP;
import Net::FTP;
Net::FTP->import;
my ($self, $ftp_url) = @_;
my ($ftp, $domain, $host, $user, $pass, $dir, $error);
$ftp_url ||= main::get_defaults('ftp-upload');
@ -2350,8 +2350,8 @@ sub set_downloader {
# For some https connections so only use tiny as option if both present
if ($dl{'tiny'}){
if (check_module('HTTP::Tiny') && check_module('IO::Socket::SSL')){
import HTTP::Tiny;
import IO::Socket::SSL;
HTTP::Tiny->import;
IO::Socket::SSL->import;
$dl{'tiny'} = 1;
}
else {
@ -3216,6 +3216,14 @@ sub compare_versions {
if ($pad1 ge $pad2){return $one}
elsif ($pad2 gt $pad1){return $two}
}
# some things randomly use hex with 0x starter, return always integer
# warning: perl will generate a 32 bit too big number warning if you pass it
# random values that exceed 2^32 in hex, even if the base system is 64 bit.
# sample: convert_hex(0x000b0000000b);
sub convert_hex {
return (defined $_[0] && $_[0] =~ /^0x/) ? hex($_[0]) : $_[0];
}
# returns count of files in directory, if 0, dir is empty
sub count_dir_files {
return unless -d $_[0];
@ -3265,6 +3273,10 @@ sub globber {
eval $end if $b_log;
return @files;
}
# arg MUST be quoted when inserted, otherwise perl takes it for a hex number
sub is_hex {
return (defined $_[0] && $_[0] =~ /^0x/) ? 1 : 0;
}
## NOTE: for perl pre 5.012 length(undef) returns warning
# receives string, returns boolean 1 if integer
@ -4842,9 +4854,10 @@ sub show_options {
PCI Bus ID/USB ID number of card; Version/port(s)/driver version (if available)." ],
['2', '-B', '', "Vendor/model, status (if available); attached devices
(e.g. wireless mouse, keyboard, if present)." ],
['2', '-C', '', "CPU $flags (short list, use -f to see full list), Bogomips
on CPU; CPU microarchitecture + revision (if found, or unless --admin,
then shows as 'stepping')." ],
['2', '-C', '', "CPU $flags (short list, use -f to see full list);
CPU boost (turbo) enabled/disabled, if present;
Bogomips on CPU; CPU microarchitecture + revision (if found, or
unless --admin, then shows as 'stepping')." ],
['2', '-d', '', "Extra optical drive features data; adds rev version to
optical drive." ],
['2', '-D', '', "HDD temp with disk data if you have hddtemp installed,
@ -4920,8 +4933,7 @@ sub show_options {
with verbose or line output, not short form):" ],
['2', '-A', '', "Serial number." ],
['2', '-B', '', "Chemistry, cycles, location (if available)." ],
['2', '-C', '', "CPU boost (turbo) enabled/disabled, if present;
CPU voltage, external clock speed (if root and dmidecode installed)." ],
['2', '-C', '', "CPU voltage, external clock speed (if root and dmidecode installed)." ],
['2', '-D', '', "Firmware rev. if available; partition scheme, in some cases; disk
rotation speed (if detected)." ],
['2', '-I', '', "For 'Shell:' adds ([su|sudo|login]) to shell name if present;
@ -5086,11 +5098,10 @@ sub show_options {
}
sub show_version {
require Cwd;
import Cwd;
# if not in PATH could be either . or directory name, no slash starting
my $working_path=$self_path;
my (@data, @row, @rows, $link, $self_string);
Cwd->import('getcwd'); # no point loading this on top use, we only use getcwd here
if ( $working_path eq '.' ){
$working_path = getcwd();
}
@ -5853,11 +5864,11 @@ sub generate_json {
error_handler('not-in-irc', 'help') if $b_irc;
#print Dumper \%data if $b_debug;
if (check_module('Cpanel::JSON::XS')){
import Cpanel::JSON::XS;
Cpanel::JSON::XS->import;
$json = Cpanel::JSON::XS::encode_json(\%data);
}
elsif (check_module('JSON::XS')){
import JSON::XS;
JSON::XS->import;
$json = JSON::XS::encode_json(\%data);
}
else {
@ -5891,7 +5902,7 @@ sub generate_xml {
error_handler('not-in-irc', 'help') if $b_irc;
#print Dumper \%data if $b_debug;
if (check_module('XML::Dumper')){
import XML::Dumper;
XML::Dumper->import;
$xml = XML::Dumper::pl2xml(\%data);
#$xml =~ s/"[0-9]+#/"/g;
if ($output_file eq 'print'){
@ -7043,9 +7054,11 @@ sub create_output_full {
if ($b_admin && $properties{'dmi-speed'} && $properties{'dmi-max-speed'}){
$rows[$j]{main::key($num++,0,2,'base/boost')} = $properties{'dmi-speed'} . '/' . $properties{'dmi-max-speed'};
}
if ($extra > 2){
if ($extra > 0){
my $boost = get_boost_status();
$rows[$j]{main::key($num++,0,2,'boost')} = $boost if $boost;
}
if ($extra > 2){
if ($properties{'volts'}){
$rows[$j]{main::key($num++,0,2,'volts')} = $properties{'volts'} . ' V';
}
@ -9452,7 +9465,10 @@ sub smartctl_data {
}
elsif ($split[$a] eq 'Media_Wearout_Indicator'){
# $data[$i]{'smart-media-wearout'} = $split[$r];
if ($b_attributes && $split[$r] > 0){
# seen case where they used hex numbers becaause values
# were in 47 billion range in hex. You can't hand perl an unquoted
# hex number that is > 2^32 without tripping a perl warning
if ($b_attributes && $split[$r] && !main::is_hex("$split[$r]") && $split[$r] > 0){
$data[$i]{'smart-media-wearout-v'} = $split[$v];
$data[$i]{'smart-media-wearout-t'} = $split[$t];
$data[$i]{'smart-media-wearout-f'} = $split[$f] if $split[$f] ne '-';
@ -9584,7 +9600,7 @@ sub smartctl_data {
}
}
}
#print Data::Dumper::Dumper\@data;
print Data::Dumper::Dumper\@data if $test[19];
eval $end if $b_log;
return @data;
}
@ -9752,7 +9768,8 @@ sub set_vendors {
@vendors = (
## These go first because they are the most likely and common ##
['(Crucial|^(FC)?CT|-CT|^M4\b|Gizmo!)','Crucial','Crucial',''],
['^(INTEL|SSD(PAM|SA2))','^INTEL','Intel',''],
# H10 HBRPEKNX0202A NVMe INTEL 512GB
['(\bINTEL\b|^SSD(PAM|SA2))','\bINTEL\b','Intel',''],
# note: S[AV][1-9][0-9] can trigger false positives
['(KINGSTON|DataTraveler|DT\s?(DUO|Microduo|101)|^SMS|^SHS|^SS0|^SUV|^Ultimate CF|HyperX|^S[AV][1234]00|^SKYMEDI)','KINGSTON','Kingston',''], # maybe SHS: SHSS37A SKC SUV
# must come before samsung MU. NOTE: toshiba can have: TOSHIBA_MK6475GSX: mush: MKNSSDCR120GB_
@ -10058,7 +10075,7 @@ sub device_vendor {
set_vendors() if !@vendors;
# 0 - match pattern; 1 - replace pattern; 2 - vendor print; 3 - serial pattern
# Data URLs: inxi-resources.txt Section: DiskData device_vendor()
# $model = 'MEDIAMAX ';
# $model = 'H10 HBRPEKNX0202A NVMe INTEL 512GB';
# $model = 'Patriot Memory';
foreach my $row (@vendors){
if ($model =~ /$row->[0]/i || ($row->[3] && $serial && $serial =~ /$row->[3]/)){
@ -12333,6 +12350,7 @@ sub wan_ip {
# dig +short @ns1-1.akamaitech.net ANY whoami.akamai.net
# this one can take forever, and sometimes requires explicit -4 or -6
# dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
if (!$b_skip_dig && (my $program = main::check_program('dig') )){
$ip = (main::grabber("$program +short +time=1 +tries=1 \@ns1-1.akamaitech.net ANY whoami.akamai.net 2>/dev/null"))[0];
$b_dig = 1;
@ -12342,6 +12360,10 @@ sub wan_ip {
# smxi: 0.525, so almost 10x slower. Dig is fast too
# leaving smxi as last test because I know it will always be up.
# --wan-ip-url replaces values with user supplied arg
# 0.059s: http://whatismyip.akamai.com/
# 0.255s: https://get.geojs.io/v1/ip
# 0.371s: http://icanhazip.com/
# 0.430s: https://smxi.org/opt/ip.php
my @urls = (!$wan_url) ? qw( http://whatismyip.akamai.com/
http://icanhazip.com/ https://smxi.org/opt/ip.php) : ($wan_url);
foreach (@urls){
@ -17869,14 +17891,18 @@ sub get_compiler_version_linux {
if ($result){
# $result = $result =~ /\*(gcc|clang)\*eval\*/;
# $result='Linux version 5.4.0-rc1 (sourav@archlinux-pc) (clang version 9.0.0 (tags/RELEASE_900/final)) #1 SMP PREEMPT Sun Oct 6 18:02:41 IST 2019';
#$result='Linux version 5.8.3-fw1 (fst@x86_64.frugalware.org) ( OpenMandriva 11.0.0-0.20200819.1 clang version 11.0.0 (/builddir/build/BUILD/llvm-project-release-11.x/clang 2a0076812cf106fcc34376d9d967dc5f2847693a), LLD 11.0.0)';
#$result='Linux version 5.8.0-18-generic (buildd@lgw01-amd64-057) (gcc (Ubuntu 10.2.0-5ubuntu2) 10.2.0, GNU ld (GNU Binutils for Ubuntu) 2.35) #19-Ubuntu SMP Wed Aug 26 15:26:32 UTC 2020';
# $result='Linux version 5.8.9-fw1 (fst@x86_64.frugalware.org) (gcc (Frugalware Linux) 9.2.1 20200215, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Tue Sep 15 16:38:57 CEST 2020';
# $result='Linux version 5.8.0-2-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.0-9) 10.2.0, GNU ld (GNU Binutils for Debian) 2.35) #1 SMP Debian 5.8.10-1 (2020-09-19)';
if ($result =~ /(gcc|clang).*version\s([\S]+)/){
$version = $2;
$version ||= 'N/A'; # we don't really know what linux clang looks like!
$version ||= 'N/A';
@compiler = ($1,$version);
}
elsif ($result =~ /\((gcc|clang)[^\(]*\([^\)]+\)\s+([0-9\.]+)\s.*,\s*/){
elsif ($result =~ /\((gcc|clang)[^\(]*\([^\)]+\)\s+([0-9\.]+)(\s[^.]*)?,\s*/){
$version = $2;
$version ||= 'N/A'; # we don't really know what linux clang looks like!
$version ||= 'N/A';
@compiler = ($1,$version);
}
}
@ -19178,7 +19204,7 @@ sub get_hostname {
# puppy removed this from core modules, sigh
# this is faster than subshell of hostname
elsif (check_module('Sys::Hostname')){
import Sys::Hostname;
Sys::Hostname->import;
$hostname = Sys::Hostname::hostname();
}
elsif (my $program = check_program('hostname')) {
@ -21087,10 +21113,14 @@ sub lsusb_data {
eval $start if $b_log;
my (@temp);
my @data = data_grabber('lsusb');
foreach (@data){
next if /^\s*$|^Couldn't/; # expensive second call: || /UNAVAIL/
@working = split /\s+/, $_;
$working[3] =~ s/:$//;
# Seen FreeBSD lsusb with:
# Bus /dev/usb Device /dev/ugen0.3: ID 24ae:1003 Shenzhen Rapoo Technology Co., Ltd.
next if !main::is_numeric($working[1]) || !main::is_numeric($working[3]);
$addr_id = int($working[3]);
$bus_id = int($working[1]);
$path_id = "$bus_id-$addr_id";

8
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2020\-08\-17" inxi "inxi manual"
.TH INXI 1 "2020\-09\-29" inxi "inxi manual"
.SH NAME
inxi \- Command line system information script for console and IRC
@ -680,6 +680,9 @@ detected (keyboard, mouse, etc.).
.B \-x \-C\fR
\- Adds bogomips on CPU (if available)
\- Adds \fBboost: [enabled|disabled]\fR if detected, aka \fBturbo\fR. Not all CPUs
have this feature.
\- Adds CPU Flags (short list). Use \fB\-f\fR to see full flag/feature list.
\- Adds CPU microarchitecture + revision (e.g. Sandy Bridge, K8, ARMv8, P6,
@ -976,9 +979,6 @@ data is simply not available as of 2018\-04\-03), location (only available from
.TP
.B \-xxx \-C\fR
\- Adds \fBboost: [enabled|disabled]\fR if detected, aka \fBturbo\fR. Not all CPUs
have this feature.
\- Adds CPU voltage and external clock speed (this is the motherboard speed).
Requires sudo/root and \fBdmidecode\fR.

View file

@ -1,3 +1,55 @@
=====================================================================================
Version: 3.1.07
Patch: 00
Date: 2020-09-29
-----------------------------------
Changes:
-----------------------------------
Bug fixes, feature updates, changes!!
Bugs:
1. There was a glitch in the pattern that made -D samsung / seagate not ID right,
fixed.
2. I do not like calling this a bug, because it's not an inxi bug, it's an upstream
regression in the syntax used in /proc/version, they changed a fully predictable
gcc version .... to a random series of embedded/nested parentheses and other random
junk. inxi tries to deal with this regression, which will be perceived as a bug in
systems running kernel 5.8 or newer and inxi 3.1.06 or older, since it will fail to
show the kernel build compiler version since it can't find it in the string.
I really dislike these types of regressions caused by bad ideas done badly and
without any thought to the transmitted knowledge base, but that's how it goes,
no discipline, I miss the graybeards, who cared about things like this.
Fixes:
1. more -D nvme id changes, intel in this case.
2. FreeBSD lsusb changed syntax, which triggered a series of errors when run.
Since I never really got the required data [hint bsd users, do NOT file issues
that you want fixed and then not provide all the data required, otherwise, really,
why did you file the issue? did you expect magic pixies to fly in with the required
data?] See the README.txt for what to do to get issues really handed in BSDs.
tldr; version: if you won't spend the time providing data and access required,
I won't spend the time on the issue, period, since if you don't care enough to
do those simple steps, why on earth do you expect me to?
Changes:
1. -C 'boost' option changed from -xxx feature to -x feature.
Consider it a promotion!
2. Added --dbg 19 switch to enable smart data debugging for -Da.
3. Some new tools to handle impossible data values for some -D situations for SMART
where the smart report contains gibberish values, that was issue #225 -- tools were
convert_hex and is_Hex. The utility for these is limited, but might be of use in
some cases, like handling the above gibberish data value.
-----------------------------------
-- Harald Hope - Tue, 29 Sep 2020 16:08:05 -0700
=====================================================================================
Version: 3.1.06
Patch: 00