aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-06-14 20:12:03 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-06-14 20:12:03 -0400
commitd2c0e7feffe028c2a3b5a2f2b06728f6a60eb73b (patch)
tree4e0b487266ef4dde4ee10c72e3cecbfdc014402b
parent80fb01314137b4a99eefac4c85adc1888095ec62 (diff)
parentaddd4370e53a593777e005cdd0e11c856006f371 (diff)
downloadinxi-d2c0e7feffe028c2a3b5a2f2b06728f6a60eb73b.tar.bz2
inxi-d2c0e7feffe028c2a3b5a2f2b06728f6a60eb73b.tar.xz
inxi-d2c0e7feffe028c2a3b5a2f2b06728f6a60eb73b.tar.zst
Update upstream source from tag 'upstream/3.3.18-1'
Update to upstream version '3.3.18-1' with Debian dir a1e45e8ce33739329729ea25cb8c8bd4c17cfd99
-rwxr-xr-xinxi8299
-rw-r--r--inxi.1154
-rw-r--r--inxi.changelog351
3 files changed, 5010 insertions, 3794 deletions
diff --git a/inxi b/inxi
index 331a517..a599e30 100755
--- a/inxi
+++ b/inxi
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
## infobash: Copyright (C) 2005-2007 Michiel de Boer aka locsmif
-## inxi: Copyright (C) 2008-2021 Harald Hope
-## Additional features (C) Scott Rogers - kde, cpu info
+## inxi: Copyright (C) 2008-2022 Harald Hope
+## Additional features (C) Scott Rogers - kde, cpu info
## Parse::EDID (C): 2005-2010 by Mandriva SA, Pascal Rigaux, Anssi Hannula
## Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
## Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
@@ -23,7 +23,7 @@ use warnings;
use 5.008;
## Perl 7 things for testing: depend on Perl 5.032
-# use 5.032;
+# use 5.034;
# use compat::perl5; # act like Perl 5's defaults
# no feature qw(indirect);
# no multidimensional;
@@ -48,10 +48,11 @@ use POSIX qw(ceil uname strftime ttyname);
## INXI INFO ##
my $self_name='inxi';
-my $self_version='3.3.16';
-my $self_date='2022-05-19';
+my $self_version='3.3.18';
+my $self_date='2022-06-13';
my $self_patch='00';
## END INXI INFO ##
+
my ($b_pledge,@pledges);
if (eval {require OpenBSD::Pledge}){
OpenBSD::Pledge->import();
@@ -68,15 +69,15 @@ if (eval {require OpenBSD::Pledge}){
}
## Self data
-my ($self_path,$user_config_dir,$user_config_file,$user_data_dir);
+my ($fake_data_dir,$self_path,$user_config_dir,$user_config_file,$user_data_dir);
## Hashes
my (%alerts,%build_prop,%client,%colors,,%cpuinfo_machine,%disks_bsd,
%dboot,%devices,%dl,%dmmapper,%force,%loaded,%mapper,%program_values,%risc,
-%rows,%sensors_raw,%service_tool,%show,%sysctl,%system_files,%usb);
+%service_tool,%show,%sysctl,%system_files,%usb);
## System Arrays
-my (@app,@cpuinfo,@dmi,@gpudata,@ifs,@ifs_bsd,@paths,@ps_aux,@ps_cmd,@ps_gui,
+my (@app,@cpuinfo,@dmi,@ifs,@ifs_bsd,@paths,@ps_aux,@ps_cmd,@ps_gui,
@sensors_exclude,@sensors_use,@uname);
## Disk/Logical/Partition/RAID arrays
@@ -489,6 +490,8 @@ sub set_display_size {
else {
$size{'max-cols'} = $size{'irc'};
}
+ # for -V/-h overrides
+ $size{'max-cols-basic'} = $size{'max-cols'};
# print "tc: $size{'term-cols'} cmc: $size{'console'} cm: $size{'max-cols'}\n";
}
@@ -546,16 +549,20 @@ sub set_path {
my (@path);
# NOTE: recent Xorg's show error if you try /usr/bin/Xorg -version but work
# if you use the /usr/lib/xorg-server/Xorg path.
- @paths = qw(/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin);
+ my @test = qw(/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin
+ /usr/X11R6/bin);
+ foreach (@test){
+ push(@paths,$_) if -d $_;
+ }
@path = split(':', $ENV{'PATH'}) if $ENV{'PATH'};
# print "paths: @paths\nPATH: $ENV{'PATH'}\n";
# Create a difference of $PATH and $extra_paths and add that to $PATH:
foreach my $id (@path){
- if (!(grep { /^$id$/ } @paths) && $id !~ /(game)/){
+ if (-d $id && !(grep {/^$id$/} @paths) && $id !~ /(game)/){
push(@paths, $id);
}
}
- # print "paths: @paths\n";
+ # print "paths: \n", join("\n", @paths),"\n";
}
sub set_sep {
@@ -662,6 +669,7 @@ sub set_user_paths {
# system 'rm', '-Rf', "$ENV{'HOME'}/.$self_name";
# print "WOULD: Moved data dir $ENV{'HOME'}/.$self_name to $user_data_dir\n";
}
+ $fake_data_dir = "$ENV{'HOME'}/bin/scripts/inxi/data";
$log_file="$user_data_dir/$self_name.log";
# system 'echo', "$ENV{'HOME'}/.$self_name/* $user_data_dir";
# print "scd: $user_config_dir sdd: $user_data_dir \n";
@@ -725,9 +733,9 @@ sub set_xorg_log {
## arg: 1 - the type of action, either integer, count, or full
sub get_color_scheme {
- my ($type) = @_;
eval $start if $b_log;
- my @color_schemes = (
+ my ($type) = @_;
+ my $color_schemes = [
[qw(EMPTY EMPTY EMPTY)],
[qw(NORMAL NORMAL NORMAL)],
# for dark OR light backgrounds
@@ -775,17 +783,17 @@ sub get_color_scheme {
[qw(BLACK MAGENTA NORMAL)],
[qw(MAGENTA BLUE NORMAL)],
[qw(MAGENTA DBLUE NORMAL)],
- );
+ ];
eval $end if $b_log;
if ($type eq 'count'){
- return scalar @color_schemes;
+ return scalar @$color_schemes;
}
if ($type eq 'full'){
- return @color_schemes;
+ return $color_schemes;
}
else {
- return @{$color_schemes[$type]};
- # print Dumper $color_schemes[$scheme_nu];
+ # print Dumper $color_schemes->[$type];
+ return $color_schemes->[$type];
}
}
@@ -794,7 +802,6 @@ sub set_color_scheme {
my ($scheme) = @_;
$colors{'scheme'} = $scheme;
my $index = ($b_irc) ? 1 : 0; # defaults to non irc
-
# NOTE: qw(...) kills the escape, it is NOT the same as using
# Literal "..", ".." despite docs saying it is.
my %color_palette = (
@@ -817,10 +824,10 @@ sub set_color_scheme {
'GREY' => [ "\e[0;37m", "\x0315" ],
'NORMAL' => [ "\e[0m", "\x03" ],
);
- my @scheme = get_color_scheme($colors{'scheme'});
- $colors{'c1'} = $color_palette{$scheme[0]}->[$index];
- $colors{'c2'} = $color_palette{$scheme[1]}->[$index];
- $colors{'cn'} = $color_palette{$scheme[2]}->[$index];
+ my $color_scheme = get_color_scheme($colors{'scheme'});
+ $colors{'c1'} = $color_palette{$color_scheme->[0]}[$index];
+ $colors{'c2'} = $color_palette{$color_scheme->[1]}[$index];
+ $colors{'cn'} = $color_palette{$color_scheme->[2]}[$index];
# print Dumper \@scheme;
# print "$colors{'c1'}here$colors{'c2'} we are!$colors{'cn'}\n";
eval $end if $b_log;
@@ -1205,6 +1212,8 @@ sub process_item {
$val = main::set_perl_downloader($val);
%dl = ('dl' => $val, $val => 1);
}}
+ elsif ($key eq 'FAKE_DATA_DIR'){
+ $fake_data_dir = $val}
elsif ($key eq 'FILTER_STRING'){
$filter_string = $val}
elsif ($key eq 'LANGUAGE'){
@@ -2097,6 +2106,7 @@ sub system_data {
['strings','present'],
['sysctl','-a'],
['systemctl','--version'],
+ ['systemctl','get-default'],
['systemctl','list-units'],
['systemctl','list-units --type=target'],
['systemd-detect-virt',''],
@@ -2122,17 +2132,18 @@ sub system_files {
copy_files(\@files, 'repo');
# chdir "/etc";
@files = main::globber('/etc/*[-_]{[rR]elease,[vV]ersion,issue}*');
- push(@files, '/etc/issue');
- push(@files, '/etc/lsb-release');
- push(@files, '/etc/os-release');
- push(@files, '/system/build.prop');# android data file, requires rooted
- push(@files, '/var/log/installer/oem-id'); # ubuntu only for oem installs?
+ push(@files, '/etc/issue','
+ /etc/lsb-release',
+ '/etc/os-release',
+ '/system/build.prop', # android data file, requires rooted
+ '/var/log/installer/oem-id'); # ubuntu only for oem installs?
copy_files(\@files,'system-distro');
@files = main::globber('/etc/upstream[-_]{[rR]elease,[vV]ersion}/*');
copy_files(\@files,'system-distro');
@files = main::globber('/etc/calamares/branding/*/branding.desc');
copy_files(\@files,'system-distro');
@files = (
+ '/etc/systemd/system/default.target',
'/proc/1/comm',
'/proc/cmdline',
'/proc/cpuinfo',
@@ -2168,8 +2179,8 @@ sub run_self {
my $w = ($debugger{'width'}) ? $debugger{'width'} : 120;
my $aiz = "$i$z";
$aiz =~ s/[\s-]//g;
- my $self_file = "$data_dir/$self_name-FERfJLrploudma$aiz-slots-y$w.txt";
- my $cmd = "$self_path/$self_name -FERfJLrploudma$i$z$a --slots --debug 10 -y $w > $self_file 2>&1";
+ my $self_file = "$data_dir/$self_name-FERfJLrploudma$aiz-slots-pkg-edid-gpu-y$w.txt";
+ my $cmd = "$self_path/$self_name -FERfJLrploudma$i$z$a --slots --pkg --edid --gpu --debug 10 -y $w > $self_file 2>&1";
system($cmd);
copy($log_file, "$data_dir") or main::error_handler('copy-failed', "$log_file", "$!");
system("$self_path/$self_name --recommends -y 120 > $data_dir/$self_name-recommends-120.txt 2>&1");
@@ -2784,6 +2795,8 @@ sub error_handler {
$errno=51; "There was an error moving files: $one\nError: $two" }
elsif ($err eq 'write'){
$errno=52; "Failed writing file: $one - Error: $two!" }
+ elsif ($err eq 'dir-missing'){
+ $errno=53; "Directory supplied for option $one does not exist:\n $two" }
## Downloaders
elsif ($err eq 'missing-downloader'){
$errno=60; "Downloader program $two could not be located on your system." }
@@ -2836,43 +2849,34 @@ my (@modules);
sub run {
main::error_handler('not-in-irc', 'recommends') if $b_irc;
my (@data,@rows);
- my $line = make_line();
+ my $rows = [];
+ my $line = main::make_line();
my $pm = get_pm();
- @data = basic_data($line,$pm);
- push(@rows, @data);
+ basic_data($rows,$line,$pm);
if (!$bsd_type){
- @data = check_items('required system directories',$line,$pm);
- push(@rows, @data);
- }
- @data = check_items('recommended system programs',$line,$pm);
- push(@rows, @data);
- @data = check_items('recommended display information programs',$line,$pm);
- push(@rows, @data);
- @data = check_items('recommended downloader programs',$line,$pm);
- push(@rows, @data);
+ check_items($rows,'required system directories',$line,$pm);
+ }
+ check_items($rows,'recommended system programs',$line,$pm);
+ check_items($rows,'recommended display information programs',$line,$pm);
+ check_items($rows,'recommended downloader programs',$line,$pm);
if (!$bsd_type){
- @data = check_items('recommended kernel modules',$line,$pm);
- push(@rows, @data);
- }
- @data = check_items('recommended Perl modules',$line,$pm);
- push(@rows, @data);
- @data = check_items('recommended directories',$line,'');
- push(@rows, @data);
- @data = check_items('recommended files',$line,'');
- push(@rows, @data);
- @data = (
+ check_items($rows,'recommended kernel modules',$line,$pm);
+ }
+ check_items($rows,'recommended Perl modules',$line,$pm);
+ check_items($rows,'recommended directories',$line,'');
+ check_items($rows,'recommended files',$line,'');
+ push(@$rows,
['0', '', '', "$line"],
['0', '', '', "Ok, all done with the checks. Have a nice day."],
['0', '', '', " "],
);
- push(@rows, @data);
- # print Data::Dumper::Dumper \@rows;
- main::print_basic(\@rows);
+ # print Data::Dumper::Dumper $rows;
+ main::print_basic($rows);
exit 0; # shell true
}
sub basic_data {
- my ($line,$pm_local) = @_;
+ my ($rows,$line,$pm_local) = @_;
my (@data,@rows);
my $client = $client{'name-print'};
$pm_local ||= 'N/A';
@@ -2884,7 +2888,7 @@ sub basic_data {
}
my $sh = main::check_program('sh');
my $sh_real = Cwd::abs_path($sh);
- @rows = (
+ push(@$rows,
['0', '', '', "$self_name will now begin checking for the programs it needs
to operate."],
['0', '', '', "" ],
@@ -2899,11 +2903,10 @@ sub basic_data {
['0', '', '', "sh links to: $sh_real" ],
['0', '', '', "Package manager: $pm_local" ],
);
- return @rows;
}
sub check_items {
- my ($type,$line,$pm) = @_;
- my (@data,%info,@missing,$row,@rows,$result,@unreadable);
+ my ($rows,$type,$line,$pm) = @_;
+ my (@data,@missing,$row,$result,@unreadable);
my ($b_dir,$b_file,$b_kernel_module,$b_perl_module,$b_program,$item);
my ($about,$extra,$extra2,$extra3,$extra4,$info_os,$install) = ('','','','','','info','');
if ($type eq 'required system directories'){
@@ -3011,24 +3014,26 @@ sub check_items {
$extra2 = "Note that not all of these are used by every system,
so if one is missing it's usually not a big deal.";
}
- @rows = (
+ push(@$rows,
['0', '', '', "$line" ],
['0', '', '', "Test: $type$extra:" ],
['0', '', '', " " ],
);
if ($extra2){
- $rows[scalar @rows] = ['0', '', '', $extra2];
- $rows[scalar @rows] = ['0', '', '', ' '];
+ push(@$rows,
+ ['0', '', '', $extra2],
+ ['0', '', '', ' ']);
}
if ($extra3){
- $rows[scalar @rows] = ['0', '', '', $extra3];
- $rows[scalar @rows] = ['0', '', '', ' '];
+ push(@$rows,
+ ['0', '', '', $extra3],
+ ['0', '', '', ' ']);
}
foreach my $item (@data){
$install = '';
$about = '';
- %info = item_data($item);
- $about = $info{$info_os};
+ my $info = item_data($item);
+ $about = $info->{$info_os};
if (($b_dir && -d $item) || ($b_file && -r $item) ||
($b_program && main::check_program($item)) ||
($b_perl_module && main::check_perl_module($item)) ||
@@ -3042,36 +3047,35 @@ sub check_items {
else {
$result = 'Missing';
if (($b_program || $b_perl_module) && $pm){
- $info{$pm} ||= 'N/A';
- $install = " ~ Install package: $info{$pm}";
+ $info->{$pm} ||= 'N/A';
+ $install = " ~ Install package: $info->{$pm}";
}
push(@missing, "$item$install");
}
$row = make_row($item,$about,$result);
- $rows[scalar @rows] = ['0', '', '', $row];
+ push(@$rows, ['0', '', '', $row]);
}
- $rows[scalar @rows] = ['0', '', '', " "];
+ push(@$rows, ['0', '', '', " "]);
if (@missing){
- $rows[scalar @rows] = ['0', '', '', "The following $type are missing$extra4:"];
+ push(@$rows, ['0', '', '', "The following $type are missing$extra4:"]);
foreach (@missing){
- $rows[scalar @rows] = ['0', '', '', "$item: $_"];
+ push(@$rows, ['0', '', '', "$item: $_"]);
}
}
if (@unreadable){
- $rows[scalar @rows] = ['0', '', '', "The following $type are not readable: "];
+ push(@$rows, ['0', '', '', "The following $type are not readable: "]);
foreach (@unreadable){
- $rows[scalar @rows] = ['0', '', '', "$item: $_"];
+ push(@$rows, ['0', '', '', "$item: $_"]);
}
}
if (!@missing && !@unreadable){
- $rows[scalar @rows] = ['0', '', '', "All $type are present"];
+ push(@$rows, ['0', '', '', "All $type are present"]);
}
- return @rows;
}
sub item_data {
my ($type) = @_;
- my %data = (
+ my $data = {
# Directory Data
'/sys/class/dmi/id' => {
'info' => '-M system, motherboard, bios',
@@ -3566,8 +3570,8 @@ sub item_data {
'rpm' => 'perl-XML-Dumper',
},
## END PACKAGE MANAGER BLOCK ##
- );
- return %{$data{$type}};
+ };
+ return $data->{$type};
}
sub get_pm {
my ($pm) = ('');
@@ -3594,13 +3598,6 @@ sub make_row {
$line = "$start$sep$middle$dots $end";
return $line;
}
-sub make_line {
- my $line = '';
- foreach (0 .. $size{'max-cols'} - 2){
- $line .= '-';
- }
- return $line;
-}
}
#### -------------------------------------------------------------------
@@ -3718,7 +3715,8 @@ sub get_piece {
# by lines from the command arg
sub grabber {
eval $start if $b_log;
- my ($cmd,$split,$strip) = @_;
+ my ($cmd,$split,$strip,$type) = @_;
+ $type ||= 'arr';
$split ||= "\n";
my @rows;
if ($strip){
@@ -3732,7 +3730,7 @@ sub grabber {
@rows = split(/$split/, qx($cmd));
}
eval $end if $b_log;
- return @rows;
+ return ($type eq 'arr') ? @rows : \@rows;
}
# args: 1 - string value to glob
@@ -3796,10 +3794,13 @@ sub load_json {
$loaded{'json'} = 1;
# recommended, but not in core modules
if (check_perl_module('Cpanel::JSON::XS')){
- Cpanel::JSON::XS->import;
+ Cpanel::JSON::XS->import(qw(encode_json decode_json));
+ # my $new = Cpanel::JSON::XS->new;
$use{'json'} = {'type' => 'cpanel-json-xs',
'encode' => \&Cpanel::JSON::XS::encode_json,
- 'decode' => \&Cpanel::JSON::XS::decode_json};
+ 'decode' => \&Cpanel::JSON::XS::decode_json,};
+ # $use{'json'} = {'type' => 'cpanel-json-xs',
+ # 'new-json' => \Cpanel::JSON::XS->new()};
}
# somewhat legacy, not in perl modules
elsif (check_perl_module('JSON::XS')){
@@ -3937,6 +3938,7 @@ sub set_program_values {
'herbstluftwm' => ['herbstluftwm',2,'--version','herbstluftwm',0,1,0,'',''],
'hikari' => ['^hikari',0,'0','hikari',0,1,0,'',''], # unverified
'hopalong' => ['^hopalong',0,'0','Hopalong',0,1,0,'',''], # unverified
+ 'hyprland' => ['^hyprland',0,'0','Hyprland',0,1,0,'',''], # unverified
'i3' => ['^i3',3,'--version','i3',0,1,0,'',''],
'icewm' => ['^icewm',2,'--version','IceWM',0,1,0,'',''],
'inaban' => ['^inaban',0,'0','inaban',0,1,0,'',''], # unverified
@@ -4086,7 +4088,7 @@ sub set_program_values {
'qmake' => ['^^Using Qt version',4,'--version','Qt',0,0,0,'',''],
'qtdiag' => ['^qt',2,'--version','Qt',0,1,0,'',''],
## Display Managers (dm) ##
- 'brzdm' => ['^brzdm',0,'-v','brzdm',0,1,0,'',''], # unverified, like slim
+ 'brzdm' => ['^brzdm version',3,'-v','brzdm',0,1,0,'',''], # unverified, slim fork
'cdm' => ['^cdm',0,'0','CDM',0,1,0,'',''],
# might be xlogin, unknown output for -V
'clogin' => ['^clogin',0,'-V','clogin',0,1,0,'',''], # unverified, maybe xlogin
@@ -4108,6 +4110,7 @@ sub set_program_values {
'qingy' => ['^qingy',0,'0','qingy',0,1,0,'',''], # unverified
'sddm' => ['^sddm',0,'0','SDDM',0,1,0,'',''],
'slim' => ['slim version',3,'-v','SLiM',0,1,0,'',''],
+ 'slimski' => ['slimski version',3,'-v','slimski',0,1,0,'',''], # slim fork
'tbsm' => ['^tbsm',0,'0','tbsm',0,1,0,'',''], # unverified
'tdm' => ['^tdm',0,'0','TDM',0,1,0,'',''],
'udm' => ['^udm',0,'0','udm',0,1,0,'',''],
@@ -4309,12 +4312,13 @@ sub program_version_pkg {
# arg: 1 - full file path, returns array of file lines.
# 2 - optionsl, strip and clean data
-# 3 - optional, return specific index, if it exists, else undef
+# 3 - optional: undef|arr|ref|index return specific index, if it exists, else undef
# note: chomp has to chomp the entire action, not just <$fh>
sub reader {
eval $start if $b_log;
- my ($file,$strip,$index) = @_;
+ my ($file,$strip,$type) = @_;
return if !$file || ! -r $file; # not all OS respect -r tests!!
+ $type = 'arr' if !defined $type;
my ($error,@rows);
open(my $fh, '<', $file) or $error = $!; # $fh always non null, even on error
if ($error){
@@ -4334,8 +4338,10 @@ sub reader {
}
}
eval $end if $b_log;
+ return @rows if $type eq 'arr';
+ return \@rows if $type eq 'ref';
# note: returns undef scalar value if $rows[index] does not exist
- return (defined $index) ? $rows[$index] : @rows;
+ return $rows[$type];
}
# args: 1 - the file to create if not exists
@@ -4689,6 +4695,12 @@ sub get {
$show{'sensor'} = 1;
$show{'swap'} = 1;
$show{'system'} = 1;},
+ 'gpu|nvidia|nv' => sub {
+ $b_admin = 1;
+ $show{'short'} = 0;
+ $show{'gpu-data'} = 1;
+ $show{'graphic'} = 1;
+ $show{'graphic-full'} = 1;},
'G|graphics|graphic' => sub {
$show{'short'} = 0;
$show{'graphic'} = 1;
@@ -4745,12 +4757,6 @@ sub get {
'N|network' => sub {
$show{'short'} = 0;
$show{'network'} = 1;},
- 'nvidia|nv|non-free' => sub {
- $b_admin = 1;
- $show{'short'} = 0;
- $show{'nvidia'} = 1;
- $show{'graphic'} = 1;
- $show{'graphic-full'} = 1;},
'o|unmounted' => sub {
$show{'short'} = 0;
$show{'unmounted'} = 1;},
@@ -4879,7 +4885,7 @@ sub get {
$b_admin = 1;
# $use{'downloader'} = 1; # only if weather
$show{'edid'} = 1;
- $show{'nvidia'} = 1;
+ $show{'gpu-data'} = 1;
$show{'process'} = 1;
$show{'ps-cpu'} = 1;
$show{'ps-mem'} = 1;
@@ -4892,7 +4898,9 @@ sub get {
main::error_handler('bad-arg',$opt,$arg);
}},
'V|version' => sub {
- $show{'version'} = 1 },
+ $show{'version'} = 1;},
+ 'version-short|vs' => sub {
+ $show{'version-short'} = 1;},
'w|weather' => sub {
my ($opt) = @_;
$show{'short'} = 0;
@@ -4962,6 +4970,7 @@ sub get {
$arg = 80;
}
if ($arg =~ /\d/ && ($arg == 1 || $arg >= 80)){
+ $size{'max-cols-basic'} = $arg if $arg != 1;
$size{'max-cols'} = $arg;
}
else {
@@ -5169,6 +5178,14 @@ sub get {
else {
main::error_handler('bad-arg', $opt, $arg);
}},
+ 'fake-data-dir:s' => sub {
+ my ($opt,$arg) = @_;
+ if ($arg && -d $arg){
+ $fake_data_dir = $arg;
+ }
+ else {
+ main::error_handler('dir-not-exist', $opt, $arg);
+ }},
'force:s' => sub {
my ($opt,$arg) = @_;
if ($arg){
@@ -5234,14 +5251,6 @@ sub get {
undef %risc;
$risc{'id'} = 'mips';
$risc{'mips'} = 1;},
- 'output:s' => sub {
- my ($opt,$arg) = @_;
- if ($arg =~ /^(json|screen|xml)$/){
- $output_type = $arg;
- }
- else {
- main::error_handler('bad-arg', $opt, $arg);
- }},
'no-dig' => sub {
$force{'no-dig'} = 1;},
'no-doas' => sub {
@@ -5257,6 +5266,14 @@ sub get {
$use{'no-ssl'} = 1;},
'no-sudo' => sub {
$force{'no-sudo'} = 1;},
+ 'output:s' => sub {
+ my ($opt,$arg) = @_;
+ if ($arg =~ /^(json|screen|xml)$/){
+ $output_type = $arg;
+ }
+ else {
+ main::error_handler('bad-arg', $opt, $arg);
+ }},
'output-file:s' => sub {
my ($opt,$arg) = @_;
if ($arg){
@@ -5306,7 +5323,7 @@ sub get {
$risc{'sparc'} = 1;},
'sys-debug' => sub {
$debugger{'sys-force'} = 1;},
- 'tty' => sub { # workaround for ansible running this
+ 'tty' => sub { # workaround for ansible/scripts running this
$b_irc = 0;},
'U|update:s' => sub { # 1,2,3 OR http://myserver/path/inxi
my ($opt,$arg) = @_;
@@ -5344,7 +5361,9 @@ sub post_process {
main::set_downloader();
}
main::set_xorg_log() if $show{'graphic'};
- main::show_version() if $show{'version'};
+ if ($show{'version'} || $show{'version-short'}){
+ main::show_version();
+ }
main::show_options() if $show{'help'};
$use{'man'} = 0 if (!$use{'yes-man'} || $use{'no-man'});
main::update_me($self_download, $download_id) if $use{'update-trigger'};
@@ -5500,8 +5519,8 @@ sub process_updater {
sub show_options {
error_handler('not-in-irc', 'help') if $b_irc;
- my (@data);
- my $line = '';
+ my $rows = [];
+ my $line = make_line();
my $color_scheme_count = get_color_scheme('count') - 1;
my $partition_string='partition';
my $partition_string_u='Partition';
@@ -5511,10 +5530,7 @@ sub show_options {
$partition_string_u='Slice';
}
# fit the line to the screen!
- for my $i (0 .. (($size{'max-cols'} / 2) - 2)){
- $line = $line . '- ';
- }
- push(@data,
+ push(@$rows,
['0', '', '', "$self_name supports the following options. For more detailed
information, see man^$self_name. If you start $self_name with no arguments,
it will display a short system summary."],
@@ -5555,6 +5571,8 @@ sub show_options {
['1', '-F', '--full', "Full output. Includes all Upper Case line letters
(except -J, -W) plus --swap, -s and -n. Does not show extra verbose options
such as -d -f -i -J -l -m -o -p -r -t -u -x, unless specified."],
+ ['1', '', '--gpu', "Show advanced gpu info (arch:, nvidia non-free driver
+ status). Triggers -Ga."],
['1', '-G', '--graphics', "Graphics info (devices(s), drivers, display
protocol (if available), display server/Wayland compositor, resolution, X.org:
renderer, OpenGL version; Xvesa: VBE info."],
@@ -5584,7 +5602,6 @@ sub show_options {
['1', '-n', '--network-advanced', "Advanced Network device info. Triggers -N.
Shows interface, speed, MAC id, state, etc. "],
['1', '-N', '--network', "Network device(s), driver."],
- ['1', '', '--nvidia,--nv', "Show advanced nvidia device info. Triggers -Ga."],
['1', '-o', '--unmounted', "Unmounted $partition_string info (includes UUID
and Label if available). Shows file system type if you have lsblk installed
(Linux) or, for BSD/GNU Linux, if 'file' installed and you are root or if
@@ -5603,8 +5620,8 @@ sub show_options {
sizes, and components. md-raid: If device is resyncing, also shows resync
progress line."],
['1', '-s', '--sensors', "Sensors output (if sensors installed/configured):
- mobo/CPU/GPU temp; detected fan speeds. GPU temp only for Fglrx/Nvidia drivers.
- Nvidia shows screen number for > 1 screen. IPMI sensors if present."],
+ mobo/CPU/GPU temp; detected fan speeds. Nvidia shows screen number for > 1
+ screen. IPMI sensors if present."],
['1', '', '--slots', "PCI slots: type, speed, status. Requires root."],
['1', '-S', '--system', "System info: host name, kernel, desktop environment
(if in X/Wayland), distro."],
@@ -5633,13 +5650,13 @@ sub show_options {
full RAID; triggers -xx."],
['2', '7', '', "Network IP data (-i), bluetooth, logical (-L),
RAID forced, full CPU $flags; triggers -xxx."],
- ['2', '8', '', "Everything available, including Nvidia non-free (--nvidia),
+ ['2', '8', '', "Everything available, including advanced gpu data (--gpu),
EDID (--edid), repos (-r), processes (-tcm), PCI slots (--slots); triggers
admin (-a)."],
);
# if distro maintainers don't want the weather feature disable it
if ($use{'weather'}){
- push(@data,
+ push(@$rows,
['1', '-w', '--weather', "Local weather data/time. To check an alternate
location, see -W. NO AUTOMATED QUERIES OR EXCESSIVE USE ALLOWED!"],
['1', '-W', '--weather-location', "[location] Supported options for
@@ -5654,7 +5671,7 @@ sub show_options {
metric/imperial (mi), or imperial/metric (im)."],
);
}
- push(@data,
+ push(@$rows,
[0, '', '', "$line"],
['0', '', '', "Filter Options:"],
['1', '', '--host', "Turn on hostname for -S. Overrides -z."],
@@ -5715,19 +5732,19 @@ sub show_options {
also sets --extra=3:"],
['2', '-A', '', "If available: list of alternate kernel modules/drivers
for device(s); PCIe lanes-max: gen, speed, lanes (if relevant)."],
- ['2', '-C', '', "If available: CPU socket type, base/boost speeds
- (dmidecode+root/sudo/doas required); Full topology line, with cores, threads,
- threads per core, granular cache data, smt status; CPU vulnerabilities (bugs);
- family, model-id, stepping - format: hex (decimal) if greater than 9;
- microcode format: hex."],
+ ['2', '-C', '', "If available: CPU generation, process node, built years; CPU
+ socket type, base/boost speeds (dmidecode+root/sudo/doas required); Full
+ topology line, with cores, threads, threads per core, granular cache data,
+ smt status; CPU vulnerabilities (bugs); family, model-id, stepping - format:
+ hex (decimal) if greater than 9; microcode format: hex."],
['2', '-d,-D', '', "If available: logical and physical block sizes; drive
family; maj:min, USB drive specifics; SMART report."],
['2', '-E', '', "If available: in Report:, adds Info: line: acl-mtu,
sco-mtu, link-policy, link-mode, service-classes."],
- ['2', '-G', '', "Shows non-free driver info (Nvidia and Linux only); PCIe
- lanes-max: gen, speed, lanes (if relevant); list of alternate kernel
- modules/drivers for device(s) (if available); Monitor built year, gamma,
- screen ratio (if available)."],
+ ['2', '-G', '', "GPU process node, built year (AMD/Intel/Nvidia only);
+ non-free driver info (Nvidia only); PCIe lanes-max: gen, speed, lanes (if
+ relevant); list of alternate kernel modules/drivers for device(s) (if
+ available); Monitor built year, gamma, screen ratio (if available)."],
['2', '-I', '', "As well as per package manager counts, also adds total
number of lib files found for each package manager if not -r; adds init
service tool."],
@@ -5768,14 +5785,14 @@ sub show_options {
Example:^<username>^ALL^=^NOPASSWD:^/usr/sbin/hddtemp"],
['2', '-E', '', "PCI/USB Bus ID of device, driver version,
LMP version."],
- ['2', '-G', '', "GPU arch (Nvidia only); Specific vendor/product information
- (if relevant); PCI/USB ID of device; Direct rendering status (in X); Screen
- number GPU is running on (Nvidia only)."],
+ ['2', '-G', '', "GPU arch (AMD/Intel/Nvidia only); Specific vendor/product
+ information (if relevant); PCI/USB ID of device; Direct rendering status
+ (in X); Screen number GPU is running on (Nvidia only)."],
['2', '-i', '', "For IPv6, show additional scope addresses: Global, Site,
Temporary, Unknown. See --limit for large counts of IP addresses."],
['2', '-I', '', "Default system GCC. With -xx, also shows other installed
GCC versions. If running in shell, not in IRC client, shows shell version
- number, if detected. Init/RC type and runlevel (if available). Total
+ number, if detected. Init/RC type and runlevel/target (if available). Total
count of all packages discovered in system and not -r."],
['2', '-j', '', "Add mapped: name if partition mapped."],
['2', '-J', '', "For Device: driver."],
@@ -5797,11 +5814,11 @@ sub show_options {
memory (-xt m)."],
);
if ($use{'weather'}){
- push(@data,
+ push(@$rows,
['2', '-w,-W', '', "Wind speed and direction, humidity, pressure,
and time zone, if available."]);
}
- push(@data,
+ push(@$rows,
['0', '', '', ''],
['1', '-xx', '--extra 2', "Show extra, extra data (only works with verbose
or line output, not short form):"],
@@ -5813,15 +5830,15 @@ sub show_options {
['2', '-E', '', "Chip vendor:product ID, LMP subversion; PCIe speed, lanes
(if found)."],
['2', '-G', '', "Chip vendor:product ID for each video device; Output ports,
- used and empty; PCIe speed, lanes (if found); Xorg:
- OpenGL compatibility version, if free drivers and available; Xorg compositor;
+ used and empty; PCIe speed, lanes (if found); Xorg: OpenGL compatibility
+ version, if free drivers and available; Xorg compositor;
alternate Xorg drivers (if available. Alternate means driver is on automatic
driver check list of Xorg for the device vendor, but is not installed on
system); Xorg Screen data: ID, s-res, dpi; Monitors: ID, position (if > 1),
resolution, dpi, model, diagonal."],
['2', '-I', '', "Other detected installed gcc versions (if present). System
- default runlevel. Adds parent program (or pty/tty) for shell info if not in
- IRC. Adds Init version number, RC (if found). Adds per package manager
+ default target/runlevel. Adds parent program (or pty/tty) for shell info if
+ not in IRC. Adds Init version number, RC (if found). Adds per package manager
installed package counts if not -r."],
['2', '-j,-p,-P', '', "Swap priority."],
['2', '-J', '', "Vendor:chip-ID."],
@@ -5843,12 +5860,12 @@ sub show_options {
['2', '--slots', '', "Slot length; slot voltage, if available."],
);
if ($use{'weather'}){
- push(@data,
+ push(@$rows,
['2', '-w,-W', '', "Snow, rain, precipitation, (last observed hour),
cloud cover, wind chill, dew point, heat index, if available."]
);
}
- push(@data,
+ push(@$rows,
['0', '', '', ''],
['1', '-xxx', '--extra 3', "Show extra, extra, extra data (only works
with verbose or line output, not short form):"],
@@ -5878,12 +5895,12 @@ sub show_options {
manager version number, virtual terminal number."],
);
if ($use{'weather'}){
- push(@data,
+ push(@$rows,
['2', '-w,-W', '', "Location (uses -z/irc filter), weather observation
time, altitude, sunrise/sunset, if available."]
);
}
- push(@data,
+ push(@$rows,
[0, '', '', "$line"],
[0, '', '', "Additional Options:"],
['1', '-h', '--help', "This help menu."],
@@ -5892,7 +5909,7 @@ sub show_options {
to add support for that feature."],
);
if ($use{'update'}){
- push(@data,
+ push(@$rows,
['1', '-U', '--update', "Auto-update $self_name. Will also install/update
man page. Note: if you installed as root, you must be root to update,
otherwise user is fine. Man page installs require root. No arguments
@@ -5905,8 +5922,10 @@ sub show_options {
Use the full download path, e.g.^$self_name^-U^https://myserver.com/inxi"],
);
}
- push(@data,
- ['1', '-V', '--version', "Prints $self_name version info then exits."],
+ push(@$rows,
+ ['1', '-V', '--version', "Prints full $self_name version info then exits."],
+ ['1', '', '--version-short,--vs', "Prints 1 line $self_name version info. Can
+ be used with other line options."],
['0', '', '', "$line"],
['0', '', '', "Advanced Options:"],
['1', '', '--alt', "Trigger for various advanced options:"],
@@ -5934,12 +5953,12 @@ sub show_options {
default)."],
);
if ($use{'update'}){
- push(@data,
+ push(@$rows,
['1', '', '--man', "Install correct man version for dev branch (-U 3) or
pinxi using -U."],
);
}
- push(@data,
+ push(@$rows,
['1', '', '--no-dig', "Skip dig for WAN IP checks, use downloader program."],
['1', '', '--no-doas', "Skip internal program use of doas features (not
related to starting $self_name with doas)."],
@@ -5947,11 +5966,11 @@ sub show_options {
only, or nothing if --no-dig."],
);
if ($use{'update'}){
- push(@data,
+ push(@$rows,
['1', '', '--no-man', "Disable man install for all -U update actions."],
);
}
- push(@data,
+ push(@$rows,
['1', '', '--no-ssl', "Skip SSL certificate checks for all downloader actions
(Wget/Fetch/Curl/Perl-HTTP::Tiny)."],
['1', '', '--no-sudo', "Skip internal program use of sudo features (not
@@ -6017,14 +6036,15 @@ sub show_options {
to. Example:^$self_name^--debug^21^--ftp^ftp.myserver.com/incoming"],
['0', '', '', "$line"],
);
- print_basic(\@data);
+ print_basic($rows);
exit 0; # shell true
}
sub show_version {
# if not in PATH could be either . or directory name, no slash starting
my $working_path=$self_path;
- my (@data,$link,$self_string);
+ my ($link,$self_string);
+ my $rows = [];
Cwd->import('getcwd'); # no point loading this on top use, we only use getcwd here
if ($working_path eq '.'){
$working_path = getcwd();
@@ -6043,20 +6063,20 @@ sub show_version {
}
# strange output /./ ending, but just trim it off, I don't know how it happens
$working_path =~ s%/\./%/%;
- push(@data, [ 0, '', '', "$self_name $self_version-$self_patch ($self_date)"]);
- if (!$b_irc){
- push(@data, [ 0, '', '', '']);
+ push(@$rows, [ 0, '', '', "$self_name $self_version-$self_patch ($self_date)"]);
+ if (!$b_irc && !$show{'version-short'}){
+ push(@$rows, [ 0, '', '', '']);
my $year = (split/-/, $self_date)[0];
- push(@data,
+ push(@$rows,
[ 0, '', '', "Copyright^(C)^2008-$year^Harald^Hope^aka^h2"],
[ 0, '', '', "Forked from Infobash 3.02: Copyright^(C)^2005-2007^Michiel^de^Boer^aka^locsmif." ],
[ 0, '', '', "Using Perl version: $]"],
[ 0, '', '', "Program Location: $working_path" ],
);
if ($link){
- push(@data, [ 0, '', '', "Started via symbolic link: $link" ]);
+ push(@$rows, [ 0, '', '', "Started via symbolic link: $link" ]);
}
- push(@data,
+ push(@$rows,
[ 0, '', '', '' ],
[ 0, '', '', "Website:^https://github.com/smxi/inxi^or^https://smxi.org/" ],
[ 0, '', '', "IRC:^irc.oftc.net channel:^#smxi" ],
@@ -6068,8 +6088,8 @@ sub show_version {
(https://www.gnu.org/licenses/gpl.html)" ]
);
}
- print_basic(\@data);
- exit 0; # shell true
+ print_basic($rows);
+ exit 0 if !$show{'version-short'} || $show{'short'}; # shell true
}
########################################################################
@@ -6227,7 +6247,7 @@ sub get_client_version {
}
# then do some perl type searches, do this last since it's a wildcard search
elsif ($client{'name'} =~ /^(perl.*|ksirc|dsirc)$/){
- my @cmdline = main::get_cmdline();
+ my $cmdline = main::get_cmdline();
# Dynamic runpath detection is too complex with KSirc, because KSirc is started from
# kdeinit. /proc/<pid of the grandparent of this process>/exe is a link to /usr/bin/kdeinit
# with one parameter which contains parameters separated by spaces(??), first param being KSirc.
@@ -6236,7 +6256,7 @@ sub get_client_version {
# You can imagine how hosed I am if I try to make inxi find out dynamically with which path
# KSirc was run by browsing up the process tree in /proc. That alone is straightjacket material.
# (KSirc sucks anyway ;)
- foreach (@cmdline){
+ foreach (@$cmdline){
if ($_ =~ /dsirc/){
$client{'version'} = main::program_version('ksirc','KSirc:',2,'-v',0,0);
$client{'name'} = 'ksirc';
@@ -6257,7 +6277,7 @@ sub get_client_version {
$wl_terms .= 'login|macwise|minicom|putty|rxvt|sakura|securecrt|';
$wl_terms .= 'shellinabox|^st$|sudo|term|tilda|tilix|tmux|tym|wayst|xiki|';
$wl_terms .= 'yaft|yakuake|\bzoc\b';
- my $wl_clients = 'ansible|chef|run-parts|sshd';
+ my $wl_clients = 'ansible|chef|run-parts|slurm|sshd';
my $whitelist = "$wl_terms|$wl_clients";
# print "$client{'name'}\n";
if ($client{'name'} =~ /($whitelist)/i){
@@ -6299,7 +6319,7 @@ sub get_cmdline {
}
main::log_data('string',"cmdline: @cmdline count: $i") if $b_log;
eval $end if $b_log;
- return @cmdline;
+ return [@cmdline];
}
sub perl_python_client {
eval $start if $b_log;
@@ -6664,10 +6684,18 @@ sub increment_starters {
return $result;
}
+sub make_line {
+ my $line = '';
+ foreach (0 .. $size{'max-cols-basic'} - 2){
+ $line .= '-';
+ }
+ return $line;
+}
+
sub message {
my ($type,$id) = @_;
$id ||= '';
- my %unfound = (
+ my %message = (
'arm-cpu-f' => 'Use -f option to see features',
'battery-data' => 'No system battery data found. Is one present?',
'battery-data-bsd' => 'No battery data found. Try with --dmidecode',
@@ -6680,6 +6708,7 @@ sub message {
'cpu-speeds-bsd' => 'No OS support for core speeds.',
'darwin-feature' => 'Feature not supported iu Darwin/OSX.',
'dev' => 'Feature under development',
+ 'device-data' => 'No device data found.',
'disk-data' => 'No disk data found.',
'disk-data-bsd' => 'No disk data found.',
'disk-size-0' => 'Total N/A',
@@ -6717,10 +6746,9 @@ sub message {
'note-check' => 'check',
'note-est' => 'est.',
'nv-current' => "current (as of $id)",
- 'nv-legacy-active' => "legacy-active (EOL $id)",
+ 'nv-legacy-active' => "legacy-active (EOL~$id)",
'nv-legacy-eol' => 'legacy (EOL)',
- 'nv-legacy-eol-try' => 'legacy (EOL, try --nv)',
- 'nv-unknown' => 'unknown device ID',
+ 'nv-legacy-eol-try' => 'legacy (EOL, try --gpu)',
'optical-data' => 'No optical or floppy data found.',
'optical-data-bsd' => 'No optical or floppy data found.',
'output-control' => "-:: 'Enter' to continue to next block. Any key + 'Enter' to exit:",
@@ -6729,9 +6757,9 @@ sub message {
'package-data' => 'No packages detected. Unsupported package manager?',
'partition-data' => 'No partition data found.',
'partition-hidden' => 'N/A (hidden?)',
- 'pci-advanced-data' => 'bus/chip ids unavailable',
- 'pci-card-data' => 'No device data found.',
- 'pci-card-data-root' => 'Device data requires root.',
+ 'pci-advanced-data' => 'bus/chip ids n/a',
+ 'pci-card-data' => 'No PCI device data found.',
+ 'pci-card-data-root' => 'PCI device data requires root.',
'pci-slot-data' => 'No PCI Slot data found.',
'pm-disabled' => 'see --pkg',
'ps-data-null' => 'No process data available.',
@@ -6780,12 +6808,13 @@ sub message {
'unknown-cpu-topology' => 'ERR-103',
'unknown-desktop-version' => 'ERR-101',
'unknown-dev' => 'ERR-102',
+ 'unknown-device-id' => 'unknown device ID',
'unknown-shell' => 'ERR-100',
'weather-error' => "Error: $id",
'weather-null' => "No $id found. Internet connection working?",
'xvesa-interface' => 'No Xvesa VBE/GOP data found.',
);
- return $unfound{$type};
+ return $message{$type};
}
# string of range types (2-5; 3 4; 3,4,2-12) to generate single regex string for
@@ -6893,7 +6922,12 @@ sub generate_json {
error_handler('not-in-irc', 'help') if $b_irc;
print Dumper $data if $b_debug;
load_json() if !$loaded{'json'};
+ print Data::Dumper::Dumper $use{'json'} if $b_debug;
if ($use{'json'}){
+ # ${$use{'json'}->{'new'}}->canonical(1);
+ # $json = ${$use{'json'}->{'new'}}->json_encode($data);
+ # ${$use{'json'}->{'new-json'}}->canonical(1);
+ # $json = ${$use{'json'}->{'new-json'}}->encode_json($data);
$json = &{$use{'json'}->{'encode'}}($data);
}
else {
@@ -6973,10 +7007,11 @@ sub print_basic {
my $indent2 = 8;
my $length = @$data;
my ($start,$i,$j,$line);
- if ($size{'max-cols'} > 110){
+ my $width = $size{'max-cols-basic'};
+ if ($width > 110){
$indent_static = 22;
}
- elsif ($size{'max-cols'} < 90){
+ elsif ($width < 90){
$indent_static = 15;
}
# print $length . "\n";
@@ -7009,7 +7044,7 @@ sub print_basic {
$start = '';
# print "1-print.\n";
}
- if (($indent + length($data->[$i][3])) < $size{'max-cols'}){
+ if (($indent + length($data->[$i][3])) < $width){
$data->[$i][3] =~ s/\^/ /g;
$line = sprintf("%-${indent}s%s\n", "$start", $data->[$i][3]);
print_line($line);
@@ -7022,12 +7057,12 @@ sub print_basic {
# then splits like awk, on one or more white spaces.
foreach my $word (split(' ', $data->[$i][3])){
# print "$word\n";
- if (($indent + length($holder) + length($word)) < $size{'max-cols'}){
+ if (($indent + length($holder) + length($word)) < $width){
$word =~ s/\^/ /g;
$holder .= $word . $sep;
# print "3-hold.\n";
}
- # elsif (($indent + length($holder) + length($word)) >= $size{'max-cols'}){
+ # elsif (($indent + length($holder) + length($word)) >= $width){
else {
$line = sprintf("%-${indent}s%s\n", "$start", $holder);
print_line($line);
@@ -7109,15 +7144,15 @@ sub print_data {
foreach my $val1 (@{$data->{$key1}}){
if (ref($val1) eq 'HASH'){
if (!$b_single){
- $indent_use = $length = ($b_row1) ? $indent : $indent_2;
+ $indent_use = $length = ($b_row1 && $key !~ /^(Features)$/) ? $indent : $indent_2;
}
($counter,$b_row1,$split_count) = (0,1,0);
foreach my $key2 (sort {substr($a,0,3) <=> substr($b,0,3)} keys %$val1){
+ ($hash_id,$b_container,$indentx,$key) = (split('#', $key2));
if (!$b_single){
$indent_use = ($b_row1 || $b_ni2) ? $indent: $indent_2;
}
# print "m-1: r1: $b_row1 iu: $indent_use\n";
- ($hash_id,$b_container,$indentx,$key) = (split('#', $key2));
if ($start_holder eq 'Graphics' && $key eq 'Screen'){
$ids{'Monitor'} = 1;
}
@@ -7340,45 +7375,44 @@ package AudioItem;
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
if (%risc && !$use{'soc-audio'} && !$use{'pci-tool'}){
my $key = 'Message';
- push(@rows,{
- main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'}),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'})
+ });
}
else {
- push(@rows,device_output());
+ device_output($rows);
}
- if (((%risc && !$use{'soc-audio'} && !$use{'pci-tool'}) || !@rows) &&
+ if (((%risc && !$use{'soc-audio'} && !$use{'pci-tool'}) || !@$rows) &&
(my $file = $system_files{'asound-cards'})){
- push(@rows,asound_output($file));
+ asound_output($rows,$file);
}
- push(@rows,usb_output());
- if (!@rows){
+ usb_output($rows);
+ # note: for servers often no audio, so we don't care about pci specific
+ if (!@$rows){
my $key = 'Message';
- my $type = 'pci-card-data';
+ my $type = 'device-data';
if ($pci_tool && $alerts{$pci_tool}->{'action'} eq 'permissions'){
$type = 'pci-card-data-root';
}
- push(@rows,{
- main::key($num++,0,1,$key) => main::message($type,''),
- },);
+ @$rows = ({main::key($num++,0,1,$key) => main::message($type,'')});
}
- push(@rows,sound_server_output());
+ sound_server_output($rows);
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub device_output {
eval $start if $b_log;
return if !$devices{'audio'};
- my (@rows);
+ my $rows = $_[0];
my ($j,$num) = (0,1);
foreach my $row (@{$devices{'audio'}}){
$num = 1;
- $j = scalar @rows;
+ $j = scalar @$rows;
my $driver = $row->[9];
$driver ||= 'N/A';
my $device = $row->[4];
@@ -7387,52 +7421,50 @@ sub device_output {
if (length($device) > 85 || $size{'max-cols'} < 110){
$device = main::filter_pci_long($device);
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $device,
- },);
+ });
if ($extra > 0 && $use{'pci-tool'} && $row->[12]){
my $item = main::get_pci_vendor($row->[4],$row->[12]);
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $item if $item;
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $item if $item;
}
- $rows[$j]->{main::key($num++,1,2,'driver')} = $driver;
+ $rows->[$j]{main::key($num++,1,2,'driver')} = $driver;
if ($extra > 0 && !$bsd_type){
if ($row->[9]){
my $version = main::get_module_version($row->[9]);
- $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version if $version;
}
}
if ($b_admin && $row->[10]){
$row->[10] = main::get_driver_modules($row->[9],$row->[10]);
- $rows[$j]->{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
+ $rows->[$j]{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
}
if ($extra > 0){
my $bus_id = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]";
if ($extra > 1 && $bus_id ne 'N/A'){
- main::get_pcie_data($bus_id,$j,\@rows,\$num);
+ main::get_pcie_data($bus_id,$j,$rows,\$num);
}
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
my $chip_id = main::get_chip_id($row->[5],$row->[6]);
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $chip_id;
if ($extra > 2 && $row->[1]){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = $row->[1];
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = $row->[1];
}
}
# print "$row->[0]\n";
}
eval $end if $b_log;
- return @rows;
}
# this handles fringe cases where there is no card on pcibus,
# but there is a card present. I don't know the exact architecture
# involved but I know this situation exists on at least one old machine.
sub asound_output {
eval $start if $b_log;
- my ($file) = @_;
- my (@asound,@rows);
+ my ($file,$rows) = @_;
my ($device,$driver,$j,$num) = ('','',0,1);
- @asound = main::reader($file);
+ my @asound = main::reader($file);
foreach (@asound){
# filtering out modems and usb devices like webcams, this might get a
# usb audio card as well, this will take some trial and error
@@ -7444,27 +7476,27 @@ sub asound_output {
$device = $2;
$driver = $1;
if ($device){
- $j = scalar @rows;
+ $j = scalar @$rows;
$driver ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $device,
main::key($num++,1,2,'driver') => $driver,
- },);
+ });
if ($extra > 0){
my $version = main::get_module_version($driver);
- $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version;
- $rows[$j]->{main::key($num++,0,2,'message')} = main::message('pci-advanced-data','');
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version if $version;
+ $rows->[$j]{main::key($num++,0,2,'message')} = main::message('pci-advanced-data','');
}
}
}
}
- # print Data::Dumper:Dumper \s@rows;
+ # print Data::Dumper:Dumper $rows;
eval $end if $b_log;
- return @rows;
}
sub usb_output {
eval $start if $b_log;
- my (@rows,@ids,$path_id,$product,@temp2);
+ my $rows = $_[0];
+ my (@ids,$path_id,$product,@temp2);
my ($j,$num) = (0,1);
return if !$usb{'audio'};
foreach my $row (@{$usb{'audio'}}){
@@ -7476,51 +7508,50 @@ sub usb_output {
$path_id = $row->[2] if $row->[2];
$product ||= 'N/A';
$row->[15] ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $product,
main::key($num++,0,2,'type') => 'USB',
main::key($num++,0,2,'driver') => $row->[15],
- },);
+ });
if ($extra > 0){
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
}
if ($extra > 1){
$row->[7] ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $row->[7];
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $row->[7];
}
if ($extra > 2 && defined $row->[5] && $row->[5] ne ''){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
}
if ($extra > 2 && $row->[16]){
- $rows[$j]->{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
+ $rows->[$j]{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
}
- $j = scalar @rows;
+ $j = scalar @$rows;
}
eval $end if $b_log;
- return @rows;
}
sub sound_server_output {
eval $start if $b_log;
- my (@rows,$program);
+ my $rows = $_[0];
+ my ($program);
my ($j,$num) = (0,0);
- my @servers = sound_server_data();
- foreach my $server (@servers){
+ foreach my $server (@{sound_server_data()}){
next if $extra < 1 && (!$server->[2] || $server->[2] ne 'yes');
- $j = scalar @rows;
+ $j = scalar @$rows;
$server->[1] ||= 'N/A';
$server->[2] ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Sound Server') => $server->[0],
main::key($num++,0,2,'v') => $server->[1],
main::key($num++,0,2,'running') => $server->[2],
});
}
eval $end if $b_log;
- return @rows;
}
sub sound_server_data {
eval $start if $b_log;
- my (@servers,$program,$running,$server,$version);
+ my ($program,$running,$server,$version);
+ my $servers = [];
if (my $file = $system_files{'asound-version'}){
# avoid possible second line if compiled by user
my $content = main::reader($file,'',0);
@@ -7534,7 +7565,7 @@ sub sound_server_data {
# if (main::check_program('aplay') && main::grabber('aplay -l 2>/dev/null')){
# $running = 'yes';
# }
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
# sndstat file may be removed in linux oss
@@ -7546,21 +7577,21 @@ sub sound_server_data {
$version =~ s|/.*$|| if $version;
# not a great test, but ok for now
$running = (-e '/dev/sndstat') ? 'yes' : 'no?';
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
if ($program = main::check_program('sndiod')){
$server = 'sndio';
#$version = main::program_version('sndio','\S',2);
$running = (grep {/sndiod/} @ps_cmd) ? 'yes': 'no';
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
if ($program = main::check_program('jackd')){
$server = 'JACK';
$version = main::program_version($program,'^jackd',3,'--version',1);
$running = (grep {/jackd/} @ps_cmd) ? 'yes':'no' ;
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
# note: pactl info/list/stat could be used
@@ -7568,20 +7599,20 @@ sub sound_server_data {
$server = 'PulseAudio';
$version = main::program_version($program,'^pactl',2,'--version',1);
$running = (grep {m|/pulseaudiod?\b|} @ps_cmd) ? 'yes':'no' ;
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
if ($program = main::check_program('pipewire')){
$server = 'PipeWire';
$version = main::program_version($program,'^Compiled with libpipe',4,'--version',1);
$running = (grep {/pipewire/} @ps_cmd) ? 'yes':'no' ;
- push(@servers, [$server,$version,$running]);
+ push(@$servers, [$server,$version,$running]);
($running,$server,$version) = ('','','');
}
- main::log_data('dump','sound servers: @servers',\@servers) if $b_log;
- print Data::Dumper::Dumper \@servers if $dbg[26];
- return @servers;
+ main::log_data('dump','sound servers: @$servers',$servers) if $b_log;
+ print Data::Dumper::Dumper $servers if $dbg[26];
eval $end if $b_log;
+ return $servers;
}
}
@@ -7592,65 +7623,67 @@ package BatteryItem;
my (@upower_items,$b_upower,$upower);
sub get {
eval $start if $b_log;
- my (@rows,%battery,$key1,$val1);
+ my ($key1,$val1);
+ my $battery = {};
+ my $rows = [];
my $num = 0;
if ($force{'dmidecode'}){
if ($alerts{'dmidecode'}->{'action'} ne 'use'){
$key1 = $alerts{'dmidecode'}->{'action'};
$val1 = $alerts{'dmidecode'}->{'message'};
$key1 = ucfirst($key1);
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
else {
- %battery = battery_data_dmi();
- if (!%battery){
+ battery_data_dmi($battery);
+ if (!%$battery){
if ($show{'battery-forced'}){
$key1 = 'Message';
$val1 = main::message('battery-data','');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
}
else {
- @rows = battery_output(\%battery);
+ battery_output($rows,$battery);
}
}
}
elsif ($bsd_type && ($sysctl{'battery'} || $show{'battery-forced'})){
- %battery = battery_data_sysctl() if $sysctl{'battery'};
- if (!%battery){
+ battery_data_sysctl($battery) if $sysctl{'battery'};
+ if (!%$battery){
if ($show{'battery-forced'}){
$key1 = 'Message';
$val1 = main::message('battery-data-bsd','');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
}
else {
- @rows = battery_output(\%battery);
+ battery_output($rows,$battery);
}
}
elsif (-d '/sys/class/power_supply/'){
- %battery = battery_data_sys();
- if (!%battery){
+ battery_data_sys($battery);
+ if (!%$battery){
if ($show{'battery-forced'}){
$key1 = 'Message';
$val1 = main::message('battery-data','');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
}
else {
- @rows = battery_output(\%battery);
+ battery_output($rows,$battery);
}
}
else {
if ($show{'battery-forced'}){
$key1 = 'Message';
$val1 = (!$bsd_type) ? main::message('battery-data-sys'): main::message('battery-data-bsd');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
}
(@upower_items,$b_upower,$upower) = ();
eval $end if $b_log;
- return @rows;
+ return $rows;
}
# alarm capacity capacity_level charge_full charge_full_design charge_now
# cycle_count energy_full energy_full_design energy_now location manufacturer model_name
@@ -7675,8 +7708,8 @@ sub get {
# 17 location
sub battery_output {
eval $start if $b_log;
- my ($battery) = @_;
- my ($key,@rows);
+ my ($rows,$battery) = @_;
+ my ($key);
my $num = 0;
my $j = 0;
# print Data::Dumper::Dumper $battery;
@@ -7712,20 +7745,20 @@ sub battery_output {
}
}
$condition ||= 'N/A';
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'ID') => $key,
main::key($num++,0,2,'charge') => $charge,
main::key($num++,0,2,'condition') => $condition,
- },);
+ });
if ($extra > 0 || ($battery->{$key}{'voltage_now'} &&
$battery->{$key}{'voltage_min_design'} &&
($battery->{$key}{'voltage_now'} - $battery->{$key}{'voltage_min_design'}) < 0.5)){
$battery->{$key}{'voltage_now'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,2,'volts')} = $battery->{$key}{'voltage_now'};
+ $rows->[$j]{main::key($num++,1,2,'volts')} = $battery->{$key}{'voltage_now'};
if ($battery->{$key}{'voltage_now'} ne 'N/A' || $battery->{$key}{'voltage_min_design'}){
$battery->{$key}{'voltage_min_design'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'min')} = $battery->{$key}{'voltage_min_design'};
+ $rows->[$j]{main::key($num++,0,3,'min')} = $battery->{$key}{'voltage_min_design'};
}
}
if ($extra > 0){
@@ -7743,23 +7776,23 @@ sub battery_output {
else {
$model = 'N/A';
}
- $rows[$j]->{main::key($num++,0,2,'model')} = $model;
+ $rows->[$j]{main::key($num++,0,2,'model')} = $model;
if ($extra > 2){
$chemistry = ($battery->{$key}{'technology'}) ? $battery->{$key}{'technology'}: 'N/A';
- $rows[$j]->{main::key($num++,0,2,'type')} = $chemistry;
+ $rows->[$j]{main::key($num++,0,2,'type')} = $chemistry;
}
if ($extra > 1){
$serial = main::filter($battery->{$key}{'serial_number'});
- $rows[$j]->{main::key($num++,0,2,'serial')} = $serial;
+ $rows->[$j]{main::key($num++,0,2,'serial')} = $serial;
}
$status = ($battery->{$key}{'status'}) ? $battery->{$key}{'status'}: 'N/A';
- $rows[$j]->{main::key($num++,0,2,'status')} = $status;
+ $rows->[$j]{main::key($num++,0,2,'status')} = $status;
if ($extra > 2){
if ($battery->{$key}{'cycle_count'}){
- $rows[$j]->{main::key($num++,0,2,'cycles')} = $battery->{$key}{'cycle_count'};
+ $rows->[$j]{main::key($num++,0,2,'cycles')} = $battery->{$key}{'cycle_count'};
}
if ($battery->{$key}{'location'}){
- $rows[$j]->{main::key($num++,0,2,'location')} = $battery->{$key}{'location'};
+ $rows->[$j]{main::key($num++,0,2,'location')} = $battery->{$key}{'location'};
}
}
}
@@ -7773,11 +7806,10 @@ sub battery_output {
$num = 0;
next if !defined $battery->{$key} || $battery->{$key}{'purpose'} eq 'mains';
my ($charge,$model,$serial,$percent,$status,$vendor) = ('','','','','','');
- my (%upower_data);
- $j = scalar @rows;
- %upower_data = upower_data($key) if $upower;
- if ($upower_data{'percent'}){
- $charge = $upower_data{'percent'};
+ $j = scalar @$rows;
+ my $upower_data = ($upower) ? upower_data($key) : {};
+ if ($upower_data->{'percent'}){
+ $charge = $upower_data->{'percent'};
}
elsif ($battery->{$key}{'capacity_level'} &&
lc($battery->{$key}{'capacity_level'}) ne 'unknown'){
@@ -7799,30 +7831,30 @@ sub battery_output {
else {
$model = 'N/A';
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $key,
main::key($num++,0,2,'model') => $model,
},);
if ($extra > 1){
$serial = main::filter($battery->{$key}{'serial_number'});
- $rows[$j]->{main::key($num++,0,2,'serial')} = $serial;
+ $rows->[$j]{main::key($num++,0,2,'serial')} = $serial;
}
- $rows[$j]->{main::key($num++,0,2,'charge')} = $charge;
- if ($extra > 2 && $upower_data{'rechargeable'}){
- $rows[$j]->{main::key($num++,0,2,'rechargeable')} = $upower_data{'rechargeable'};
+ $rows->[$j]{main::key($num++,0,2,'charge')} = $charge;
+ if ($extra > 2 && $upower_data->{'rechargeable'}){
+ $rows->[$j]{main::key($num++,0,2,'rechargeable')} = $upower_data->{'rechargeable'};
}
$status = ($battery->{$key}{'status'}) ? $battery->{$key}{'status'}: 'N/A' ;
- $rows[$j]->{main::key($num++,0,2,'status')} = $status;
+ $rows->[$j]{main::key($num++,0,2,'status')} = $status;
}
}
eval $end if $b_log;
- return @rows;
}
# charge: mAh energy: Wh
sub battery_data_sys {
eval $start if $b_log;
- my ($b_ma,%battery,$file,$id,$item,$path,$value);
+ my $battery = $_[0];
+ my ($b_ma,$file,$id,$item,$path,$value);
my $num = 0;
my @batteries = main::globber("/sys/class/power_supply/*");
# note: there is no 'location' file, but dmidecode has it
@@ -7843,7 +7875,7 @@ sub battery_data_sys {
$value = (-r $path) ? main::reader($path,'',0): '';
# mains, plus in psu
if ($file eq 'type' && $value && lc($value) ne 'battery'){
- $battery{$id}->{'purpose'} = 'mains';
+ $battery->{$id}{'purpose'} = 'mains';
}
if ($value){
$value = main::trimmer($value);
@@ -7896,206 +7928,205 @@ sub battery_data_sys {
elsif ($b_root && -e $path && ! -r $path){
$value = main::message('root-required');
}
- $battery{$id}->{$file} = $value;
- # print "$battery{$id}->{$file}\n";
+ $battery->{$id}{$file} = $value;
+ # print "$battery->{$id}{$file}\n";
}
# note, too few data sets, there could be sbs-charger but not sure
- if (!$battery{$id}->{'purpose'}){
+ if (!$battery->{$id}{'purpose'}){
# NOTE: known ids: BAT[0-9] CMB[0-9]. arm may be like: sbs- sbm- but just check
# if the energy/charge values exist for this item, if so, it's a battery, if not,
# it's a device.
if ($id =~ /^(BAT|CMB).*$/i ||
- ($battery{$id}->{'energy_full'} || $battery{$id}->{'charge_full'} ||
- $battery{$id}->{'energy_now'} || $battery{$id}->{'charge_now'} ||
- $battery{$id}->{'energy_full_design'} || $battery{$id}->{'charge_full_design'}) ||
- $battery{$id}->{'voltage_min_design'} || $battery{$id}->{'voltage_now'}){
- $battery{$id}->{'purpose'} = 'primary';
+ ($battery->{$id}{'energy_full'} || $battery->{$id}{'charge_full'} ||
+ $battery->{$id}{'energy_now'} || $battery->{$id}{'charge_now'} ||
+ $battery->{$id}{'energy_full_design'} || $battery->{$id}{'charge_full_design'}) ||
+ $battery->{$id}{'voltage_min_design'} || $battery->{$id}{'voltage_now'}){
+ $battery->{$id}{'purpose'} = 'primary';
}
else {
- $battery{$id}->{'purpose'} = 'device';
+ $battery->{$id}{'purpose'} = 'device';
}
}
# note:voltage_now fluctuates, which will make capacity numbers change a bit
# if any of these values failed, the math will be wrong, but no way to fix that
# tests show more systems give right capacity/charge with voltage_min_design
# than with voltage_now
- if ($b_ma && $battery{$id}->{'voltage_min_design'}){
- if ($battery{$id}->{'charge_now'}){
- $battery{$id}->{'energy_now'} = $battery{$id}->{'charge_now'} * $battery{$id}->{'voltage_min_design'};
+ if ($b_ma && $battery->{$id}{'voltage_min_design'}){
+ if ($battery->{$id}{'charge_now'}){
+ $battery->{$id}{'energy_now'} = $battery->{$id}{'charge_now'} * $battery->{$id}{'voltage_min_design'};
}
- if ($battery{$id}->{'charge_full'}){
- $battery{$id}->{'energy_full'} = $battery{$id}->{'charge_full'}*$battery{$id}->{'voltage_min_design'};
+ if ($battery->{$id}{'charge_full'}){
+ $battery->{$id}{'energy_full'} = $battery->{$id}{'charge_full'}*$battery->{$id}{'voltage_min_design'};
}
- if ($battery{$id}->{'charge_full_design'}){
- $battery{$id}->{'energy_full_design'} = $battery{$id}->{'charge_full_design'} * $battery{$id}->{'voltage_min_design'};
+ if ($battery->{$id}{'charge_full_design'}){
+ $battery->{$id}{'energy_full_design'} = $battery->{$id}{'charge_full_design'} * $battery->{$id}{'voltage_min_design'};
}
}
- if ($battery{$id}->{'energy_now'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'capacity'} = 100 * $battery{$id}->{'energy_now'}/$battery{$id}->{'energy_full'};
- $battery{$id}->{'capacity'} = sprintf("%.1f", $battery{$id}->{'capacity'});
+ if ($battery->{$id}{'energy_now'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'capacity'} = 100 * $battery->{$id}{'energy_now'}/$battery->{$id}{'energy_full'};
+ $battery->{$id}{'capacity'} = sprintf("%.1f", $battery->{$id}{'capacity'});
}
- if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'of_orig'} = 100 * $battery{$id}->{'energy_full'}/$battery{$id}->{'energy_full_design'};
- $battery{$id}->{'of_orig'} = sprintf("%.1f", $battery{$id}->{'of_orig'});
+ if ($battery->{$id}{'energy_full_design'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'of_orig'} = 100 * $battery->{$id}{'energy_full'}/$battery->{$id}{'energy_full_design'};
+ $battery->{$id}{'of_orig'} = sprintf("%.1f", $battery->{$id}{'of_orig'});
}
- if ($battery{$id}->{'energy_now'}){
- $battery{$id}->{'energy_now'} = sprintf("%.1f", $battery{$id}->{'energy_now'});
+ if ($battery->{$id}{'energy_now'}){
+ $battery->{$id}{'energy_now'} = sprintf("%.1f", $battery->{$id}{'energy_now'});
}
- if ($battery{$id}->{'energy_full_design'}){
- $battery{$id}->{'energy_full_design'} = sprintf("%.1f",$battery{$id}->{'energy_full_design'});
+ if ($battery->{$id}{'energy_full_design'}){
+ $battery->{$id}{'energy_full_design'} = sprintf("%.1f",$battery->{$id}{'energy_full_design'});
}
- if ($battery{$id}->{'energy_full'}){
- $battery{$id}->{'energy_full'} = sprintf("%.1f", $battery{$id}->{'energy_full'});
+ if ($battery->{$id}{'energy_full'}){
+ $battery->{$id}{'energy_full'} = sprintf("%.1f", $battery->{$id}{'energy_full'});
}
}
- print Data::Dumper::Dumper \%battery if $dbg[33];
- main::log_data('dump','sys: %battery',\%battery) if $b_log;
+ print Data::Dumper::Dumper $battery if $dbg[33];
+ main::log_data('dump','sys: %$battery',$battery) if $b_log;
eval $end if $b_log;
- return %battery;
}
sub battery_data_sysctl {
eval $start if $b_log;
- my (%battery,$id);
+ my $battery = $_[0];
+ my ($id);
for (@{$sysctl{'battery'}}){
if (/^(hw\.sensors\.)acpi([^\.]+)(\.|:)/){
$id = uc($2);
}
if (/volt[^:]+:([0-9\.]+)\s+VDC\s+\(voltage\)/){
- $battery{$id}->{'voltage_min_design'} = $1;
+ $battery->{$id}{'voltage_min_design'} = $1;
}
elsif (/volt[^:]+:([0-9\.]+)\s+VDC\s+\(current voltage\)/){
- $battery{$id}->{'voltage_now'} = $1;
+ $battery->{$id}{'voltage_now'} = $1;
}
elsif (/watthour[^:]+:([0-9\.]+)\s+Wh\s+\(design capacity\)/){
- $battery{$id}->{'energy_full_design'} = $1;
+ $battery->{$id}{'energy_full_design'} = $1;
}
elsif (/watthour[^:]+:([0-9\.]+)\s+Wh\s+\(last full capacity\)/){
- $battery{$id}->{'energy_full'} = $1;
+ $battery->{$id}{'energy_full'} = $1;
}
elsif (/watthour[^:]+:([0-9\.]+)\s+Wh\s+\(remaining capacity\)/){
- $battery{$id}->{'energy_now'} = $1;
+ $battery->{$id}{'energy_now'} = $1;
}
elsif (/amphour[^:]+:([0-9\.]+)\s+Ah\s+\(design capacity\)/){
- $battery{$id}->{'charge_full_design'} = $1;
+ $battery->{$id}{'charge_full_design'} = $1;
}
elsif (/amphour[^:]+:([0-9\.]+)\s+Ah\s+\(last full capacity\)/){
- $battery{$id}->{'charge_full'} = $1;
+ $battery->{$id}{'charge_full'} = $1;
}
elsif (/amphour[^:]+:([0-9\.]+)\s+Ah\s+\(remaining capacity\)/){
- $battery{$id}->{'charge_now'} = $1;
+ $battery->{$id}{'charge_now'} = $1;
}
elsif (/raw[^:]+:[0-9\.]+\s+\((battery) ([^\)]+)\)/){
- $battery{$id}->{'status'} = $2;
+ $battery->{$id}{'status'} = $2;
}
elsif (/^acpi[\S]+:at [^:]+:\s*$id\s+/i){
if (/\s+model\s+(.*?)\s*/){
- $battery{$id}->{'model_name'} = main::clean_dmi($1);
+ $battery->{$id}{'model_name'} = main::clean_dmi($1);
}
if (/\s*serial\s+([\S]*?)\s*/){
- $battery{$id}->{'serial_number'} = main::clean_unset($1,'^(0x)0+$');
+ $battery->{$id}{'serial_number'} = main::clean_unset($1,'^(0x)0+$');
}
if (/\s*type\s+(.*?)\s*/){
- $battery{$id}->{'technology'} = $1;
+ $battery->{$id}{'technology'} = $1;
}
if (/\s*oem\s+(.*)/){
- $battery{$id}->{'manufacturer'} = main::clean_dmi($1);
+ $battery->{$id}{'manufacturer'} = main::clean_dmi($1);
}
}
}
# then do the condition/charge percent math
- for my $id (keys %battery){
- $battery{$id}->{'purpose'} = 'primary';
+ for my $id (keys %$battery){
+ $battery->{$id}{'purpose'} = 'primary';
# CHARGE is Ah, which are converted to Wh by: Ah x voltage.
- if ($battery{$id}->{'voltage_min_design'}){
- if ($battery{$id}->{'charge_now'}){
- $battery{$id}->{'energy_now'} = $battery{$id}->{'charge_now'} * $battery{$id}->{'voltage_min_design'};
+ if ($battery->{$id}{'voltage_min_design'}){
+ if ($battery->{$id}{'charge_now'}){
+ $battery->{$id}{'energy_now'} = $battery->{$id}{'charge_now'} * $battery->{$id}{'voltage_min_design'};
}
- if ($battery{$id}->{'charge_full'}){
- $battery{$id}->{'energy_full'} = $battery{$id}->{'charge_full'}*$battery{$id}->{'voltage_min_design'};
+ if ($battery->{$id}{'charge_full'}){
+ $battery->{$id}{'energy_full'} = $battery->{$id}{'charge_full'}*$battery->{$id}{'voltage_min_design'};
}
- if ($battery{$id}->{'charge_full_design'}){
- $battery{$id}->{'energy_full_design'} = $battery{$id}->{'charge_full_design'} * $battery{$id}->{'voltage_min_design'};
+ if ($battery->{$id}{'charge_full_design'}){
+ $battery->{$id}{'energy_full_design'} = $battery->{$id}{'charge_full_design'} * $battery->{$id}{'voltage_min_design'};
}
}
- if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'of_orig'} = 100 * $battery{$id}->{'energy_full'}/$battery{$id}->{'energy_full_design'};
- $battery{$id}->{'of_orig'} = sprintf("%.1f", $battery{$id}->{'of_orig'});
+ if ($battery->{$id}{'energy_full_design'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'of_orig'} = 100 * $battery->{$id}{'energy_full'}/$battery->{$id}{'energy_full_design'};
+ $battery->{$id}{'of_orig'} = sprintf("%.1f", $battery->{$id}{'of_orig'});
}
- if ($battery{$id}->{'energy_now'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'capacity'} = 100 * $battery{$id}->{'energy_now'}/$battery{$id}->{'energy_full'};
- $battery{$id}->{'capacity'} = sprintf("%.1f", $battery{$id}->{'capacity'});
+ if ($battery->{$id}{'energy_now'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'capacity'} = 100 * $battery->{$id}{'energy_now'}/$battery->{$id}{'energy_full'};
+ $battery->{$id}{'capacity'} = sprintf("%.1f", $battery->{$id}{'capacity'});
}
- if ($battery{$id}->{'energy_now'}){
- $battery{$id}->{'energy_now'} = sprintf("%.1f", $battery{$id}->{'energy_now'});
+ if ($battery->{$id}{'energy_now'}){
+ $battery->{$id}{'energy_now'} = sprintf("%.1f", $battery->{$id}{'energy_now'});
}
- if ($battery{$id}->{'energy_full'}){
- $battery{$id}->{'energy_full'} = sprintf("%.1f", $battery{$id}->{'energy_full'});
+ if ($battery->{$id}{'energy_full'}){
+ $battery->{$id}{'energy_full'} = sprintf("%.1f", $battery->{$id}{'energy_full'});
}
- if ($battery{$id}->{'energy_full_design'}){
- $battery{$id}->{'energy_full_design'} = sprintf("%.1f", $battery{$id}->{'energy_full_design'});
+ if ($battery->{$id}{'energy_full_design'}){
+ $battery->{$id}{'energy_full_design'} = sprintf("%.1f", $battery->{$id}{'energy_full_design'});
}
}
- print Data::Dumper::Dumper \%battery if $dbg[33];
- main::log_data('dump','dmi: %battery',\%battery) if $b_log;
+ print Data::Dumper::Dumper $battery if $dbg[33];
+ main::log_data('dump','dmi: %$battery',$battery) if $b_log;
eval $end if $b_log;
- return %battery;
}
# note, dmidecode does not have charge_now or charge_full
sub battery_data_dmi {
eval $start if $b_log;
- my (%battery,$id);
+ my $battery = $_[0];
+ my ($id);
my $i = 0;
foreach my $row (@dmi){
# Portable Battery
if ($row->[0] == 22){
$id = "BAT$i";
$i++;
- $battery{$id}->{'purpose'} = 'primary';
+ $battery->{$id}{'purpose'} = 'primary';
# skip first three row, we don't need that data
foreach my $item (@$row[3 .. $#$row]){
my @value = split(/:\s+/, $item);
next if !$value[0];
if ($value[0] eq 'Location'){
- $battery{$id}->{'location'} = $value[1]}
+ $battery->{$id}{'location'} = $value[1]}
elsif ($value[0] eq 'Manufacturer'){
- $battery{$id}->{'manufacturer'} = main::clean_dmi($value[1])}
+ $battery->{$id}{'manufacturer'} = main::clean_dmi($value[1])}
elsif ($value[0] =~ /Chemistry/){
- $battery{$id}->{'technology'} = $value[1]}
+ $battery->{$id}{'technology'} = $value[1]}
elsif ($value[0] =~ /Serial Number/){
- $battery{$id}->{'serial_number'} = $value[1]}
+ $battery->{$id}{'serial_number'} = $value[1]}
elsif ($value[0] =~ /^Name/){
- $battery{$id}->{'model_name'} = main::clean_dmi($value[1])}
+ $battery->{$id}{'model_name'} = main::clean_dmi($value[1])}
elsif ($value[0] eq 'Design Capacity'){
$value[1] =~ s/\s*mwh$//i;
- $battery{$id}->{'energy_full_design'} = sprintf("%.1f", $value[1]/1000);
+ $battery->{$id}{'energy_full_design'} = sprintf("%.1f", $value[1]/1000);
}
elsif ($value[0] eq 'Design Voltage'){
$value[1] =~ s/\s*mv$//i;
- $battery{$id}->{'voltage_min_design'} = sprintf("%.1f", $value[1]/1000);
+ $battery->{$id}{'voltage_min_design'} = sprintf("%.1f", $value[1]/1000);
}
}
- if ($battery{$id}->{'energy_now'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'capacity'} = 100 * $battery{$id}->{'energy_now'} / $battery{$id}->{'energy_full'};
- $battery{$id}->{'capacity'} = sprintf("%.1f%", $battery{$id}->{'capacity'});
+ if ($battery->{$id}{'energy_now'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'capacity'} = 100 * $battery->{$id}{'energy_now'} / $battery->{$id}{'energy_full'};
+ $battery->{$id}{'capacity'} = sprintf("%.1f%", $battery->{$id}{'capacity'});
}
- if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'}){
- $battery{$id}->{'of_orig'} = 100 * $battery{$id}->{'energy_full'} / $battery{$id}->{'energy_full_design'};
- $battery{$id}->{'of_orig'} = sprintf("%.0f%", $battery{$id}->{'of_orig'});
+ if ($battery->{$id}{'energy_full_design'} && $battery->{$id}{'energy_full'}){
+ $battery->{$id}{'of_orig'} = 100 * $battery->{$id}{'energy_full'} / $battery->{$id}{'energy_full_design'};
+ $battery->{$id}{'of_orig'} = sprintf("%.0f%", $battery->{$id}{'of_orig'});
}
}
elsif ($row->[0] > 22){
last;
}
}
- print Data::Dumper::Dumper \%battery if $dbg[33];
- main::log_data('dump','dmi: %battery',\%battery) if $b_log;
+ print Data::Dumper::Dumper $battery if $dbg[33];
+ main::log_data('dump','dmi: %$battery',$battery) if $b_log;
eval $end if $b_log;
- return %battery;
}
sub upower_data {
my ($id) = @_;
eval $start if $b_log;
- my (%data);
+ my $data = {};
if (!$b_upower && $upower){
@upower_items = main::grabber("$upower -e",'','strip');
$b_upower = 1;
@@ -8107,19 +8138,19 @@ sub upower_data {
foreach my $row (@working){
my @temp = split(/\s*:\s*/, $row);
if ($temp[0] eq 'percentage'){
- $data{'percent'} = $temp[1];
+ $data->{'percent'} = $temp[1];
}
elsif ($temp[0] eq 'rechargeable'){
- $data{'rechargeable'} = $temp[1];
+ $data->{'rechargeable'} = $temp[1];
}
}
last;
}
}
}
- main::log_data('dump','upower: %data',\%data) if $b_log;
+ main::log_data('dump','upower: %$data',$data) if $b_log;
eval $end if $b_log;
- return %data;
+ return $data;
}
}
@@ -8132,7 +8163,7 @@ my ($service);
my (%hci);
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
$b_bluetooth = 1 if @ps_cmd && (grep {m|/bluetoothd\b|} @ps_cmd);
# note: rapi 4 has pci bus
@@ -8140,39 +8171,38 @@ sub get {
# do nothing, but keep the test conditions to force
# the non risc case to always run
# my $key = 'Message';
- # push(@rows,{
- # main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'}),
- # },);
+ # @$rows = ({
+ # main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'})
+ # });
}
else {
- push(@rows,device_output());
+ device_output($rows);
}
- push(@rows,usb_output());
- if (!@rows){
+ usb_output($rows);
+ if (!@$rows){
if ($show{'bluetooth-forced'}){
my $key = 'Message';
- push(@rows,{
- main::key($num++,0,1,$key) => main::message('bluetooth-data'),
- },);
+ @$rows = ({main::key($num++,0,1,$key) => main::message('bluetooth-data')});
}
}
# if there are any unhandled hci items print them out
if (%hci){
- push(@rows,advanced_output('check',''));
+ advanced_output($rows,'check','');
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub device_output {
eval $start if $b_log;
return if !$devices{'bluetooth'};
- my ($bus_id,@rows);
+ my $rows = $_[0];
+ my ($bus_id);
my ($j,$num) = (0,1);
foreach my $row (@{$devices{'bluetooth'}}){
$num = 1;
$bus_id = '';
- $j = scalar @rows;
+ $j = scalar @$rows;
my $driver = ($row->[9]) ? $row->[9] : 'N/A';
my $device = $row->[4];
$device = ($device) ? main::clean_pci($device,'output') : 'N/A';
@@ -8180,34 +8210,34 @@ sub device_output {
if (length($device) > 85 || $size{'max-cols'} < 110){
$device = main::filter_pci_long($device);
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $device,
},);
if ($extra > 0 && $use{'pci-tool'} && $row->[12]){
my $item = main::get_pci_vendor($row->[4],$row->[12]);
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $item if $item;
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $item if $item;
}
- $rows[$j]->{main::key($num++,1,2,'driver')} = $driver;
+ $rows->[$j]{main::key($num++,1,2,'driver')} = $driver;
if ($extra > 0 && $row->[9] && !$bsd_type){
my $version = main::get_module_version($row->[9]);
- $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version if $version;
}
if ($b_admin && $row->[10]){
$row->[10] = main::get_driver_modules($row->[9],$row->[10]);
- $rows[$j]->{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
+ $rows->[$j]{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
}
if ($extra > 0){
$bus_id = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]";
if ($extra > 1 && $bus_id ne 'N/A'){
- main::get_pcie_data($bus_id,$j,\@rows,\$num);
+ main::get_pcie_data($bus_id,$j,$rows,\$num);
}
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
my $chip_id = main::get_chip_id($row->[5],$row->[6]);
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $chip_id;
if ($extra > 2 && $row->[1]){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = $row->[1];
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = $row->[1];
}
}
# weird serial rpi bt
@@ -8219,58 +8249,57 @@ sub device_output {
# only theoretical, never seen one
$bus_id = "$row->[2].$row->[3]" if defined $row->[2] && defined $row->[3];
}
- push(@rows,advanced_output('pci',$bus_id)) if $bus_id;
+ advanced_output($rows,'pci',$bus_id) if $bus_id;
# print "$row->[0]\n";
}
eval $end if $b_log;
- return @rows;
}
sub usb_output {
eval $start if $b_log;
return if !$usb{'bluetooth'};
- my (@rows,$path_id,$product);
+ my $rows = $_[0];
+ my ($path_id,$product);
my ($j,$num) = (0,1);
foreach my $row (@{$usb{'bluetooth'}}){
# print Data::Dumper::Dumper $row;
$num = 1;
- $j = scalar @rows;
+ $j = scalar @$rows;
# makre sure to reset, or second device trips last flag
($path_id,$product) = ('','');
$product = main::clean($row->[13]) if $row->[13];
$product ||= 'N/A';
$row->[15] ||= 'N/A';
$path_id = $row->[2] if $row->[2];
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $product,
main::key($num++,0,2,'type') => 'USB',
main::key($num++,1,2,'driver') => $row->[15],
},);
if ($extra > 0 && $row->[15] && !$bsd_type){
my $version = main::get_module_version($row->[15]);
- $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version if $version;
}
if ($extra > 0){
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
}
if ($extra > 1){
$row->[7] ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $row->[7];
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $row->[7];
}
if ($extra > 2 && defined $row->[5] && $row->[5] ne ''){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
}
if ($extra > 2 && $row->[16]){
- $rows[$j]->{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
+ $rows->[$j]{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
}
- push(@rows,advanced_output('usb',$path_id)) if $path_id;
+ advanced_output($rows,'usb',$path_id) if $path_id;
}
eval $end if $b_log;
- return @rows;
}
sub advanced_output {
- my ($type,$bus_id) = @_;
eval $start if $b_log;
- my (@rows,@temp);
+ my ($rows,$type,$bus_id) = @_;
+ my (@temp);
my ($j,$num,$k,$l,$m,$n,$address,$id,$note,$tool) = (0,1,2,3,4,5,'','','','');
if (!$b_hci && $alerts{'hciconfig'}->{'action'} eq 'use'){
hciconfig_data();
@@ -8302,10 +8331,10 @@ sub advanced_output {
if ($hci{'alert'}){
if (keys %hci == 1){
check_service(); # sets $service
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,$k,'Report')} = $tool;
- $rows[$j]->{main::key($num++,0,$l,'bt-service')} = $service;
- $rows[$j]->{main::key($num++,0,$l,'note')} = $hci{'alert'};
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,$k,'Report')} = $tool;
+ $rows->[$j]{main::key($num++,0,$l,'bt-service')} = $service;
+ $rows->[$j]{main::key($num++,0,$l,'note')} = $hci{'alert'};
}
else {
$note = $hci{'alert'};
@@ -8314,33 +8343,33 @@ sub advanced_output {
}
foreach my $item (@temp){
if ($hci{$item}){
- $j = scalar @rows;
- push(@rows,{
+ $j = scalar @$rows;
+ push(@$rows,{
main::key($num++,1,$k,'Report' . $id) => $tool,
},);
if ($note){
- $rows[$j]->{main::key($num++,0,$l,'note')} = $note;
+ $rows->[$j]{main::key($num++,0,$l,'note')} = $note;
}
# synthesize for rfkill
if (!$hci{$item}->{'state'}){
$hci{$item}->{'state'} = ($b_bluetooth) ? 'up' : 'down';
}
- $rows[$j]->{main::key($num++,0,$l,'ID')} = $item;
+ $rows->[$j]{main::key($num++,0,$l,'ID')} = $item;
if (defined $hci{$item}->{'rf-index'} &&
($extra > 0 || $hci{$item}->{'state'} eq 'down')){
- $rows[$j]->{main::key($num++,0,$m,'rfk-id')} = $hci{$item}->{'rf-index'};
+ $rows->[$j]{main::key($num++,0,$m,'rfk-id')} = $hci{$item}->{'rf-index'};
}
- $rows[$j]->{main::key($num++,1,$l,'state')} = $hci{$item}->{'state'};
+ $rows->[$j]{main::key($num++,1,$l,'state')} = $hci{$item}->{'state'};
# this only appears for hciconfig, bt-adapter does not run without bt service
if (!$b_bluetooth || $hci{$item}->{'state'} eq 'down'){
if (!$b_bluetooth || $hci{$item}->{'state'} eq 'down'){
check_service(); # sets $service
- $rows[$j]->{main::key($num++,0,$m,'bt-service')} = $service;
+ $rows->[$j]{main::key($num++,0,$m,'bt-service')} = $service;
}
if ($hci{$item}->{'hard-blocked'}){
- $rows[$j]->{main::key($num++,1,$m,'rfk-block')} = '';
- $rows[$j]->{main::key($num++,0,$n,'hardware')} = $hci{$item}->{'hard-blocked'};
- $rows[$j]->{main::key($num++,0,$n,'software')} = $hci{$item}->{'soft-blocked'};
+ $rows->[$j]{main::key($num++,1,$m,'rfk-block')} = '';
+ $rows->[$j]{main::key($num++,0,$n,'hardware')} = $hci{$item}->{'hard-blocked'};
+ $rows->[$j]{main::key($num++,0,$n,'software')} = $hci{$item}->{'soft-blocked'};
}
}
if (!$hci{$item}->{'address'} && $tool eq 'rfkill'){
@@ -8349,62 +8378,63 @@ sub advanced_output {
else {
$address = main::filter($hci{$item}->{'address'});
}
- $rows[$j]->{main::key($num++,0,$l,'address')} = $address;
+ $rows->[$j]{main::key($num++,0,$l,'address')} = $address;
# lmp/hci version only hciconfig sadly
if (defined $hci{$item}->{'lmp-version'} &&
(my $btv = bluetooth_version($hci{$item}->{'lmp-version'}))){
- $rows[$j]->{main::key($num++,0,$l,'bt-v')} = $btv;
+ $rows->[$j]{main::key($num++,0,$l,'bt-v')} = $btv;
}
if ($extra > 0 && defined $hci{$item}->{'lmp-version'}){
- $rows[$j]->{main::key($num++,0,$l,'lmp-v')} = $hci{$item}->{'lmp-version'};
+ $rows->[$j]{main::key($num++,0,$l,'lmp-v')} = $hci{$item}->{'lmp-version'};
if ($extra > 1 && $hci{$item}->{'lmp-subversion'}){
- $rows[$j]->{main::key($num++,0,$m,'sub-v')} = $hci{$item}->{'lmp-subversion'};
+ $rows->[$j]{main::key($num++,0,$m,'sub-v')} = $hci{$item}->{'lmp-subversion'};
}
}
if ($extra > 0 && defined $hci{$item}->{'hci-version'} && ($extra > 2 || !$hci{$item}->{'lmp-version'} ||
($hci{$item}->{'lmp-version'} && $hci{$item}->{'lmp-version'} ne $hci{$item}->{'hci-version'}))){
- $rows[$j]->{main::key($num++,0,$l,'hci-v')} = $hci{$item}->{'hci-version'};
+ $rows->[$j]{main::key($num++,0,$l,'hci-v')} = $hci{$item}->{'hci-version'};
if ($extra > 1 && $hci{$item}->{'hci-revision'}){
- $rows[$j]->{main::key($num++,0,$m,'rev')} = $hci{$item}->{'hci-revision'};
+ $rows->[$j]{main::key($num++,0,$m,'rev')} = $hci{$item}->{'hci-revision'};
}
}
# if ($extra > 1 && $hci{$item}->{'discoverable'}){
- # $rows[$j]->{main::key($num++,1,$l,'discover')} = $hci{$item}->{'discoverable'};
+ # $rows->[$j]{main::key($num++,1,$l,'discover')} = $hci{$item}->{'discoverable'};
# if ($extra > 2 && $hci{$item}->{'discovering'}){
- # $rows[$j]->{main::key($num++,1,$m,'active')} = $hci{$item}->{'discovering'};
+ # $rows->[$j]{main::key($num++,1,$m,'active')} = $hci{$item}->{'discovering'};
# }
# }
# if ($extra > 1 && $hci{$item}->{'pairable'}){
- # $rows[$j]->{main::key($num++,0,$l,'pair')} = $hci{$item}->{'pairable'};
+ # $rows->[$j]{main::key($num++,0,$l,'pair')} = $hci{$item}->{'pairable'};
# }
# this data only from hciconfig
if ($b_admin &&
($hci{$item}->{'acl-mtu'} || $hci{$item}->{'sco-mtu'} || $hci{$item}->{'link-policy'})){
- $j = scalar @rows;
- push(@rows,{
+ $j = scalar @$rows;
+ push(@$rows,{
main::key($num++,1,$l,'Info') => '',
},);
if ($hci{$item}->{'acl-mtu'}){
- $rows[$j]->{main::key($num++,0,$m,'acl-mtu')} = $hci{$item}->{'acl-mtu'};
+ $rows->[$j]{main::key($num++,0,$m,'acl-mtu')} = $hci{$item}->{'acl-mtu'};
}
if ($hci{$item}->{'sco-mtu'}){
- $rows[$j]->{main::key($num++,0,$m,'sco-mtu')} = $hci{$item}->{'sco-mtu'};
+ $rows->[$j]{main::key($num++,0,$m,'sco-mtu')} = $hci{$item}->{'sco-mtu'};
}
if ($hci{$item}->{'link-policy'}){
- $rows[$j]->{main::key($num++,0,$m,'link-policy')} = $hci{$item}->{'link-policy'};
+ $rows->[$j]{main::key($num++,0,$m,'link-policy')} = $hci{$item}->{'link-policy'};
}
if ($hci{$item}->{'link-mode'}){
- $rows[$j]->{main::key($num++,0,$m,'link-mode')} = $hci{$item}->{'link-mode'};
+ $rows->[$j]{main::key($num++,0,$m,'link-mode')} = $hci{$item}->{'link-mode'};
}
if ($hci{$item}->{'service-classes'}){
- $rows[$j]->{main::key($num++,0,$m,'service-classes')} = $hci{$item}->{'service-classes'};
+ $rows->[$j]{main::key($num++,0,$m,'service-classes')} = $hci{$item}->{'service-classes'};
}
}
delete $hci{$item};
}
}
}
- if (!@rows && !$b_hci_error && ($alerts{'hciconfig'}->{'action'} ne 'use' &&
+ # since $rows is ref, we need to just check if no $j were set.
+ if (!$j && !$b_hci_error && ($alerts{'hciconfig'}->{'action'} ne 'use' &&
$alerts{'bt-adapter'}->{'action'} ne 'use')){
my $key = 'Report';
my $value = '';
@@ -8415,13 +8445,12 @@ sub advanced_output {
else {
$value = main::message('tools-missing','hciconfig/bt-adapter');
}
- push(@rows,{
+ push(@$rows,{
main::key($num++,0,1,$key) => $value,
},);
$b_hci_error = 1;
}
eval $end if $b_log;
- return @rows;
}
sub bt_tool_data {
@@ -8588,27 +8617,30 @@ my ($type);
sub get {
eval $start if $b_log;
($type) = @_;
- my (@rows);
+ my $rows = [];
if ($type eq 'short' || $type eq 'basic'){
# note, for short form, just return the raw data, not the processed output
- @rows = short_data();
+ my $cpu = short_data();
if ($type eq 'basic'){
- @rows = short_output(\@rows);
+ short_output($rows,$cpu);
+ }
+ else {
+ $rows = $cpu;
}
}
else {
- @rows = full_output();
+ full_output($rows);
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
## OUTPUT HANDLERS ##
sub full_output {
eval $start if $b_log;
+ my $rows = $_[0];
my $num = 0;
my ($b_speeds,$core_speeds_value,$cpu);
- my (@rows);
my $sleep = $cpu_sleep * 1000000;
if (my $file = $system_files{'proc-cpuinfo'}){
$cpu = cpuinfo_data($file);
@@ -8624,17 +8656,16 @@ sub full_output {
else {
$key1 = ucfirst($alerts{'sysctl'}->{'action'});
$val1 = $alerts{'sysctl'}->{'message'};
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
- return @rows;
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
+ return;
}
}
}
my $properties = cpu_properties($cpu);
my $type = ($properties->{'cpu-type'}) ? $properties->{'cpu-type'}: '';
- my $j = scalar @rows;
- $j = scalar @rows;
+ my $j = scalar @$rows;
$cpu->{'model_name'} ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Info') => $properties->{'topology-string'},
main::key($num++,0,2,'model') => $cpu->{'model_name'},
},);
@@ -8644,64 +8675,75 @@ sub full_output {
my $counter = (%system_cpus && scalar keys %system_cpus > 1) ? '-' : '';
foreach my $key (keys %system_cpus){
$counter = '-' . $i++ if $counter;
- $rows[$j]->{main::key($num++,0,2,'variant'.$counter)} = $key;
+ $rows->[$j]{main::key($num++,0,2,'variant'.$counter)} = $key;
}
}
if ($b_admin && $properties->{'socket'}){
if ($properties->{'upgrade'}){
- $rows[$j]->{main::key($num++,1,2,'socket')} = $properties->{'socket'} . ' (' . $properties->{'upgrade'} . ')';
- $rows[$j]->{main::key($num++,0,3,'note')} = main::message('note-check');
+ $rows->[$j]{main::key($num++,1,2,'socket')} = $properties->{'socket'} . ' (' . $properties->{'upgrade'} . ')';
+ $rows->[$j]{main::key($num++,0,3,'note')} = main::message('note-check');
}
else {
- $rows[$j]->{main::key($num++,0,2,'socket')} = $properties->{'socket'};
+ $rows->[$j]{main::key($num++,0,2,'socket')} = $properties->{'socket'};
}
}
$properties->{'bits-sys'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'bits')} = $properties->{'bits-sys'};
+ $rows->[$j]{main::key($num++,0,2,'bits')} = $properties->{'bits-sys'};
if ($type){
- $rows[$j]->{main::key($num++,0,2,'type')} = $type;
+ $rows->[$j]{main::key($num++,0,2,'type')} = $type;
if (!$properties->{'topology-full'} && $cpu->{'smt'} && ($extra > 2 ||
($extra > 0 && $cpu->{'smt'} eq 'disabled'))){
- $rows[$j]->{main::key($num++,0,2,'smt')} = $cpu->{'smt'};
+ $rows->[$j]{main::key($num++,0,2,'smt')} = $cpu->{'smt'};
}
}
if ($extra > 0){
$cpu->{'arch'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,2,'arch')} = $cpu->{'arch'};
+ $rows->[$j]{main::key($num++,1,2,'arch')} = $cpu->{'arch'};
if ($cpu->{'arch-note'}){
- $rows[$j]->{main::key($num++,0,3,'note')} = $cpu->{'arch-note'};
+ $rows->[$j]{main::key($num++,0,3,'note')} = $cpu->{'arch-note'};
}
- # ntoe: had if arch, but stepping can be defined where arch failed, stepping can be 0
+ if ($b_admin){
+ if ($cpu->{'gen'}){
+ $rows->[$j]{main::key($num++,0,3,'gen')} = $cpu->{'gen'};
+ }
+ if ($cpu->{'year'}){
+ $rows->[$j]{main::key($num++,0,2,'built')} = $cpu->{'year'};
+ }
+ if ($cpu->{'process'}){
+ $rows->[$j]{main::key($num++,0,2,'process')} = $cpu->{'process'};
+ }
+ }
+ # note: had if arch, but stepping can be defined where arch failed, stepping can be 0
if (!$b_admin && (defined $cpu->{'stepping'} || defined $cpu->{'revision'})){
my $rev = main::get_defined($cpu->{'stepping'},$cpu->{'revision'});
- $rows[$j]->{main::key($num++,0,2,'rev')} = $rev;
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $rev;
}
}
if ($b_admin){
- $rows[$j]->{main::key($num++,0,2,'family')} = hex_and_decimal($cpu->{'family'});
- $rows[$j]->{main::key($num++,0,2,'model-id')} = hex_and_decimal($cpu->{'model-id'});
+ $rows->[$j]{main::key($num++,0,2,'family')} = hex_and_decimal($cpu->{'family'});
+ $rows->[$j]{main::key($num++,0,2,'model-id')} = hex_and_decimal($cpu->{'model-id'});
if (defined $cpu->{'stepping'}){
- $rows[$j]->{main::key($num++,0,2,'stepping')} = hex_and_decimal($cpu->{'stepping'});
+ $rows->[$j]{main::key($num++,0,2,'stepping')} = hex_and_decimal($cpu->{'stepping'});
}
elsif (defined $cpu->{'revision'}){
- $rows[$j]->{main::key($num++,0,2,'rev')} = $cpu->{'revision'};
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $cpu->{'revision'};
}
if (!%risc && $cpu->{'type'} ne 'elbrus'){
$cpu->{'microcode'} = ($cpu->{'microcode'}) ? '0x' . $cpu->{'microcode'} : 'N/A';
- $rows[$j]->{main::key($num++,0,2,'microcode')} = $cpu->{'microcode'};
+ $rows->[$j]{main::key($num++,0,2,'microcode')} = $cpu->{'microcode'};
}
}
# note, risc cpus are using l1, L2, L3 more often, but if risc and no L2, skip
if ($properties->{'topology-string'} && (($extra > 1 &&
($properties->{'l1-cache'} || $properties->{'l3-cache'})) ||
(!%risc || $properties->{'l2-cache'}) || $properties->{'cache'})){
- full_output_caches($j,$properties,\$num,\@rows);
+ full_output_caches($j,$properties,\$num,$rows);
}
# all tests already done to load this, admin, etc
if ($properties->{'topology-full'}){
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'Topology') => '',
},);
my ($id,$var) = (2,'');
@@ -8711,18 +8753,18 @@ sub full_output {
}
foreach my $topo (@{$properties->{'topology-full'}}){
if ($var){
- $rows[$j]->{main::key($num++,1,2,'variant')} = '';
+ $rows->[$j]{main::key($num++,1,2,'variant')} = '';
}
my $x = ($size{'max-cols'} == 1 || $output_type ne 'screen') ? '' : 'x';
- $rows[$j]->{main::key($num++,0,$id,'cpus')} = $topo->{'cpus'} . $x;
- $rows[$j]->{main::key($num++,1,$id+1,'cores')} = $topo->{'cores'};
+ $rows->[$j]{main::key($num++,0,$id,'cpus')} = $topo->{'cpus'} . $x;
+ $rows->[$j]{main::key($num++,1,$id+1,'cores')} = $topo->{'cores'};
if ($topo->{'cores-mt'} && $topo->{'cores-st'}){
- $rows[$j]->{main::key($num++,1,$id+2,'mt')} = $topo->{'cores-mt'};
- $rows[$j]->{main::key($num++,0,$id+3,'tpc')} = $topo->{'tpc'};
- $rows[$j]->{main::key($num++,0,$id+2,'st')} = $topo->{'cores-st'};
+ $rows->[$j]{main::key($num++,1,$id+2,'mt')} = $topo->{'cores-mt'};
+ $rows->[$j]{main::key($num++,0,$id+3,'tpc')} = $topo->{'tpc'};
+ $rows->[$j]{main::key($num++,0,$id+2,'st')} = $topo->{'cores-st'};
}
elsif ($topo->{'cores-mt'}){
- $rows[$j]->{main::key($num++,0,$id+2,'tpc')} = $topo->{'tpc'};
+ $rows->[$j]{main::key($num++,0,$id+2,'tpc')} = $topo->{'tpc'};
}
if ($topo->{'max'} || $topo->{'min'}){
my ($freq,$key) = ('','');
@@ -8738,20 +8780,19 @@ sub full_output {
$key = 'min';
$freq = $topo->{'min'};
}
- $rows[$j]->{main::key($num++,0,$id+1,$key)} = $freq;
+ $rows->[$j]{main::key($num++,0,$id+1,$key)} = $freq;
}
if ($topo->{'threads'}){
- $rows[$j]->{main::key($num++,0,$id+1,'threads')} = $topo->{'threads'};
+ $rows->[$j]{main::key($num++,0,$id+1,'threads')} = $topo->{'threads'};
}
if ($topo->{'dies'}){
- $rows[$j]->{main::key($num++,0,$id+1,'dies')} = $topo->{'dies'};
+ $rows->[$j]{main::key($num++,0,$id+1,'dies')} = $topo->{'dies'};
}
}
$cpu->{'smt'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'smt')} = $cpu->{'smt'};
- full_output_caches($j,$properties,\$num,\@rows);
+ $rows->[$j]{main::key($num++,0,2,'smt')} = $cpu->{'smt'};
+ full_output_caches($j,$properties,\$num,$rows);
}
- $j = scalar @rows;
my $speeds = $cpu->{'processors'};
my $core_key = (defined $speeds && scalar @{$speeds} > 1) ? 'cores' : 'core';
my $speed_key = ($properties->{'speed-key'}) ? $properties->{'speed-key'}: 'Speed';
@@ -8776,54 +8817,54 @@ sub full_output {
else {
$core_speeds_value = main::message('cpu-speeds');
}
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,$speed_key) => $speed,
});
if ($properties->{'avg-speed-key'}){
- $rows[$j]->{main::key($num++,0,2,$properties->{'avg-speed-key'})} = $properties->{'speed'};
+ $rows->[$j]{main::key($num++,0,2,$properties->{'avg-speed-key'})} = $properties->{'speed'};
if ($extra > 0 && $properties->{'high-speed-key'}){
- $rows[$j]->{main::key($num++,0,2,$properties->{'high-speed-key'})} = $cpu->{'high-freq'};
+ $rows->[$j]{main::key($num++,0,2,$properties->{'high-speed-key'})} = $cpu->{'high-freq'};
}
}
- $rows[$j]->{main::key($num++,0,2,$min_max_key)} = $min_max;
+ $rows->[$j]{main::key($num++,0,2,$min_max_key)} = $min_max;
if ($extra > 0 && defined $cpu->{'boost'}){
- $rows[$j]->{main::key($num++,0,2,'boost')} = $cpu->{'boost'};
+ $rows->[$j]{main::key($num++,0,2,'boost')} = $cpu->{'boost'};
}
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'};
+ $rows->[$j]{main::key($num++,0,2,'base/boost')} = $properties->{'dmi-speed'} . '/' . $properties->{'dmi-max-speed'};
}
if ($b_admin && ($cpu->{'governor'} || $cpu->{'scaling-driver'})){
- $rows[$j]->{main::key($num++,1,2,'scaling')} = '';
+ $rows->[$j]{main::key($num++,1,2,'scaling')} = '';
$cpu->{'driver'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'driver')} = $cpu->{'scaling-driver'};
+ $rows->[$j]{main::key($num++,0,3,'driver')} = $cpu->{'scaling-driver'};
$cpu->{'governor'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'governor')} = $cpu->{'governor'};
+ $rows->[$j]{main::key($num++,0,3,'governor')} = $cpu->{'governor'};
# only set if different from cpu min/max
if ($cpu->{'scaling-min-max'} && $cpu->{'scaling-min-max-key'}){
- $rows[$j]->{main::key($num++,0,3,$cpu->{'scaling-min-max-key'})} = $cpu->{'scaling-min-max'};
+ $rows->[$j]{main::key($num++,0,3,$cpu->{'scaling-min-max-key'})} = $cpu->{'scaling-min-max'};
}
}
if ($extra > 2){
if ($properties->{'volts'}){
- $rows[$j]->{main::key($num++,0,2,'volts')} = $properties->{'volts'} . ' V';
+ $rows->[$j]{main::key($num++,0,2,'volts')} = $properties->{'volts'} . ' V';
}
if ($properties->{'ext-clock'}){
- $rows[$j]->{main::key($num++,0,2,'ext-clock')} = $properties->{'ext-clock'};
+ $rows->[$j]{main::key($num++,0,2,'ext-clock')} = $properties->{'ext-clock'};
}
}
- $rows[$j]->{main::key($num++,1,2,$core_key)} = $core_speeds_value;
+ $rows->[$j]{main::key($num++,1,2,$core_key)} = $core_speeds_value;
my $i = 1;
# if say 96 0 speed cores, no need to print all those 0s
if ($b_speeds){
foreach (@{$speeds}){
- $rows[$j]->{main::key($num++,0,3,$i++)} = $_;
+ $rows->[$j]{main::key($num++,0,3,$i++)} = $_;
}
}
if ($extra > 0 && !$bsd_type){
my $bogomips = ($cpu->{'bogomips'} &&
main::is_numeric($cpu->{'bogomips'})) ? int($cpu->{'bogomips'}) : 'N/A';
- $rows[$j]->{main::key($num++,0,2,'bogomips')} = $bogomips;
+ $rows->[$j]{main::key($num++,0,2,'bogomips')} = $bogomips;
}
if (($extra > 0 && !$show{'cpu-flag'}) || $show{'cpu-flag'}){
my @flags = ($cpu->{'flags'}) ? split(/\s+/, $cpu->{'flags'}) : ();
@@ -8845,7 +8886,7 @@ sub full_output {
@flags = sort @flags;
$flag = join(' ', @flags);
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,$flag_key) => $flag,
},);
}
@@ -8866,20 +8907,19 @@ sub full_output {
$value = $filter_string;
undef $cpu->{'bugs-hash'};
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Vulnerabilities') => $value,
},);
if (defined $cpu->{'bugs-hash'}){
- $j = scalar @rows;
+ $j = scalar @$rows;
foreach my $key (sort keys %{$cpu->{'bugs-hash'}}){
- $rows[$j]->{main::key($num++,1,2,'Type')} = $key;
- $rows[$j]->{main::key($num++,0,3,$cpu->{'bugs-hash'}->{$key}[0])} = $cpu->{'bugs-hash'}->{$key}[1];
+ $rows->[$j]{main::key($num++,1,2,'Type')} = $key;
+ $rows->[$j]{main::key($num++,0,3,$cpu->{'bugs-hash'}->{$key}[0])} = $cpu->{'bugs-hash'}->{$key}[1];
$j++;
}
}
}
eval $end if $b_log;
- return @rows;
}
# $num, $rows passed by reference
sub full_output_caches {
@@ -8890,9 +8930,9 @@ sub full_output_caches {
!$properties->{'l3-cache'}){
$value = ($properties->{'cache'}) ? $properties->{'cache'} : 'N/A';
}
- $$rows[$j]->{main::key($$num++,1,2,'cache')} = $value;
+ $rows->[$j]{main::key($$num++,1,2,'cache')} = $value;
if ($extra > 0 && $properties->{'l1-cache'}){
- $$rows[$j]->{main::key($$num++,2,3,'L1')} = $properties->{'l1-cache'};
+ $rows->[$j]{main::key($$num++,2,3,'L1')} = $properties->{'l1-cache'};
if ($b_admin && ($properties->{'l1d-desc'} || $properties->{'l1i-desc'})){
my $desc = '';
if ($properties->{'l1d-desc'}){
@@ -8902,62 +8942,60 @@ sub full_output_caches {
$desc .= '; ' if $desc;
$desc .= 'i-' . $properties->{'l1i-desc'};
}
- $$rows[$j]->{main::key($$num++,0,4,'desc')} = $desc;
+ $rows->[$j]{main::key($$num++,0,4,'desc')} = $desc;
}
}
- # $$rows[$j]->{main::key($$num++,1,$l,$key)} = $support;
+ # $rows->[$j]{main::key($$num++,1,$l,$key)} = $support;
if (!$value){
$properties->{'l2-cache'} = ($properties->{'l2-cache'}) ? $properties->{'l2-cache'} : 'N/A';
- $$rows[$j]->{main::key($$num++,1,3,'L2')} = $properties->{'l2-cache'};
+ $rows->[$j]{main::key($$num++,1,3,'L2')} = $properties->{'l2-cache'};
if ($b_admin && $properties->{'l2-desc'}){
- $$rows[$j]->{main::key($$num++,0,4,'desc')} = $properties->{'l2-desc'};
+ $rows->[$j]{main::key($$num++,0,4,'desc')} = $properties->{'l2-desc'};
}
}
if ($extra > 0 && $properties->{'l3-cache'}){
- $$rows[$j]->{main::key($$num++,1,3,'L3')} = $properties->{'l3-cache'};
+ $rows->[$j]{main::key($$num++,1,3,'L3')} = $properties->{'l3-cache'};
if ($b_admin && $properties->{'l3-desc'}){
- $$rows[$j]->{main::key($$num++,0,4,'desc')} = $properties->{'l3-desc'};
+ $rows->[$j]{main::key($$num++,0,4,'desc')} = $properties->{'l3-desc'};
}
}
if ($properties->{'cache-check'}){
- $$rows[$j]->{main::key($$num++,0,3,'note')} = $properties->{'cache-check'};
+ $rows->[$j]{main::key($$num++,0,3,'note')} = $properties->{'cache-check'};
}
eval $end if $b_log;
}
sub short_output {
eval $start if $b_log;
- my ($cpu) = @_;
- my @data;
+ my ($rows,$cpu) = @_;
my $num = 0;
$cpu->[1] ||= main::message('cpu-model-null');
$cpu->[2] ||= 'N/A';
- @data = ({
- main::key($num++,1,1,'Info') => $cpu->[0] . ' ' . $cpu->[1] . ' [' . $cpu->[2] . ']',
+ push(@$rows,{
+ main::key($num++,1,1,'Info') => $cpu->[0] . ' ' . $cpu->[1] . ' [' . $cpu->[2] . ']'
#main::key($num++,0,2,'type') => $cpu->[2],
- },);
+ });
if ($extra > 0){
- $data[0]->{main::key($num++,1,2,'arch')} = $cpu->[8];
+ $rows->[0]{main::key($num++,1,2,'arch')} = $cpu->[8];
if ($cpu->[9]){
- $data[0]->{main::key($num++,0,3,'note')} = $cpu->[9];
+ $rows->[0]{main::key($num++,0,3,'note')} = $cpu->[9];
}
}
my $value = ($cpu->[7]) ? '' : $cpu->[4];
- $data[0]->{main::key($num++,1,2,$cpu->[3])} = $value;
+ $rows->[0]{main::key($num++,1,2,$cpu->[3])} = $value;
if ($cpu->[7]){
- $data[0]->{main::key($num++,0,3,$cpu->[7])} = $cpu->[4];
+ $rows->[0]{main::key($num++,0,3,$cpu->[7])} = $cpu->[4];
}
if ($cpu->[6]){
- $data[0]->{main::key($num++,0,3,$cpu->[5])} = $cpu->[6];
+ $rows->[0]{main::key($num++,0,3,$cpu->[5])} = $cpu->[6];
}
eval $end if $b_log;
- return @data;
}
## SHORT OUTPUT DATA ##
sub short_data {
eval $start if $b_log;
my $num = 0;
- my ($cpu,@data,%speeds);
+ my ($cpu,$data,%speeds);
my $sys = '/sys/devices/system/cpu/cpufreq/policy0';
# NOTE: : Permission denied, ie, this is not always readable
# /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
@@ -8975,15 +9013,15 @@ sub short_data {
else {
$key1 = ucfirst($alerts{'sysctl'}->{'action'});
$val1 = $alerts{'sysctl'}->{'message'};
- @data = ({main::key($num++,0,1,$key1) => $val1,});
- return @data;
+ $data = ({main::key($num++,0,1,$key1) => $val1,});
+ return $data;
}
}
}
# $cpu{'cur-freq'} = $cpu[0]->{'core-id'}[0]{'speed'};
- @data = prep_short_data($cpu);
+ $data = prep_short_data($cpu);
eval $end if $b_log;
- return @data;
+ return $data;
}
sub prep_short_data {
eval $start if $b_log;
@@ -8994,7 +9032,7 @@ sub prep_short_data {
$type = $properties->{'cpu-type'} if $properties->{'cpu-type'};
$speed_key = $properties->{'speed-key'} if $properties->{'speed-key'};
$speed = $properties->{'speed'} if $properties->{'speed'};
- my @result = (
+ my $result = [
$properties->{'topology-string'},
$cpu,
$type,
@@ -9003,23 +9041,23 @@ sub prep_short_data {
$properties->{'min-max-key'},
$properties->{'min-max'},
$properties->{'avg-speed-key'},
- );
+ ];
if ($extra > 0){
$cpu_data->{'arch'} ||= 'N/A';
- $result[8] = $cpu_data->{'arch'};
- $result[9] = $cpu_data->{'arch-note'};
+ $result->[8] = $cpu_data->{'arch'};
+ $result->[9] = $cpu_data->{'arch-note'};
}
eval $end if $b_log;
- return @result;
+ return $result;
}
## PRIMARY DATA GENERATORS ##
sub cpuinfo_data {
eval $start if $b_log;
my ($file)= @_;
- my ($arch,$note,$temp);
+ my ($cpu,$arch,$note,$temp);
# has to be set above fake cpu section
- my %cpu = set_cpu_data();
+ set_cpu_data(\$cpu);
# sleep is also set in front of sysctl_data for BSDs, same idea
my $sleep = $cpu_sleep * 1000000;
if ($b_hires){
@@ -9067,11 +9105,11 @@ sub cpuinfo_data {
foreach (keys %working){
$freq{sprintf("%04d",$_)} = $working{$_}->[1] if defined $working{$_}->[0];
}
- $cpu{'sys-freq'} = \%freq if %freq;
+ $cpu->{'sys-freq'} = \%freq if %freq;
}
}
- cpuinfo_data_grabber($file,\$cpu{'type'}) if !$loaded{'cpuinfo'};
- $cpu{'type'} = cpu_vendor($cpu_arch) if $cpu_arch eq 'elbrus'; # already set to lower
+ cpuinfo_data_grabber($file,\$cpu->{'type'}) if !$loaded{'cpuinfo'};
+ $cpu->{'type'} = cpu_vendor($cpu_arch) if $cpu_arch eq 'elbrus'; # already set to lower
my ($core_count,$proc_count,$speed) = (0,0,0);
my ($b_block_1) = (1);
# need to prime for arm cpus, which do not have physical/core ids usually
@@ -9082,32 +9120,32 @@ sub cpuinfo_data {
next if !$block;
if ($b_block_1){
$b_block_1 = 0;
- if (!$cpu{'type'} && $block->{'vendor_id'}){
- $cpu{'type'} = cpu_vendor($block->{'vendor_id'});
+ if (!$cpu->{'type'} && $block->{'vendor_id'}){
+ $cpu->{'type'} = cpu_vendor($block->{'vendor_id'});
}
# PPC can use 'cpu', MIPS 'cpu model'
$temp = main::get_defined($block->{'model name'},$block->{'cpu'},
$block->{'cpu model'});
if ($temp){
- $cpu{'model_name'} = $temp;
- $cpu{'model_name'} = main::clean($cpu{'model_name'});
- $cpu{'model_name'} = clean_cpu($cpu{'model_name'});
- if ($risc{'arm'} || $cpu{'model_name'} =~ /ARM|AArch/i){
- $cpu{'type'} = 'arm';
- if ($cpu{'model_name'} =~ /(.*)\srev\s([\S]+)\s(\(([\S]+)\))?/){
- $cpu{'model_name'} = $1;
- $cpu{'stepping'} = $2;
+ $cpu->{'model_name'} = $temp;
+ $cpu->{'model_name'} = main::clean($cpu->{'model_name'});
+ $cpu->{'model_name'} = clean_cpu($cpu->{'model_name'});
+ if ($risc{'arm'} || $cpu->{'model_name'} =~ /ARM|AArch/i){
+ $cpu->{'type'} = 'arm';
+ if ($cpu->{'model_name'} =~ /(.*)\srev\s([\S]+)\s(\(([\S]+)\))?/){
+ $cpu->{'model_name'} = $1;
+ $cpu->{'stepping'} = $2;
if ($4){
- $cpu{'arch'} = $4;
- if ($cpu{'model_name'} !~ /\Q$cpu{'arch'}\E/i){
- $cpu{'model_name'} .= ' ' . $cpu{'arch'};
+ $cpu->{'arch'} = $4;
+ if ($cpu->{'model_name'} !~ /\Q$cpu->{'arch'}\E/i){
+ $cpu->{'model_name'} .= ' ' . $cpu->{'arch'};
}
}
# print "p0:\n";
}
}
- elsif ($risc{'mips'} || $cpu{'model_name'} =~ /mips/i){
- $cpu{'type'} = 'mips';
+ elsif ($risc{'mips'} || $cpu->{'model_name'} =~ /mips/i){
+ $cpu->{'type'} = 'mips';
}
}
$temp = main::get_defined($block->{'architecture'},
@@ -9115,38 +9153,38 @@ sub cpuinfo_data {
if ($temp){
if ($temp =~ /^\d+$/){
# translate integers to hex
- $cpu{'family'} = uc(sprintf("%x",$temp));
+ $cpu->{'family'} = uc(sprintf("%x",$temp));
}
elsif ($risc{'arm'}){
- $cpu{'arch'} = $temp;
+ $cpu->{'arch'} = $temp;
}
}
# note: stepping and ARM cpu revision are integers
$temp = main::get_defined($block->{'stepping'},$block->{'cpu revision'});
# can be 0, but can be 'unknown'
if (defined $temp ||
- ($cpu{'type'} eq 'elbrus' && defined $block->{'revision'})){
+ ($cpu->{'type'} eq 'elbrus' && defined $block->{'revision'})){
$temp = $block->{'revision'} if defined $block->{'revision'};
if ($temp =~ /^\d+$/){
- $cpu{'stepping'} = uc(sprintf("%x",$temp));
+ $cpu->{'stepping'} = uc(sprintf("%x",$temp));
}
}
# PPC revision is a string, but elbrus revision is hex
elsif (defined $block->{'revision'}){
- $cpu{'revision'} = $block->{'revision'};
+ $cpu->{'revision'} = $block->{'revision'};
}
# this is hex so uc for cpu arch id. raspi 4 has Model rather than Hardware
if (defined $block->{'model'}){
# can be 0, but can be 'unknown'
- $cpu{'model-id'} = uc(sprintf("%x",$block->{'model'}));
+ $cpu->{'model-id'} = uc(sprintf("%x",$block->{'model'}));
}
if ($block->{'cpu variant'}){
- $cpu{'model-id'} = uc($block->{'cpu variant'});
- $cpu{'model-id'} =~ s/^0X//;
+ $cpu->{'model-id'} = uc($block->{'cpu variant'});
+ $cpu->{'model-id'} =~ s/^0X//;
}
# this is per cpu, not total if > 1 pys cpus
- if (!$cpu{'cores'} && $block->{'cpu cores'}){
- $cpu{'cores'} = $block->{'cpu cores'};
+ if (!$cpu->{'cores'} && $block->{'cpu cores'}){
+ $cpu->{'cores'} = $block->{'cpu cores'};
}
## this is only for -C full cpu output
if ($type eq 'full'){
@@ -9154,37 +9192,37 @@ sub cpuinfo_data {
# L2, or L3, but never all of them added togehter, so give up.
if ($block->{'cache size'} &&
$block->{'cache size'} =~ /(\d+\s*[KMG])i?B?$/){
- $cpu{'cache'} = main::translate_size($1);
+ $cpu->{'cache'} = main::translate_size($1);
}
if ($block->{'l1 cache size'} &&
$block->{'l1 cache size'} =~ /(\d+\s*[KMG])i?B?$/){
- $cpu{'l1-cache'} = main::translate_size($1);
+ $cpu->{'l1-cache'} = main::translate_size($1);
}
if ($block->{'l2 cache size'} &&
$block->{'l2 cache size'} =~ /(\d+\s*[KMG])i?B?$/){
- $cpu{'l2-cache'} = main::translate_size($1);
+ $cpu->{'l2-cache'} = main::translate_size($1);
}
if ($block->{'l3 cache size'} &&
$block->{'l3 cache size'} =~ /(\d+\s*[KMG])i?B?$/){
- $cpu{'l3-cache'} = main::translate_size($1);
+ $cpu->{'l3-cache'} = main::translate_size($1);
}
$temp = main::get_defined($block->{'flags'} || $block->{'features'});
if ($temp){
- $cpu{'flags'} = $temp;
+ $cpu->{'flags'} = $temp;
}
if ($b_admin){
# note: not used unless maybe /sys data missing?
if ($block->{'bugs'}){
- $cpu{'bugs-string'} = $block->{'bugs'};
+ $cpu->{'bugs-string'} = $block->{'bugs'};
}
# unlike family and model id, microcode appears to be hex already
if ($block->{'microcode'}){
if ($block->{'microcode'} =~ /0x/){
- $cpu{'microcode'} = uc($block->{'microcode'});
- $cpu{'microcode'} =~ s/^0X//;
+ $cpu->{'microcode'} = uc($block->{'microcode'});
+ $cpu->{'microcode'} =~ s/^0X//;
}
else {
- $cpu{'microcode'} = uc(sprintf("%x",$block->{'microcode'}));
+ $cpu->{'microcode'} = uc(sprintf("%x",$block->{'microcode'}));
}
}
}
@@ -9192,49 +9230,49 @@ sub cpuinfo_data {
}
# These occurs in a separate block with E2C3, last in cpuinfo blocks,
# otherwise per block in E8C variants
- if ($cpu{'type'} eq 'elbrus' && (!$cpu{'l1i-cache'} &&
- !$cpu{'l1d-cache'} && !$cpu{'l2-cache'} && !$cpu{'l3-cache'})){
+ if ($cpu->{'type'} eq 'elbrus' && (!$cpu->{'l1i-cache'} &&
+ !$cpu->{'l1d-cache'} && !$cpu->{'l2-cache'} && !$cpu->{'l3-cache'})){
# note: cache0 is L1i and cache1 L1d. cp_caches_fallback handles
if ($block->{'cache0'} &&
$block->{'cache0'} =~ /size\s*=\s*(\d+)K\s/){
- $cpu{'l1i-cache'} = $1;
+ $cpu->{'l1i-cache'} = $1;
}
if ($block->{'cache1'} &&
$block->{'cache1'} =~ /size\s*=\s*(\d+)K\s/){
- $cpu{'l1d-cache'} = $1;
+ $cpu->{'l1d-cache'} = $1;
}
if ($block->{'cache2'} &&
$block->{'cache2'} =~ /size\s*=\s*(\d+)(K|M)\s/){
- $cpu{'l2-cache'} = ($2 eq 'M') ? ($1*1024) : $1;
+ $cpu->{'l2-cache'} = ($2 eq 'M') ? ($1*1024) : $1;
}
if ($block->{'cache3'} &&
$block->{'cache3'} =~ /size\s*=\s*(\d+)(K|M)\s/){
- $cpu{'l3-cache'} = ($2 eq 'M') ? ($1*1024) : $1;
+ $cpu->{'l3-cache'} = ($2 eq 'M') ? ($1*1024) : $1;
}
}
## Start incrementers
$temp = main::get_defined($block->{'cpu mhz'},$block->{'clock'});
if ($temp){
$speed = clean_speed($temp);
- push(@{$cpu{'processors'}},$speed);
+ push(@{$cpu->{'processors'}},$speed);
}
# new arm shows bad bogomip value, so don't use it, however, ancient
# cpus, intel 486, can have super low bogomips, like 33.17
if ($extra > 0 && $block->{'bogomips'} && ((%risc &&
$block->{'bogomips'} > 50) || !%risc)){
- $cpu{'bogomips'} += $block->{'bogomips'};
+ $cpu->{'bogomips'} += $block->{'bogomips'};
}
# just to get core counts for ARM/MIPS/PPC systems
if (defined $block->{'processor'} && !$temp){
if ($block->{'processor'} =~ /^\d+$/){
- push(@{$cpu{'processors'}},0);
+ push(@{$cpu->{'processors'}},0);
}
}
# note: for alder lake, could vary, depending on if e or p core but we
# only care aobut the highest value for crude logic here
if ($block->{'siblings'} &&
- (!$cpu{'siblings'} || $block->{'siblings'} > $cpu{'siblings'})){
- $cpu{'siblings'} = $block->{'siblings'};
+ (!$cpu->{'siblings'} || $block->{'siblings'} > $cpu->{'siblings'})){
+ $cpu->{'siblings'} = $block->{'siblings'};
}
# Ignoring trying to catch dies with $block->{'physical id'},
# that's too buggy for cpuinfo
@@ -9242,26 +9280,26 @@ sub cpuinfo_data {
# https://www.pcworld.com/article/3214635/components-processors/ryzen-threadripper-review-we-test-amds-monster-cpu.html
my $phys = (defined $block->{'physical id'}) ? $block->{'physical id'}: 0;
my $die_id = 0;
- if (!grep {$_ eq $block->{'core id'}} @{$cpu{'ids'}->[$phys][$die_id]}){
- push(@{$cpu{'ids'}->[$phys][$die_id]},$block->{'core id'});
+ if (!grep {$_ eq $block->{'core id'}} @{$cpu->{'ids'}->[$phys][$die_id]}){
+ push(@{$cpu->{'ids'}->[$phys][$die_id]},$block->{'core id'});
}
}
}
undef @cpuinfo; # we're done with it, dump it
undef %cpuinfo_machine;
if (%risc){
- if (!$cpu{'type'}){
- $cpu{'type'} = $risc{'id'};
+ if (!$cpu->{'type'}){
+ $cpu->{'type'} = $risc{'id'};
}
if (!$bsd_type){
my $system_cpus = system_cpu_name();
- $cpu{'system-cpus'} = $system_cpus if %$system_cpus;
+ $cpu->{'system-cpus'} = $system_cpus if %$system_cpus;
}
}
- main::log_data('dump','%cpu',\%cpu) if $b_log;
- print Data::Dumper::Dumper \%cpu if $dbg[8];
+ main::log_data('dump','%$cpu',$cpu) if $b_log;
+ print Data::Dumper::Dumper $cpu if $dbg[8];
eval $end if $b_log;
- return \%cpu;
+ return $cpu;
}
sub cpuinfo_data_grabber {
eval $start if $b_log;
@@ -9270,61 +9308,61 @@ sub cpuinfo_data_grabber {
# use --arm flag when testing arm cpus, and --fake-cpu to trigger fake data
if ($fake{'cpu'}){
## CPU sys/cpuinfo pairs:
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/android-pocom3-fake-cpuinfo.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/arm-pine64-cpuinfo-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/arm-riscyslack2-cpuinfo-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/ppc-stuntkidz~cpuinfo.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/riscv-unmatched-2021~cpuinfo-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-brickwizard-atom-n270~cpuinfo-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-amd-phenom-chrisretusn-cpuinfo-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-drgibbon-intel-i7-cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/android-pocom3-fake-cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/arm-pine64-cpuinfo-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/arm-riscyslack2-cpuinfo-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/ppc-stuntkidz~cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/riscv-unmatched-2021~cpuinfo-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-brickwizard-atom-n270~cpuinfo-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-amd-phenom-chrisretusn-cpuinfo-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-drgibbon-intel-i7-cpuinfo.txt";
## ARM/MIPS
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/arm-4-core-pinebook-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/armv6-single-core-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/armv7-dual-core-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/armv7-new-format-model-name-single-core.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/arm-2-die-96-core-rk01.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/arm/arm-shevaplug-1.2ghz.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/mips/mips-mainusg-cpuinfo.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/ppc/ppc-debian-ppc64-cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/arm/arm-4-core-pinebook-1.txt";
+ # $file = "$fake_data_dir/cpu/arm/armv6-single-core-1.txt";
+ # $file = "$fake_data_dir/cpu/arm/armv7-dual-core-1.txt";
+ # $file = "$fake_data_dir/cpu/arm/armv7-new-format-model-name-single-core.txt";
+ # $file = "$fake_data_dir/cpu/arm/arm-2-die-96-core-rk01.txt";
+ # $file = "$fake_data_dir/cpu/arm/arm-shevaplug-1.2ghz.txt";
+ # $file = "$fake_data_dir/cpu/mips/mips-mainusg-cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/ppc/ppc-debian-ppc64-cpuinfo.txt";
## x86
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/16-core-32-mt-ryzen.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/2-16-core-epyc-abucodonosor.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/2-core-probook-antix.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/4-core-jean-antix.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/4-core-althlon-mjro.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/4-core-apu-vc-box.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/amd/4-core-a10-5800k-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/1-core-486-fourtysixandtwo.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/2-core-ht-atom-bruh.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/core-2-i3.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/8-core-i7-damentz64.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/2-10-core-xeon-ht.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/4-core-xeon-fake-dual-die-zyanya.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/2-core-i5-fake-dual-die-hek.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/2-1-core-xeon-vm-vs2017.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/4-1-core-xeon-vps-frodo1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/intel/4-6-core-xeon-no-mt-lathander.txt";
+ # $file = "$fake_data_dir/cpu/amd/16-core-32-mt-ryzen.txt";
+ # $file = "$fake_data_dir/cpu/amd/2-16-core-epyc-abucodonosor.txt";
+ # $file = "$fake_data_dir/cpu/amd/2-core-probook-antix.txt";
+ # $file = "$fake_data_dir/cpu/amd/4-core-jean-antix.txt";
+ # $file = "$fake_data_dir/cpu/amd/4-core-althlon-mjro.txt";
+ # $file = "$fake_data_dir/cpu/amd/4-core-apu-vc-box.txt";
+ # $file = "$fake_data_dir/cpu/amd/4-core-a10-5800k-1.txt";
+ # $file = "$fake_data_dir/cpu/intel/1-core-486-fourtysixandtwo.txt";
+ # $file = "$fake_data_dir/cpu/intel/2-core-ht-atom-bruh.txt";
+ # $file = "$fake_data_dir/cpu/intel/core-2-i3.txt";
+ # $file = "$fake_data_dir/cpu/intel/8-core-i7-damentz64.txt";
+ # $file = "$fake_data_dir/cpu/intel/2-10-core-xeon-ht.txt";
+ # $file = "$fake_data_dir/cpu/intel/4-core-xeon-fake-dual-die-zyanya.txt";
+ # $file = "$fake_data_dir/cpu/intel/2-core-i5-fake-dual-die-hek.txt";
+ # $file = "$fake_data_dir/cpu/intel/2-1-core-xeon-vm-vs2017.txt";
+ # $file = "$fake_data_dir/cpu/intel/4-1-core-xeon-vps-frodo1.txt";
+ # $file = "$fake_data_dir/cpu/intel/4-6-core-xeon-no-mt-lathander.txt";
## Elbrus
- # $$cpu_type = 'elbrus'; # uncomment to test elbrus
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/elbrus-2c3/cpuinfo.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/1xE1C-8.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/1xE2CDSP-4.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/1xE2S4-3-monocub.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/1xMBE8C-7.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/4xEL2S4-3.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/4xE8C-7.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/4xE2CDSP-4.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/elbrus/cpuinfo.e8c2.txt";
- }
- my @raw = main::reader($file);
- @raw = map {$_ =~ s/^\s*$/~~~/;$_;} @raw;
- push(@raw,'~~~') if @raw;
+ # $cpu_type = 'elbrus'; # uncomment to test elbrus
+ # $file = "$fake_data_dir/cpu/elbrus/elbrus-2c3/cpuinfo.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/1xE1C-8.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/1xE2CDSP-4.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/1xE2S4-3-monocub.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/1xMBE8C-7.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/4xEL2S4-3.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/4xE8C-7.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/4xE2CDSP-4.txt";
+ # $file = "$fake_data_dir/cpu/elbrus/cpuinfo.e8c2.txt";
+ }
+ my $raw = main::reader($file,'','ref');
+ @$raw = map {$_ =~ s/^\s*$/~~~/;$_;} @$raw;
+ push(@$raw,'~~~') if @$raw;
my ($b_processor,$key,$value);
my ($i) = (0);
my @key_tests = ('firmware','hardware','mmu','model','motherboard',
'platform','system type','timebase');
- foreach my $row (@raw){
+ foreach my $row (@$raw){
($key,$value) = split(/\s*:\s*/,$row,2);
next if !defined $key;
# ARM: 'Hardware' can appear in processor block; system type (mips)
@@ -9366,10 +9404,10 @@ sub cpuinfo_data_grabber {
sub cpu_sys_data {
eval $start if $b_log;
my $sys_freq = $_[0];
- my (%cpu_sys);
+ my $cpu_sys = {};
my $working = sys_data_grabber();
- return \%cpu_sys if !%{$working};
- $cpu_sys{'data'} = $working->{'data'} if $working->{'data'};
+ return $cpu_sys if !%$working;
+ $cpu_sys->{'data'} = $working->{'data'} if $working->{'data'};
my ($core_id,$fake_core_id,$phys_id,) = (0,0,-1);
my (%cache_ids,@ci_freq_max,@ci_freq_min,@sc_freq_max,@sc_freq_min);
foreach my $key (sort keys %{$working->{'cpus'}}){
@@ -9394,14 +9432,14 @@ sub cpu_sys_data {
$speed = $sys_freq->{$key};
}
if (defined $speed){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'cores'}{$core_id}},$speed);
- push(@{$cpu_sys{'data'}->{'speeds'}{'all'}},$speed);
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'cores'}{$core_id}},$speed);
+ push(@{$cpu_sys->{'data'}{'speeds'}{'all'}},$speed);
}
else {
- push(@{$cpu_sys{'data'}->{'speeds'}{'all'}},0);
+ push(@{$cpu_sys->{'data'}{'speeds'}{'all'}},0);
# seen cases, riscv, where core id, phys id, are all -1
my $id = ($core_id != -1) ? $core_id: $fake_core_id++;
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'cores'}{$id}},0);
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'cores'}{$id}},0);
}
# Only use if topology core-id exists, some virtualized cpus can list
# frequency data for the non available cores, but those do not show
@@ -9412,8 +9450,8 @@ sub cpu_sys_data {
if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @ci_freq_max){
push(@ci_freq_max,$cpu->{'cpufreq'}{'cpuinfo_max_freq'});
}
- if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'cpuinfo_max_freq'});
+ if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'cpuinfo_max_freq'});
}
}
if (defined $cpu->{'cpufreq'}{'cpuinfo_min_freq'}){
@@ -9421,8 +9459,8 @@ sub cpu_sys_data {
if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @ci_freq_min){
push(@ci_freq_min,$cpu->{'cpufreq'}{'cpuinfo_min_freq'});
}
- if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'cpuinfo_min_freq'});
+ if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'cpuinfo_min_freq'});
}
}
if (defined $cpu->{'cpufreq'}{'scaling_max_freq'}){
@@ -9430,8 +9468,8 @@ sub cpu_sys_data {
if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @sc_freq_max){
push(@sc_freq_max,$cpu->{'cpufreq'}{'scaling_max_freq'});
}
- if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'scaling_max_freq'});
+ if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'scaling_max_freq'});
}
}
if (defined $cpu->{'cpufreq'}{'scaling_min_freq'}){
@@ -9439,21 +9477,21 @@ sub cpu_sys_data {
if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @sc_freq_min){
push(@sc_freq_min,$cpu->{'cpufreq'}{'scaling_min_freq'});
}
- if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'scaling_min_freq'});
+ if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'scaling_min_freq'});
}
}
if (defined $cpu->{'cpufreq'}{'scaling_governor'}){
- if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_governor'}} @{$cpu_sys{'cpus'}->{$phys_id}{'governor'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'governor'}},$cpu->{'cpufreq'}{'scaling_governor'});
+ if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_governor'}} @{$cpu_sys->{'cpus'}{$phys_id}{'governor'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'governor'}},$cpu->{'cpufreq'}{'scaling_governor'});
}
}
if (defined $cpu->{'cpufreq'}{'scaling_driver'}){
- $cpu_sys{'cpus'}->{$phys_id}{'scaling-driver'} = $cpu->{'cpufreq'}{'scaling_driver'};
+ $cpu_sys->{'cpus'}{$phys_id}{'scaling-driver'} = $cpu->{'cpufreq'}{'scaling_driver'};
}
}
- if (!defined $cpu_sys{'data'}->{'cpufreq-boost'} && defined $cpu->{'cpufreq'}{'cpb'}){
- $cpu_sys{'data'}->{'cpufreq-boost'} = $cpu->{'cpufreq'}{'cpb'};
+ if (!defined $cpu_sys->{'data'}{'cpufreq-boost'} && defined $cpu->{'cpufreq'}{'cpb'}){
+ $cpu_sys->{'data'}{'cpufreq-boost'} = $cpu->{'cpufreq'}{'cpb'};
}
if (defined $cpu->{'topology'}{'core_cpus_list'}){
$cpu->{'topology'}{'thread_siblings_list'} = $cpu->{'topology'}{'core_cpus_list'};
@@ -9475,7 +9513,7 @@ sub cpu_sys_data {
# print "cpuid: $cpu_id phys-core: $phys_id-$core_id level: $level range: $range shared: $cache->{'shared_cpu_list'}\n";
if (!(grep {$_ eq $cache->{'shared_cpu_list'}} @{$cache_ids{$phys_id}->{$level}})){
push(@{$cache_ids{$phys_id}->{$level}},$cache->{'shared_cpu_list'});
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'caches'}{$level}},$size);
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'caches'}{$level}},$size);
}
}
}
@@ -9485,53 +9523,53 @@ sub cpu_sys_data {
defined $cpu->{'topology'}{'core_siblings_list'}){
my $die = $cpu->{'topology'}{'die_id'};
$die = $cpu->{'topology'}{'core_siblings_list'} if !defined $die;
- if (!grep {$_ eq $die} @{$cpu_sys{'cpus'}->{$phys_id}{'dies'}}){
- push(@{$cpu_sys{'cpus'}->{$phys_id}{'dies'}},$die);
+ if (!grep {$_ eq $die} @{$cpu_sys->{'cpus'}{$phys_id}{'dies'}}){
+ push(@{$cpu_sys->{'cpus'}{$phys_id}{'dies'}},$die);
}
}
}
- if (defined $cpu_sys{'data'}->{'cpufreq-boost'} &&
- $cpu_sys{'data'}->{'cpufreq-boost'} =~ /^[01]$/){
- if ($cpu_sys{'data'}->{'cpufreq-boost'}){
- $cpu_sys{'data'}->{'cpufreq-boost'} = 'enabled';
+ if (defined $cpu_sys->{'data'}{'cpufreq-boost'} &&
+ $cpu_sys->{'data'}{'cpufreq-boost'} =~ /^[01]$/){
+ if ($cpu_sys->{'data'}{'cpufreq-boost'}){
+ $cpu_sys->{'data'}{'cpufreq-boost'} = 'enabled';
}
else {
- $cpu_sys{'data'}->{'cpufreq-boost'} = 'disabled';
+ $cpu_sys->{'data'}{'cpufreq-boost'} = 'disabled';
}
}
# cpuinfo_max_freq:["2000000"] cpuinfo_max_freq:["1500000"]
# cpuinfo_min_freq:["200000"]
if (@ci_freq_max){
- $cpu_sys{'data'}->{'speeds'}{'max-freq'} = join(':',@ci_freq_max);
+ $cpu_sys->{'data'}{'speeds'}{'max-freq'} = join(':',@ci_freq_max);
}
if (@ci_freq_min){
- $cpu_sys{'data'}->{'speeds'}{'min-freq'} = join(':',@ci_freq_min);
+ $cpu_sys->{'data'}{'speeds'}{'min-freq'} = join(':',@ci_freq_min);
}
# also handle off chance that cpuinfo_min/max not set, but scaling_min/max there
if (@sc_freq_max){
- $cpu_sys{'data'}->{'speeds'}{'scaling-max-freq'} = join(':',@sc_freq_max);
- if (!$cpu_sys{'data'}->{'speeds'}{'max-freq'}){
- $cpu_sys{'data'}->{'speeds'}{'max-freq'} = $cpu_sys{'data'}->{'speeds'}{'scaling-max-freq'};
+ $cpu_sys->{'data'}{'speeds'}{'scaling-max-freq'} = join(':',@sc_freq_max);
+ if (!$cpu_sys->{'data'}{'speeds'}{'max-freq'}){
+ $cpu_sys->{'data'}{'speeds'}{'max-freq'} = $cpu_sys->{'data'}{'speeds'}{'scaling-max-freq'};
}
}
if (@sc_freq_min){
- $cpu_sys{'data'}->{'speeds'}{'scaling-min-freq'} = join(':',@sc_freq_min);
- if (!$cpu_sys{'data'}->{'speeds'}{'min-freq'}){
- $cpu_sys{'data'}->{'speeds'}{'min-freq'} = $cpu_sys{'data'}->{'speeds'}{'scaling-min-freq'};
+ $cpu_sys->{'data'}{'speeds'}{'scaling-min-freq'} = join(':',@sc_freq_min);
+ if (!$cpu_sys->{'data'}{'speeds'}{'min-freq'}){
+ $cpu_sys->{'data'}{'speeds'}{'min-freq'} = $cpu_sys->{'data'}{'speeds'}{'scaling-min-freq'};
}
}
# this corrects a bug we see sometimes in min/max frequencies
if ((scalar @ci_freq_max < 2 && scalar @ci_freq_min < 2) &&
- (defined $cpu_sys{'data'}->{'speeds'}{'min-freq'} &&
- defined $cpu_sys{'data'}->{'speeds'}{'max-freq'}) &&
- ($cpu_sys{'data'}->{'speeds'}{'min-freq'} > $cpu_sys{'data'}->{'speeds'}{'max-freq'} ||
- $cpu_sys{'data'}->{'speeds'}{'min-freq'} == $cpu_sys{'data'}->{'speeds'}{'max-freq'})){
- $cpu_sys{'data'}->{'speeds'}{'min-freq'} = 0;
+ (defined $cpu_sys->{'data'}{'speeds'}{'min-freq'} &&
+ defined $cpu_sys->{'data'}{'speeds'}{'max-freq'}) &&
+ ($cpu_sys->{'data'}{'speeds'}{'min-freq'} > $cpu_sys->{'data'}{'speeds'}{'max-freq'} ||
+ $cpu_sys->{'data'}{'speeds'}{'min-freq'} == $cpu_sys->{'data'}{'speeds'}{'max-freq'})){
+ $cpu_sys->{'data'}{'speeds'}{'min-freq'} = 0;
}
- main::log_data('dump','%cpu_sys',\%cpu_sys) if $b_log;
- print Data::Dumper::Dumper \%cpu_sys if $dbg[8];
+ main::log_data('dump','%$cpu_sys',$cpu_sys) if $b_log;
+ print Data::Dumper::Dumper $cpu_sys if $dbg[8];
eval $end if $b_log;
- return \%cpu_sys;
+ return $cpu_sys;
}
sub sys_data_grabber {
eval $start if $b_log;
@@ -9541,14 +9579,14 @@ sub sys_data_grabber {
if ($fake{'cpu'}){
# my $file;
## CPU sys/cpuinfo pairs:
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/android-pocom3-fake-sys.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/arm-pine64-sys-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/arm-riscyslack2-sys-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/ppc-stuntkidz~sys.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/riscv-unmatched-2021~sys-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-brickwizard-atom-n270~sys-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-amd-phenom-chrisretusn-sys-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/cpu/sys-ci-pairs/x86-drgibbon-intel-i7-sys.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/android-pocom3-fake-sys.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/arm-pine64-sys-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/arm-riscyslack2-sys-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/ppc-stuntkidz~sys.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/riscv-unmatched-2021~sys-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-brickwizard-atom-n270~sys-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-amd-phenom-chrisretusn-sys-1.txt";
+ # $file = "$fake_data_dir/cpu/sys-ci-pairs/x86-drgibbon-intel-i7-sys.txt";
# @files = main::reader($file);
}
# There's a massive time hit reading full globbed set of files, so grab and
@@ -9577,10 +9615,11 @@ sub sys_data_grabber {
}
main::log_data('dump','@files',\@files) if $b_log;
print Data::Dumper::Dumper \@files if $dbg[40];
- my ($b_bug,$b_cache,$b_freq,$b_topo,$b_main,%working);
+ my ($b_bug,$b_cache,$b_freq,$b_topo,$b_main);
+ my $working = {};
my ($main_id,$main_key,$holder,$id,$item,$key) = ('','','','','','');
# need to return hash reference on failure or old systems complain
- return \%working if !@files;
+ return $working if !@files;
foreach (sort @files){
if ($fake{'cpu'}){
($_,$item) = split(/::/,$_,2);
@@ -9660,31 +9699,31 @@ sub sys_data_grabber {
}
# print "$key_1 :: $key_2 :: $item\n";
if ($b_main){
- $working{'data'}->{$id} = $item;
+ $working->{'data'}{$id} = $item;
}
elsif ($b_bug){
my $type = ($item =~ /^Mitigation:/) ? 'mitigation': 'status';
$item =~ s/Mitigation: //;
- $working{'data'}->{$id}{$key} = [$type,$item];
+ $working->{'data'}{$id}{$key} = [$type,$item];
}
elsif ($b_cache){
- $working{'cpus'}->{$id}{$key}{$main_id}{$main_key} = $item;
+ $working->{'cpus'}{$id}{$key}{$main_id}{$main_key} = $item;
}
elsif ($b_freq || $b_topo){
- $working{'cpus'}->{$id}{$key}{$main_key} = $item;
+ $working->{'cpus'}{$id}{$key}{$main_key} = $item;
}
}
- main::log_data('dump','%working',\%working) if $b_log;
- print Data::Dumper::Dumper \%working if $dbg[39];
+ main::log_data('dump','%$working',$working) if $b_log;
+ print Data::Dumper::Dumper $working if $dbg[39];
eval $end if $b_log;
- return \%working;
+ return $working;
}
sub sysctl_data {
eval $start if $b_log;
- my %cpu = set_cpu_data();
- my (@line,%speeds,@working);
+ my ($cpu,@line,%speeds,@working);
my ($sep) = ('');
my ($die_holder,$die_id,$phys_holder,$phys_id,$proc_count,$speed) = (0,0,0,0,0,0,0);
+ set_cpu_data(\$cpu);
@{$sysctl{'cpu'}} = () if !$sysctl{'cpu'}; # don't want error next!
foreach (@{$sysctl{'cpu'}}){
@line = split(/\s*:\s*/, $_);
@@ -9701,84 +9740,84 @@ sub sysctl_data {
$line[1] = clean_cpu($line[1]);
if ($line[1] =~ /([0-9]+)[\s-]*([KM]B)\s+L2 cache/i){
my $multiplier = ($2 eq 'MB') ? 1024: 1;
- $cpu{'l2-cache'} = $1 * $multiplier;
+ $cpu->{'l2-cache'} = $1 * $multiplier;
}
if ($line[1] =~ /([^0-9\.][0-9\.]+)[\s-]*[MG]Hz/){
- $cpu{'max-freq'} = $1;
- if ($cpu{'max-freq'} =~ /MHz/i){
- $cpu{'max-freq'} =~ s/[\s-]*MHz//;
- $cpu{'max-freq'} = clean_speed($cpu{'max-freq'},'mhz');
+ $cpu->{'max-freq'} = $1;
+ if ($cpu->{'max-freq'} =~ /MHz/i){
+ $cpu->{'max-freq'} =~ s/[\s-]*MHz//;
+ $cpu->{'max-freq'} = clean_speed($cpu->{'max-freq'},'mhz');
}
- elsif ($cpu{'max-freq'} =~ /GHz/){
- $cpu{'max-freq'} =~ s/[\s-]*GHz//i;
- $cpu{'max-freq'} = $cpu{'max-freq'} / 1000;
- $cpu{'max-freq'} = clean_speed($cpu{'max-freq'},'mhz');
+ elsif ($cpu->{'max-freq'} =~ /GHz/){
+ $cpu->{'max-freq'} =~ s/[\s-]*GHz//i;
+ $cpu->{'max-freq'} = $cpu->{'max-freq'} / 1000;
+ $cpu->{'max-freq'} = clean_speed($cpu->{'max-freq'},'mhz');
}
}
if ($line[1] =~ /\)$/){
$line[1] =~ s/\s*\(.*\)$//;
}
- $cpu{'model_name'} = $line[1];
- $cpu{'type'} = cpu_vendor($line[1]);
+ $cpu->{'model_name'} = $line[1];
+ $cpu->{'type'} = cpu_vendor($line[1]);
}
# NOTE: hw.l1icachesize: hw.l1dcachesize: ; in bytes, apparently
elsif ($line[0] eq 'hw.l1dcachesize'){
- $cpu{'l1d-cache'} = $line[1]/1024;
+ $cpu->{'l1d-cache'} = $line[1]/1024;
}
elsif ($line[0] eq 'hw.l1icachesize'){
- $cpu{'l1i-cache'} = $line[1]/1024;
+ $cpu->{'l1i-cache'} = $line[1]/1024;
}
elsif ($line[0] eq 'hw.l2cachesize'){
- $cpu{'l2-cache'} = $line[1]/1024;
+ $cpu->{'l2-cache'} = $line[1]/1024;
}
elsif ($line[0] eq 'hw.l3cachesize'){
- $cpu{'l3-cache'} = $line[1]/1024;
+ $cpu->{'l3-cache'} = $line[1]/1024;
}
# hw.smt: openbsd
elsif ($line[0] eq 'hw.smt'){
- $cpu{'smt'} = ($line[1]) ? 'enabled' : 'disabled';
+ $cpu->{'smt'} = ($line[1]) ? 'enabled' : 'disabled';
}
# htl: maybe freebsd, never seen, 1 is disabled, sigh...
elsif ($line[0] eq 'machdep.hlt_logical_cpus'){
- $cpu{'smt'} = ($line[1]) ? 'disabled' : 'enabled';
+ $cpu->{'smt'} = ($line[1]) ? 'disabled' : 'enabled';
}
# this is in mghz in samples
- elsif (!$cpu{'cur-freq'} &&
+ elsif (!$cpu->{'cur-freq'} &&
($line[0] eq 'hw.clockrate' || $line[0] eq 'hw.cpuspeed')){
- $cpu{'cur-freq'} = $line[1];
+ $cpu->{'cur-freq'} = $line[1];
}
# these are in hz: 2400000000
elsif ($line[0] eq 'hw.cpufrequency'){
- $cpu{'cur-freq'} = $line[1]/1000000;
+ $cpu->{'cur-freq'} = $line[1]/1000000;
}
elsif ($line[0] eq 'hw.busfrequency_min'){
- $cpu{'min-freq'} = $line[1]/1000000;
+ $cpu->{'min-freq'} = $line[1]/1000000;
}
elsif ($line[0] eq 'hw.busfrequency_max'){
- $cpu{'max-freq'} = $line[1]/1000000;
+ $cpu->{'max-freq'} = $line[1]/1000000;
}
# FB seems to call freq something other than clock speed, unreliable
# eg: 1500 Mhz real shows as 2400 freq, which is wrong
# elsif ($line[0] =~ /^dev\.cpu\.([0-9]+)\.freq$/){
# $speed = clean_speed($line[1]);
- # $cpu{'processors'}->[$1] = $speed;
+ # $cpu->{'processors'}->[$1] = $speed;
# }
# weird FB thing, freq can be wrong, so just count the cores and call it
# done.
elsif ($line[0] =~ /^dev\.cpu\.([0-9]+)\./ &&
- (!$cpu{'processors'} || !defined $cpu{'processors'}->[$1])){
- $cpu{'processors'}->[$1] = undef;
+ (!$cpu->{'processors'} || !defined $cpu->{'processors'}->[$1])){
+ $cpu->{'processors'}->[$1] = undef;
}
elsif ($line[0] eq 'machdep.cpu.vendor'){
- $cpu{'type'} = cpu_vendor($line[1]);
+ $cpu->{'type'} = cpu_vendor($line[1]);
}
# darwin only?
elsif ($line[0] eq 'machdep.cpu.features'){
- $cpu{'flags'} = lc($line[1]);
+ $cpu->{'flags'} = lc($line[1]);
}
# is this per phys or total?
elsif ($line[0] eq 'hw.ncpu'){
- $cpu{'cores'} = $line[1];
+ $cpu->{'cores'} = $line[1];
}
# Freebsd does some voltage hacking to actually run at lowest listed
# frequencies. The cpu does not actually support all the speeds output
@@ -9790,14 +9829,14 @@ sub sysctl_data {
# get rid of -1 in FB: 2400/-1 2200/-1 2000/-1 1800/-1
$line[1] =~ s|/-1||g;
my @temp = split(/\s+/, $line[1]);
- $cpu{'max-freq'} = $temp[0];
- $cpu{'min-freq'} = $temp[-1];
- $cpu{'scalings'} = \@temp;
+ $cpu->{'max-freq'} = $temp[0];
+ $cpu->{'min-freq'} = $temp[-1];
+ $cpu->{'scalings'} = \@temp;
}
}
# Disabled w/XXX. this is almost certainly bad data, should not be used
- elsif (!$cpu{'cur-freq'} && $line[0] eq 'dev.cpu.0.freqXXX'){
- $cpu{'cur-freq'} = $line[1];
+ elsif (!$cpu->{'cur-freq'} && $line[0] eq 'dev.cpu.0.freqXXX'){
+ $cpu->{'cur-freq'} = $line[1];
}
# the following have only been seen in DragonflyBSD data but thumbs up!
elsif ($line[0] eq 'hw.cpu_topology.members'){
@@ -9806,13 +9845,13 @@ sub sysctl_data {
$count-- if $count > 0;
# no way to get per processor speeds yet, so assign 0 to each
foreach (0 .. $count){
- $cpu{'processors'}->[$_] = 0;
+ $cpu->{'processors'}->[$_] = 0;
}
}
elsif ($line[0] eq 'hw.cpu_topology.cpu1.physical_siblings'){
# string, like: cpu0 cpu1
my @temp = split(/\s+/, $line[1]);
- $cpu{'siblings'} = scalar @temp;
+ $cpu->{'siblings'} = scalar @temp;
}
# increment by 1 for every new physical id we see. These are in almost all
# cases separate cpus, not separate dies within a single cpu body.
@@ -9821,42 +9860,42 @@ sub sysctl_data {
if ($phys_holder != $line[1]){
$phys_id++;
$phys_holder = $line[1];
- push(@{$cpu{'ids'}->[$phys_id][$die_id]},0);
+ push(@{$cpu->{'ids'}->[$phys_id][$die_id]},0);
}
}
elsif ($line[0] eq 'hw.cpu_topology.cpu0.core_id'){
- $cpu{'ids'}->[$phys_id][$line[1]] = $speed;
+ $cpu->{'ids'}->[$phys_id][$line[1]] = $speed;
}
}
- if (!$cpu{'flags'} || !$cpu{'family'}){
+ if (!$cpu->{'flags'} || !$cpu->{'family'}){
my $dmesg_boot = dboot_data();
# this core count may fix failed MT detection.
- $cpu{'cores'} = $dmesg_boot->{'cores'} if $dmesg_boot->{'cores'};
- $cpu{'flags'} = $dmesg_boot->{'flags'} if !$cpu{'flags'};
- $cpu{'family'} = $dmesg_boot->{'family'} if !$cpu{'family'};
- $cpu{'l1d-cache'} = $dmesg_boot->{'l1d-cache'} if !$cpu{'l1d-cache'};
- $cpu{'l1i-cache'} = $dmesg_boot->{'l1i-cache'} if !$cpu{'l1i-cache'};
- $cpu{'l2-cache'} = $dmesg_boot->{'l2-cache'} if !$cpu{'l2-cache'};
- $cpu{'l3-cache'} = $dmesg_boot->{'l3-cache'} if !$cpu{'l3-cache'};
- $cpu{'microcode'} = $dmesg_boot->{'microcode'} if !$cpu{'microcode'};
- $cpu{'model-id'} = $dmesg_boot->{'model-id'} if !$cpu{'model-id'};
- $cpu{'max-freq'} = $dmesg_boot->{'max-freq'} if !$cpu{'max-freq'};
- $cpu{'min-freq'} = $dmesg_boot->{'min-freq'} if !$cpu{'min-freq'};
- $cpu{'scalings'} = $dmesg_boot->{'scalings'} if !$cpu{'scalings'};
- $cpu{'siblings'} = $dmesg_boot->{'siblings'} if !$cpu{'siblings'};
- $cpu{'stepping'} = $dmesg_boot->{'stepping'} if !$cpu{'stepping'};
- $cpu{'type'} = $dmesg_boot->{'type'} if !$cpu{'type'};
- }
- main::log_data('dump','%cpu',\%cpu) if $b_log;
- print Data::Dumper::Dumper \%cpu if $dbg[8];
- eval $end if $b_log;
- return \%cpu;
+ $cpu->{'cores'} = $dmesg_boot->{'cores'} if $dmesg_boot->{'cores'};
+ $cpu->{'flags'} = $dmesg_boot->{'flags'} if !$cpu->{'flags'};
+ $cpu->{'family'} = $dmesg_boot->{'family'} if !$cpu->{'family'};
+ $cpu->{'l1d-cache'} = $dmesg_boot->{'l1d-cache'} if !$cpu->{'l1d-cache'};
+ $cpu->{'l1i-cache'} = $dmesg_boot->{'l1i-cache'} if !$cpu->{'l1i-cache'};
+ $cpu->{'l2-cache'} = $dmesg_boot->{'l2-cache'} if !$cpu->{'l2-cache'};
+ $cpu->{'l3-cache'} = $dmesg_boot->{'l3-cache'} if !$cpu->{'l3-cache'};
+ $cpu->{'microcode'} = $dmesg_boot->{'microcode'} if !$cpu->{'microcode'};
+ $cpu->{'model-id'} = $dmesg_boot->{'model-id'} if !$cpu->{'model-id'};
+ $cpu->{'max-freq'} = $dmesg_boot->{'max-freq'} if !$cpu->{'max-freq'};
+ $cpu->{'min-freq'} = $dmesg_boot->{'min-freq'} if !$cpu->{'min-freq'};
+ $cpu->{'scalings'} = $dmesg_boot->{'scalings'} if !$cpu->{'scalings'};
+ $cpu->{'siblings'} = $dmesg_boot->{'siblings'} if !$cpu->{'siblings'};
+ $cpu->{'stepping'} = $dmesg_boot->{'stepping'} if !$cpu->{'stepping'};
+ $cpu->{'type'} = $dmesg_boot->{'type'} if !$cpu->{'type'};
+ }
+ main::log_data('dump','%$cpu',$cpu) if $b_log;
+ print Data::Dumper::Dumper $cpu if $dbg[8];
+ eval $end if $b_log;
+ return $cpu;
}
## DATA GENERATOR DATA SOURCES ##
sub dboot_data {
eval $start if $b_log;
- my ($max_freq,$min_freq,@scalings,%values);
+ my ($max_freq,$min_freq,@scalings);
my ($family,$flags,$microcode,$model,$sep,$stepping,$type) = ('','','','','','','');
my ($cores,$siblings) = (0,0);
my ($l1d,$l1i,$l2,$l3) = (0,0,0,0);
@@ -9951,7 +9990,7 @@ sub dboot_data {
$flags = main::message('dmesg-boot-permissions');
}
}
- %values = (
+ my $values = {
'cores' => $cores,
'family' => $family,
'flags' => $flags,
@@ -9967,17 +10006,17 @@ sub dboot_data {
'siblings' => $siblings,
'stepping' => $stepping,
'type' => $type,
- );
- print Data::Dumper::Dumper \%values if $dbg[27];
+ };
+ print Data::Dumper::Dumper $values if $dbg[27];
eval $end if $b_log;
- return \%values;
+ return $values;
}
sub dmidecode_data {
eval $start if $b_log;
- return if !@dmi;
- my %dmi_data = ('L1' => 0, 'L2' => 0,'L3' => 0, 'phys-cnt' => 0,
+ my $dmi_data = {'L1' => 0, 'L2' => 0,'L3' => 0, 'phys-cnt' => 0,
'ext-clock' => undef, 'socket' => undef, 'speed' => undef,
- 'max-speed' => undef, 'upgrade' => undef, 'volts' => undef);
+ 'max-speed' => undef, 'upgrade' => undef, 'volts' => undef};
+ return $dmi_data if !@dmi;
my ($id,$amount,$socket,$upgrade);
foreach my $item (@dmi){
next if ref $item ne 'ARRAY';
@@ -10012,7 +10051,7 @@ sub dmidecode_data {
$amount = main::translate_size($1);
}
if ($id && $amount){
- $dmi_data{$id} = $amount;
+ $dmi_data->{$id} = $amount;
last;
}
}
@@ -10024,7 +10063,7 @@ sub dmidecode_data {
elsif ($item->[0] == 4){
# skip first three row,s we don't need that data
($socket,$upgrade) = ();
- $dmi_data{'phys-cnt'}++; # try to catch bsds without physical cpu count
+ $dmi_data->{'phys-cnt'}++; # try to catch bsds without physical cpu count
foreach my $value (@$item[3 .. $#$item]){
next if $value =~ /^~/;
# note: on single cpu systems, Socket Designation shows socket type,
@@ -10043,16 +10082,16 @@ sub dmidecode_data {
}
# seen: Voltage: 5.0 V 2.9 V
elsif ($value =~ /^Voltage:\s*([0-9\.]+)\s*(V|Volts)?\b/i){
- $dmi_data{'volts'} = main::clean_dmi($1);
+ $dmi_data->{'volts'} = main::clean_dmi($1);
}
elsif ($value =~ /^Current Speed:\s*([0-9\.]+)\s*([MGK]Hz)?\b/i){
- $dmi_data{'speed'} = main::clean_dmi($1);
+ $dmi_data->{'speed'} = main::clean_dmi($1);
}
elsif ($value =~ /^Max Speed:\s*([0-9\.]+)\s*([MGK]Hz)?\b/i){
- $dmi_data{'max-speed'} = main::clean_dmi($1);
+ $dmi_data->{'max-speed'} = main::clean_dmi($1);
}
elsif ($value =~ /^External Clock:\s*([0-9\.]+\s*[MGK]Hz)\b/){
- $dmi_data{'ext-clock'} = main::clean_dmi($1);
+ $dmi_data->{'ext-clock'} = main::clean_dmi($1);
}
}
}
@@ -10066,71 +10105,74 @@ sub dmidecode_data {
$socket = $upgrade;
undef $upgrade;
}
- $dmi_data{'socket'} = $socket;
- $dmi_data{'upgrade'} = $upgrade;
+ $dmi_data->{'socket'} = $socket;
+ $dmi_data->{'upgrade'} = $upgrade;
}
- main::log_data('dump','%dmi_data',\%dmi_data) if $b_log;
- print Data::Dumper::Dumper \%dmi_data if $dbg[27];
+ main::log_data('dump','%$dmi_data',$dmi_data) if $b_log;
+ print Data::Dumper::Dumper $dmi_data if $dbg[27];
eval $end if $b_log;
- return \%dmi_data;
+ return $dmi_data;
}
## CPU PROPERTIES MAIN ##
sub cpu_properties {
my ($cpu) = @_;
- my ($cpu_sys,%dmi_data,%tests);
- my %caches = (
+ my ($cpu_sys);
+ my $dmi_data = {};
+ my $tests = {};
+ my $caches = {
'cache' => 0, # general, non id'ed from cpuinfo generic cache
'l1' => 0,
'l1d' => 0,
'l1i' => 0,
'l2' => 0,
'l3' => 0,
- );
- my %counts = (
+ };
+ my $counts = {
'dies' => 0,
'cpu-cores' => 0,
'cores' => 0,
'cores-multiplier' => 0,
'physical' => 0,
'processors' => 0,
- );
+ };
my ($cache_check) = ('');
if (!$bsd_type && -d '/sys/devices' && !$force{'cpuinfo'}){
$cpu_sys = cpu_sys_data($cpu->{'sys-freq'});
}
- cp_test_types($cpu,\%tests) if $cpu->{'type'};
+ cp_test_types($cpu,$tests) if $cpu->{'type'};
undef $cpu_sys if $dbg[42];
## START CPU DATA HANDLERS ##
if (defined $cpu_sys->{'cpus'}){
cp_data_sys(
$cpu,
$cpu_sys,
- \%caches,
- \%counts
+ $caches,
+ $counts
);
}
- if (!defined $cpu_sys->{'cpus'} || !$counts{'physical'} ||
- !$counts{'cpu-cores'}){
+ if (!defined $cpu_sys->{'cpus'} || !$counts->{'physical'} ||
+ !$counts->{'cpu-cores'}){
cp_data_fallback(
$cpu,
- \%caches,
+ $caches,
\$cache_check,
- \%counts,
- \%tests,
+ $counts,
+ $tests,
);
}
# some arm cpus report each core as its own die, but that's wrong
- if (%risc && $counts{'dies'} > 1 && $counts{'cpu-cores'} == $counts{'dies'}){
- $counts{'dies'} = 1;
+ if (%risc && $counts->{'dies'} > 1 &&
+ $counts->{'cpu-cores'} == $counts->{'dies'}){
+ $counts->{'dies'} = 1;
$cpu->{'dies'} = 1;
}
if ($type eq 'full' && ($extra > 1 || ($bsd_type && !$cpu->{'l2-cache'}))){
cp_data_dmi(
$cpu,
- \%dmi_data,
- \%caches,
- \%counts, # only to set BSD phys cpu counts if not found
+ $dmi_data,
+ $caches,
+ $counts, # only to set BSD phys cpu counts if not found
\$cache_check,
);
}
@@ -10140,31 +10182,33 @@ sub cpu_properties {
## START CACHE PROCESSING ##
# Get BSD and legacy linux caches if not already from dmidecode or cpu_sys.
- if ($type eq 'full' && !$caches{'l1'} && !$caches{'l2'} && !$caches{'l2'}){
+ if ($type eq 'full' &&
+ !$caches->{'l1'} && !$caches->{'l2'} && !$caches->{'l2'}){
cp_caches_fallback(
- \%counts,
+ $counts,
$cpu,
- \%caches,
+ $caches,
\$cache_check,
);
}
# nothing to check!
if ($type eq 'full'){
- if (!$caches{'l1'} && !$caches{'l2'} && !$caches{'l3'} && !$caches{'cache'}){
+ if (!$caches->{'l1'} && !$caches->{'l2'} && !$caches->{'l3'} &&
+ !$caches->{'cache'}){
$cache_check = '';
}
- if ($caches{'cache'}){
+ if ($caches->{'cache'}){
# we don't want any math done on this one, who knows what it is
- $caches{'cache'} = cp_cache_processor($caches{'cache'},1);
+ $caches->{'cache'} = cp_cache_processor($caches->{'cache'},1);
}
- if ($caches{'l1'}){
- $caches{'l1'} = cp_cache_processor($caches{'l1'},$counts{'physical'});
+ if ($caches->{'l1'}){
+ $caches->{'l1'} = cp_cache_processor($caches->{'l1'},$counts->{'physical'});
}
- if ($caches{'l2'}){
- $caches{'l2'} = cp_cache_processor($caches{'l2'},$counts{'physical'});
+ if ($caches->{'l2'}){
+ $caches->{'l2'} = cp_cache_processor($caches->{'l2'},$counts->{'physical'});
}
- if ($caches{'l3'}){
- $caches{'l3'} = cp_cache_processor($caches{'l3'},$counts{'physical'});
+ if ($caches->{'l3'}){
+ $caches->{'l3'} = cp_cache_processor($caches->{'l3'},$counts->{'physical'});
}
}
## END CACHE PROCESSING ##
@@ -10172,21 +10216,23 @@ sub cpu_properties {
## START TYPE/LAYOUT/ARCH/BUGS ##
my ($cpu_type) = ('');
$cpu_type = cp_cpu_type(
- \%counts,
+ $counts,
$cpu,
- \%tests
+ $tests
);
- my %topology;
- cp_cpu_topology(\%counts,\%topology);
+ my $topology = {};
+ cp_cpu_topology($counts,$topology);
my $arch = cp_cpu_arch(
$cpu->{'type'},
$cpu->{'family'},
$cpu->{'model-id'},
- $cpu->{'stepping'}
+ $cpu->{'stepping'},
+ $cpu->{'model_name'},
);
# arm cpuinfo case only; confirm on bsds, not sure all get family/ids
if ($arch->[0] && !$cpu->{'arch'}){
- ($cpu->{'arch'},$cpu->{'arch-note'}) = @{$arch};
+ ($cpu->{'arch'},$cpu->{'arch-note'},$cpu->{'process'},$cpu->{'gen'},
+ $cpu->{'year'}) = @$arch;
}
# cpu_arch comes from set_os()
if (!$cpu->{'arch'} && $cpu_arch && %risc){
@@ -10205,48 +10251,48 @@ sub cpu_properties {
## END SPEED/BITS ##
## LOAD %cpu_properties
- my %cpu_properties = (
+ my $cpu_properties = {
'avg-speed-key' => $speed_info->{'avg-speed-key'},
'bits-sys' => $bits_sys,
- 'cache' => $caches{'cache'},
+ 'cache' => $caches->{'cache'},
'cache-check' => $cache_check,
'cpu-type' => $cpu_type,
- 'dmi-max-speed' => $dmi_data{'max-speed'},
- 'dmi-speed' => $dmi_data{'speed'},
- 'ext-clock' => $dmi_data{'ext-clock'},
+ 'dmi-max-speed' => $dmi_data->{'max-speed'},
+ 'dmi-speed' => $dmi_data->{'speed'},
+ 'ext-clock' => $dmi_data->{'ext-clock'},
'high-speed-key' => $speed_info->{'high-speed-key'},
- 'l1-cache' => $caches{'l1'},
- 'l1d-desc' => $caches{'l1d-desc'},
- 'l1i-desc' => $caches{'l1i-desc'},
- 'l2-cache' => $caches{'l2'},
- 'l2-desc' => $caches{'l2-desc'},
- 'l3-cache' => $caches{'l3'},
- 'l3-desc' => $caches{'l3-desc'},
+ 'l1-cache' => $caches->{'l1'},
+ 'l1d-desc' => $caches->{'l1d-desc'},
+ 'l1i-desc' => $caches->{'l1i-desc'},
+ 'l2-cache' => $caches->{'l2'},
+ 'l2-desc' => $caches->{'l2-desc'},
+ 'l3-cache' => $caches->{'l3'},
+ 'l3-desc' => $caches->{'l3-desc'},
'min-max-key' => $speed_info->{'min-max-key'},
'min-max' => $speed_info->{'min-max'},
- 'socket' => $dmi_data{'socket'},
+ 'socket' => $dmi_data->{'socket'},
'scaling-min-max-key' => $speed_info->{'scaling-min-max-key'},
'scaling-min-max' => $speed_info->{'scaling-min-max'},
'speed-key' => $speed_info->{'speed-key'},
'speed' => $speed_info->{'speed'},
- 'topology-full' => $topology{'full'},
- 'topology-string' => $topology{'string'},
- 'upgrade' => $dmi_data{'upgrade'},
- 'volts' => $dmi_data{'volts'},
- );
+ 'topology-full' => $topology->{'full'},
+ 'topology-string' => $topology->{'string'},
+ 'upgrade' => $dmi_data->{'upgrade'},
+ 'volts' => $dmi_data->{'volts'},
+ };
if ($b_log){
- main::log_data('dump','%cpu_properties',\%cpu_properties);
- main::log_data('dump','%topology',\%topology);
+ main::log_data('dump','%$cpu_properties',$cpu_properties);
+ main::log_data('dump','%$topology',$topology);
}
# print Data::Dumper::Dumper $cpu;
if ($dbg[38]){
- print Data::Dumper::Dumper \%cpu_properties;
- print Data::Dumper::Dumper \%topology;
+ print Data::Dumper::Dumper $cpu_properties;
+ print Data::Dumper::Dumper $topology;
}
# my $dc = scalar @dies;
# print 'phys: ' . $pc . ' dies: ' . $dc, "\n";
eval $end if $b_log;
- return \%cpu_properties;
+ return $cpu_properties;
}
## CPU DATA ENGINES ##
@@ -10319,11 +10365,11 @@ sub cp_data_fallback {
# where rounds to 0 or 1 less
# print "$cpu{'type'},$cpu{'family'},$cpu{'model-id'},$cpu{'arch'}\n";
if ($tests->{'elbrus'} && $counts->{'processors'}){
- my @elbrus = cp_elbrus_data($cpu->{'family'},$cpu->{'model-id'},
+ my $elbrus = cp_elbrus_data($cpu->{'family'},$cpu->{'model-id'},
$counts->{'processors'},$cpu->{'arch'});
- $counts->{'cpu-cores'} = $elbrus[0];
- $counts->{'physical'} = $elbrus[1];
- $cpu->{'arch'} = $elbrus[2];
+ $counts->{'cpu-cores'} = $elbrus->[0];
+ $counts->{'physical'} = $elbrus->[1];
+ $cpu->{'arch'} = $elbrus->[2];
# print 'model id: ' . $cpu->{'model-id'} . ' arch: ' . $cpu->{'arch'} . " cpc: $counts->{'cpu-cores'} phyc: $counts->{'physical'} proc: $counts->{'processors'} \n";
}
$counts->{'physical'} ||= 1; # assume 1 if no id found, as with ARM
@@ -10670,9 +10716,10 @@ sub cp_caches_fallback {
}
eval $end if $b_log;
}
+## START CPU ARCH ##
sub cp_cpu_arch {
eval $start if $b_log;
- my ($type,$family,$model,$stepping) = @_;
+ my ($type,$family,$model,$stepping,$name) = @_;
# we can get various random strings for rev/stepping, particularly for arm,ppc
# but we want stepping to be integer for math comparisons, so convert, or set
# to 0 so it won't break anything.
@@ -10684,136 +10731,244 @@ sub cp_cpu_arch {
}
$family ||= '';
$model = '' if !defined $model; # model can be 0
- my ($arch,$note) = ('','');
+ my ($arch,$gen,$note,$process,$year);
my $check = main::message('note-check');
# See: docs/inxi-resources.txt
# print "type:$type fam:$family model:$model step:$stepping\n";
if ($type eq 'amd'){
- if ($family eq '4'){
+ if ($family eq '3'){
+ $arch = 'Am386';
+ $process = 'AMD 900-1500nm';
+ $year = '1991-92';
+ }
+ elsif ($family eq '4'){
if ($model =~ /^(3|7|8|9|A)$/){
- $arch = 'Am486'}
+ $arch = 'Am486';
+ $process = 'AMD 350-700nm';
+ $year = '1993-95';}
elsif ($model =~ /^(E|F)$/){
- $arch = 'Am5x86'}
+ $arch = 'Am5x86';
+ $process = 'AMD 350nm';
+ $year = '1995-99';}
}
elsif ($family eq '5'){
if ($model =~ /^(0|1|2|3)$/){
- $arch = 'K5'}
+ $arch = 'K5';
+ $process = 'AMD 350-500nm';
+ $year = '1996';}
elsif ($model =~ /^(6|7)$/){
- $arch = 'K6'}
+ $arch = 'K6';
+ $process = 'AMD ' . ($model eq '6') ? '350nm' : '250nm';
+ $year = '1997-98';}
elsif ($model =~ /^(8)$/){
- $arch = 'K6-2'}
+ $arch = 'K6-2';
+ $process = 'AMD 250nm';
+ $year = '1998-2003';}
elsif ($model =~ /^(9|D)$/){
- $arch = 'K6-3'}
+ $arch = 'K6-3';
+ $process = 'AMD 180-250nm';
+ $year = '1999-2003';}
elsif ($model =~ /^(A)$/){
- $arch = 'Geode'}
- }
+ $arch = 'Geode';
+ $process = 'AMD 150-350nm';
+ $year = '';} # dates uncertain, 1999 start
+ }
elsif ($family eq '6'){
if ($model =~ /^(1|2)$/){
- $arch = 'K7'}
+ $arch = 'K7 Athlon Classic';
+ $process = 'AMD 180-250nm';
+ $year = '1999-2002';}
elsif ($model =~ /^(3|4)$/){
- $arch = 'K7 Thunderbird'}
+ $arch = 'K7 Thunderbird';
+ $process = 'AMD 180nm';
+ $year = '2000-01';}
elsif ($model =~ /^(6|7|8|A)$/){
- $arch = 'K7 Palomino+'}
+ $arch = 'K7 Palomino+'; # athlon xp
+ $process = 'AMD 130-180nm';
+ $year = '2001';}
else {
- $arch = 'K7'}
+ $arch = 'K7';
+ $process = 'AMD 130-250nm';
+ $year = '';}
}
+ # note: family F K8 needs granular breakdowns, was a long lived family
elsif ($family eq 'F'){
- if ($model =~ /^(4|5|7|8|B|C|E|F|14|15|17|18|1B|1C|1F)$/){
- $arch = 'K8'}
+ # positive IDs, but sub arch difficult, can be stepping based
+ if ($model =~ /^(1C)$/){
+ $arch = 'K8'; # Palermo
+ $process = 'AMD 90nm';
+ $year = '2001';}
+ elsif ($model =~ /^(7F)$/){
+ $arch = 'K8 rev.F+'; # Lima
+ $process = 'AMD 65nm';
+ $year = '2005';}
+ # generic IDs, try to reduce these to solid over time
+ elsif ($model =~ /^(4|5|7|8|B|C|E|F|14|15|17|18|1B|1F)$/){
+ $arch = 'K8';
+ $process = 'AMD 65-130nm';
+ $year = '';}
elsif ($model =~ /^(21|23|24|25|27|28|2C|2F)$/){
- $arch = 'K8 rev.E'}
- elsif ($model =~ /^(41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|7F|C1)$/){
- $arch = 'K8 rev.F+'}
+ $arch = 'K8 rev.E';
+ $process = 'AMD 65-130nm';
+ $year = '';}
+ elsif ($model =~ /^(41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|C1)$/){
+ $arch = 'K8 rev.F+';
+ $process = 'AMD 65-130nm';
+ $year = '';}
else {
- $arch = 'K8'}
+ $arch = 'K8';
+ $process = 'AMD 65-130nm';
+ $year = '';}
}
elsif ($family eq '10'){
if ($model =~ /^(2|4|5|6|8|9|A)$/){
- $arch = 'K10'}
+ $arch = 'K10';
+ $process = 'AMD 32-65nm';
+ $year = '2007-12';}
else {
- $arch = 'K10'}
+ $arch = 'K10';
+ $process = 'AMD 32-65nm';
+ $year = '2007-12';}
}
+ # very loose, all stepping 1: covers athlon x2, sempron, turion x2
+ # years unclear, could be 2005 start, or 2008
elsif ($family eq '11'){
if ($model =~ /^(3)$/){
- $arch = 'Turion X2 Ultra'}
+ $arch = 'Athlon X2/Turion X2'; # unclear: K8 or K10
+ $note = $check;
+ $process = 'AMD 45-90nm';
+ $year = ''; }
}
# might also need cache handling like 14/16
elsif ($family eq '12'){
if ($model =~ /^(1)$/){
- $arch = 'Fusion'}
+ $arch = 'Fusion';
+ $process = 'GF 32nm';
+ $year = '';}
else {
- $arch = 'Fusion'}
+ $arch = 'Fusion';
+ $process = 'GF 32nm';
+ $year = '';}
}
# SOC, apu
elsif ($family eq '14'){
if ($model =~ /^(1|2)$/){
- $arch = 'Bobcat'}
+ $arch = 'Bobcat';
+ $process = 'GF 40nm';
+ $year = '2011-13';}
else {
- $arch = 'Bobcat'}
+ $arch = 'Bobcat';
+ $process = 'GF 40nm';
+ $year = '2011-13';}
}
elsif ($family eq '15'){
# note: only model 1 confirmd
if ($model =~ /^(0|1|3|4|5|6|7|8|9|A|B|C|D|E|F)$/){
- $arch = 'Bulldozer'}
+ $arch = 'Bulldozer';
+ $process = 'GF 32nm';
+ $year = '2011';}
# note: only 2,11,13 confirmed
elsif ($model =~ /^(2|10|11|12|13|14|15|16|17|18|19|1A|1B|1C|1D|1E|1F)$/){
- $arch = 'Piledriver'}
+ $arch = 'Piledriver';
+ $process = 'GF 32nm';
+ $year = '2012-13';}
# note: only 30,38 confirmed
elsif ($model =~ /^(30|31|32|33|34|35|36|37|38|39|3A|3B|3C|3D|3E|3F)$/){
- $arch = 'Steamroller'}
+ $arch = 'Steamroller';
+ $process = 'GF 28nm';
+ $year = '2014';}
# note; only 60,65,70 confirmed
elsif ($model =~ /^(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 = 'Excavator';
+ $process = 'GF 28nm';
+ $year = '2015';}
else {
- $arch = 'Bulldozer'}
+ $arch = 'Bulldozer';
+ $process = 'GF 32nm';
+ $year = '2011-12';}
}
# SOC, apu
elsif ($family eq '16'){
if ($model =~ /^(0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)$/){
- $arch = 'Jaguar'}
+ $arch = 'Jaguar';
+ $process = 'GF 28nm';
+ $year = '2013-14';}
elsif ($model =~ /^(30|31|32|33|34|35|36|37|38|39|3A|3B|3C|3D|3E|3F)$/){
- $arch = 'Puma'}
+ $arch = 'Puma';
+ $process = 'GF 28nm';
+ $year = '2014-15';}
else {
- $arch = 'Jaguar'}
+ $arch = 'Jaguar';
+ $process = 'GF 28nm';
+ $year = '2013-14';}
}
elsif ($family eq '17'){
# can't find stepping/model for no ht 2x2 core/die models, only first ones
if ($model =~ /^(1|11|20)$/){
$arch = 'Zen';
- }
+ $process = 'GF 14nm';
+ $year = '2017-19';}
# Seen: stepping 1 is Zen+ Ryzen 7 3750H. But stepping 1 Zen is: Ryzen 3 3200U
# AMD Ryzen 3 3200G is stepping 1, Zen+
# Unknown if stepping 0 is Zen or either.
elsif ($model =~ /^(18)$/){
$arch = 'Zen/Zen+';
+ $gen = '1';
+ $process = 'GF 12nm';
$note = $check;
- }
+ $year = '2019';}
# shares model 8 with zen, stepping unknown
elsif ($model =~ /^(8)$/){
$arch = 'Zen+';
- }
+ $gen = '2';
+ $process = 'GF 12nm';
+ $year = '2018-21';}
# used this but it didn't age well: ^(2[0123456789ABCDEF]|
elsif ($model =~ /^(31|47|60|68|71|90)$/){
$arch = 'Zen 2';
- }
+ $gen = '3';
+ $process = 'TSMC n7 (7nm)'; # some consumer maybe GF 14nm
+ $year = '2020-22';}
else {
$arch = 'Zen';
- $note = $check;}
+ $note = $check;
+ $process = '7-14nm';
+ $year = '';}
}
# Joint venture between AMD and Chinese companies. Type amd? or hygon?
elsif ($family eq '18'){
- # model 0
+ # model 0, zen 1
$arch = 'Zen (Hygon Dhyana)';
- }
+ $gen = '1';
+ $process = 'GF 14nm';
+ $year = '';}
elsif ($family eq '19'){
- # model: 0 1 21 40 50
- $arch = 'Zen 3';
+ # ext model 7,8, but no base models yet
+ # 10 engineering sample
+ if ($model =~ /^(10|7\d|8\d)$/){
+ $arch = 'Zen 4';
+ $gen = '5';
+ $process = 'TSMC n5 (5nm)';
+ $year = '2022';}
+ # double check 40, 44
+ elsif ($model =~ /^(40|44)$/){
+ $arch = 'Zen 3+';
+ $gen = '4';
+ $process = 'TSMC n6 (7nm)';
+ $year = '2022';}
+ # 21, 50: step 0;
+ elsif ($model =~ /^(0|1|8|21|50)$/){
+ $arch = 'Zen 3';
+ $gen = '4';
+ $process = 'TSMC n7 (7nm)';
+ $year = '2021-22';}
+ else {
+ $arch = 'Zen 3/4';
+ $note = $check;
+ $process = 'TSMC n5 (5nm)-7';
+ $year = '2021-22';}
+ # Zen 5: TSCM n3
}
- # note: family 20 may be Zen 4 but not known for sure yet, zen 5 also in pipeline
- # elsif ($family eq '20'){
- # # model: unknown
- # $arch = 'Zen 4';
- # }
}
elsif ($type eq 'arm'){
if ($family ne ''){
@@ -10828,23 +10983,39 @@ sub cp_cpu_arch {
elsif ($type eq 'centaur'){
if ($family eq '5'){
if ($model =~ /^(4)$/){
- $arch = 'WinChip C6'}
+ $arch = 'WinChip C6';
+ $process = '250nm';
+ $year = '';}
elsif ($model =~ /^(8)$/){
- $arch = 'WinChip 2'}
+ $arch = 'WinChip 2';
+ $process = '250nm';
+ $year = '';}
elsif ($model =~ /^(9)$/){
- $arch = 'WinChip 3'}
+ $arch = 'WinChip 3';
+ $process = '250nm';
+ $year = '';}
}
elsif ($family eq '6'){
if ($model =~ /^(6)$/){
- $arch = 'WinChip-based'}
+ $arch = 'WinChip-based';
+ $process = '150nm'; # guess
+ $year = '';}
elsif ($model =~ /^(7|8)$/){
- $arch = 'C3'}
+ $arch = 'C3';
+ $process = '150nm';
+ $year = '';}
elsif ($model =~ /^(9)$/){
- $arch = 'C3-2'}
+ $arch = 'C3-2';
+ $process = '130nm';
+ $year = '';}
elsif ($model =~ /^(A|D)$/){
- $arch = 'C7'}
+ $arch = 'C7';
+ $process = '90nm';
+ $year = '';}
elsif ($model =~ /^(F)$/){
- $arch = 'Isaiah'}
+ $arch = 'Isaiah';
+ $process = '90nm'; # guess
+ $year = '';}
}
}
# note, to test uncoment $cpu{'type'} = Elbrus in proc/cpuinfo logic
@@ -10852,54 +11023,92 @@ sub cp_cpu_arch {
# E8CB
if ($family eq '4'){
if ($model eq '1'){
- $arch = 'Elbrus'}
+ $arch = 'Elbrus';
+ $process = '';
+ $year = '';}
elsif ($model eq '2'){
- $arch = 'Elbrus-S'}
+ $arch = 'Elbrus-S';
+ $process = '';
+ $year = '';}
elsif ($model eq '3'){
- $arch = 'Elbrus-4C'}
+ $arch = 'Elbrus-4C';
+ $process = '65nm';
+ $year = '';}
elsif ($model eq '4'){
- $arch = 'Elbrus-2C+'}
+ $arch = 'Elbrus-2C+';
+ $process = '90nm';
+ $year = '';}
elsif ($model eq '6'){
- $arch = 'Elbrus-2CM'}
+ $arch = 'Elbrus-2CM';
+ $process = '90nm';
+ $year = '';}
elsif ($model eq '7'){
if ($stepping >= 2){
- $arch = 'Elbrus-8C1';}
+ $arch = 'Elbrus-8C1';
+ $process = '28nm';
+ $year = '';}
else {
- $arch = 'Elbrus-8C';}
+ $arch = 'Elbrus-8C';
+ $process = '28nm';
+ $year = '';}
} # note: stepping > 1 may be 8C1
elsif ($model eq '8'){
- $arch = 'Elbrus-1C+'}
+ $arch = 'Elbrus-1C+';
+ $process = 'TSMC 40nm';
+ $year = '';}
# 8C2 morphed out of E8CV, but the two were the same die
elsif ($model eq '9'){
$arch = 'Elbrus-8CV/8C2';
- $note = $check;}
+ $process = 'TSMC 28nm';
+ $note = $check;
+ $year = '';}
elsif ($model eq 'A'){
- $arch = 'Elbrus-12C'}
+ $arch = 'Elbrus-12C';
+ $process = 'TSMC 16nm'; # guess
+ $year = '';}
elsif ($model eq 'B'){
- $arch = 'Elbrus-16C'}
+ $arch = 'Elbrus-16C';
+ $process = 'TSMC 16nm';
+ $year = '';}
elsif ($model eq 'C'){
- $arch = 'Elbrus-2C3'}
+ $arch = 'Elbrus-2C3';
+ $process = 'TSMC 16nm';
+ $year = '';}
else {
- $arch = 'Elbrus-??';
- $note = $check;}
+ $arch = 'Elbrus-??';;
+ $year = '';
+ $note = $check;
+ $year = '';}
}
elsif ($family eq '5'){
if ($model eq '9'){
- $arch = 'Elbrus-8C2'}
+ $arch = 'Elbrus-8C2';
+ $process = 'TSMC 28nm';
+ $year = '';}
else {
$arch = 'Elbrus-??';
- $note = $check;}
+ $note = $check;
+ $process = '';
+ $year = '';}
}
elsif ($family eq '6'){
if ($model eq 'A'){
- $arch = 'Elbrus-12C'}
+ $arch = 'Elbrus-12C';
+ $process = 'TSMC 16nm'; # guess
+ $year = '';}
elsif ($model eq 'B'){
- $arch = 'Elbrus-16C'}
+ $arch = 'Elbrus-16C';
+ $process = 'TSMC 16nm';
+ $year = '';}
elsif ($model eq 'C'){
- $arch = 'Elbrus-2C3'}
+ $arch = 'Elbrus-2C3';
+ $process = 'TSMC 16nm';
+ $year = '';}
else {
$arch = 'Elbrus-??';
- $note = $check;}
+ $note = $check;
+ $process = '';
+ $year = '';}
}
else {
$arch = 'Elbrus-??';
@@ -10909,178 +11118,327 @@ sub cp_cpu_arch {
elsif ($type eq 'intel'){
if ($family eq '4'){
if ($model =~ /^(0|1|2|3|4|5|6|7|8|9)$/){
- $arch = '486'}
+ $arch = '486';
+ $process = '600-1000nm';
+ $year = '';}
}
elsif ($family eq '5'){
if ($model =~ /^(1|2|3|7)$/){
- $arch = 'P5'}
+ $arch = 'P5';
+ $process = 'Intel 350-800nm';
+ $year = '';}
elsif ($model =~ /^(4|8)$/){
- $arch = 'P5'} # MMX
+ $arch = 'P5';
+ $process = 'Intel 350-800nm'; # MMX
+ $year = '';}
elsif ($model =~ /^(9|A)$/){
- $arch = 'Lakemont'}
+ $arch = 'Lakemont';
+ $process = 'Intel 350-800nm';
+ $year = '';}
}
elsif ($family eq '6'){
if ($model =~ /^(1)$/){
- $arch = 'P6 Pro'}
+ $arch = 'P6 Pro';
+ $process = 'Intel 350nm';
+ $year = '';}
elsif ($model =~ /^(3)$/){
- $arch = 'P6 II Klamath'}
+ $arch = 'P6 II Klamath';
+ $process = 'Intel 350nm';
+ $year = '';}
elsif ($model =~ /^(5)$/){
- $arch = 'P6 II Deschutes'}
+ $arch = 'P6 II Deschutes';
+ $process = 'Intel 250nm';
+ $year = '';}
elsif ($model =~ /^(6)$/){
- $arch = 'P6 II Mendocino'}
+ $arch = 'P6 II Mendocino';
+ $process = 'Intel 250nm';
+ $year = '';}
elsif ($model =~ /^(7)$/){
- $arch = 'P6 III Katmai'}
+ $arch = 'P6 III Katmai';
+ $process = 'Intel 250nm';
+ $year = '1999';}
elsif ($model =~ /^(8)$/){
- $arch = 'P6 III Coppermine'}
+ $arch = 'P6 III Coppermine';
+ $process = 'Intel 180nm';
+ $year = '1999';}
elsif ($model =~ /^(9)$/){
- $arch = 'M Banias'} # pentium M
+ $arch = 'M Banias'; # Pentium M
+ $process = 'Intel 130nm';
+ $year = '2003';}
elsif ($model =~ /^(A)$/){
- $arch = 'P6 III Xeon'}
+ $arch = 'P6 III Xeon';
+ $process = 'Intel 180-250nm';
+ $year = '1999';}
elsif ($model =~ /^(B)$/){
- $arch = 'P6 III Tualitin'}
+ $arch = 'P6 III Tualitin';
+ $process = 'Intel 130nm';
+ $year = '2001';}
elsif ($model =~ /^(D)$/){
- $arch = 'M Dothan'} # Pentium M
+ $arch = 'M Dothan'; # Pentium M
+ $process = 'Intel 90nm';
+ $year = '2003-05';}
elsif ($model =~ /^(E)$/){
- $arch = 'M Yonah'}
+ $arch = 'M Yonah';
+ $process = 'Intel 65nm';
+ $year = '2006-08';}
elsif ($model =~ /^(F|16)$/){
- $arch = 'Core Merom'}
+ $arch = 'Core2 Merom';
+ $process = 'Intel 65nm';
+ $year = '2006-09';}
elsif ($model =~ /^(15)$/){
- $arch = 'M Tolapai'} # pentium M system on chip
+ $arch = 'M Tolapai'; # pentium M system on chip
+ $process = 'Intel 90nm';
+ $year = '2008';}
elsif ($model =~ /^(1D)$/){
- $arch = 'Core Penryn'}
+ $arch = 'Penryn';
+ $process = 'Intel 45nm';
+ $year = '2007-08';}
elsif ($model =~ /^(17)$/){
- $arch = 'Core Yorkfield'}
+ $arch = 'Penryn Yorkfield';
+ $process = 'Intel 45nm';
+ $year = '2008';}
# had 25 also, but that's westmere, at least for stepping 2
elsif ($model =~ /^(1A|1E|1F|2C|2E|2F)$/){
- $arch = 'Nehalem'}
+ $arch = 'Nehalem';
+ $process = 'Intel 45nm';
+ $year = '2008-10';}
elsif ($model =~ /^(1C|26)$/){
- $arch = 'Bonnell'} # atom Bonnell? 27?
- elsif ($model =~ /^(27|35|36)$/){
- $arch = 'Saltwell'}
+ $arch = 'Bonnell';
+ $process = 'Intel 45nm';
+ $year = '2008-13';} # atom Bonnell? 27?
# 25 may be nahelem in a stepping, check. Stepping 2 is westmere
elsif ($model =~ /^(25|2C|2F)$/){
- $arch = 'Westmere'}
+ $arch = 'Westmere'; # die shrink of nehalem
+ $process = 'Intel 32nm';
+ $year = '2010-11';}
+ elsif ($model =~ /^(27|35|36)$/){
+ $arch = 'Saltwell';
+ $process = 'Intel 32nm';
+ $year = '2011-13';}
elsif ($model =~ /^(2A|2D)$/){
- $arch = 'Sandy Bridge'}
+ $arch = 'Sandy Bridge';
+ $process = 'Intel 32nm';
+ $year = '2010-12';}
elsif ($model =~ /^(37|4A|4D|5A|5D)$/){
- $arch = 'Silvermont'}
+ $arch = 'Silvermont';
+ $process = 'Intel 22nm';
+ $year = '2013-15';}
elsif ($model =~ /^(3A|3E)$/){
- $arch = 'Ivy Bridge'}
+ $arch = 'Ivy Bridge';
+ $process = 'Intel 22nm';
+ $year = '2012-15';}
elsif ($model =~ /^(3C|3F|45|46)$/){
- $arch = 'Haswell'}
+ $arch = 'Haswell';
+ $process = 'Intel 22nm';
+ $year = '2013-15';}
elsif ($model =~ /^(3D|47|4F|56)$/){
- $arch = 'Broadwell'}
+ $arch = 'Broadwell';
+ $process = 'Intel 14nm';
+ $year = '2015-18';}
elsif ($model =~ /^(4C)$/){
- $arch = 'Airmont'}
+ $arch = 'Airmont';
+ $process = 'Intel 14nm';
+ $year = '2015-17';}
elsif ($model =~ /^(4E)$/){
- $arch = 'Skylake'}
+ $arch = 'Skylake';
+ $process = 'Intel 14nm';
+ $year = '2015';}
# need to find stepping for these, guessing stepping 4 is last for SL
elsif ($model =~ /^(55)$/){
if ($stepping >= 5 && $stepping <= 7){
- $arch = 'Cascade Lake'}
+ $arch = 'Cascade Lake';
+ $process = 'Intel 14nm';
+ $year = '2019';}
elsif ($stepping >= 8){
- $arch = 'Cooper Lake'}
+ $arch = 'Cooper Lake';
+ $process = 'Intel 14nm';
+ $year = '2020';}
else {
- $arch = 'Skylake'} }
+ $arch = 'Skylake';
+ $process = 'Intel 14nm';
+ $year = '';}}
elsif ($model =~ /^(57)$/){
- $arch = 'Knights Landing'}
+ $arch = 'Knights Landing';
+ $process = 'Intel 14nm';
+ $year = '2016+';}
elsif ($model =~ /^(5C|5F)$/){
- $arch = 'Goldmont'}
+ $arch = 'Goldmont';
+ $process = 'Intel 14nm';
+ $year = '2016';}
elsif ($model =~ /^(5E)$/){
- $arch = 'Skylake-S'}
+ $arch = 'Skylake-S';
+ $process = 'Intel 14nm';
+ $year = '2015';}
elsif ($model =~ /^(66)$/){
- $arch = 'Cannon Lake'}
+ $arch = 'Cannon Lake';
+ $process = 'Intel 10nm';
+ $year = '2018';}
# 6 are servers, 7 not
elsif ($model =~ /^(6A|6C|7D|7E)$/){
- $arch = 'Ice Lake'}
+ $arch = 'Ice Lake';
+ $process = 'Intel 10nm';
+ $year = '2019-21';}
elsif ($model =~ /^(7A)$/){
- $arch = 'Goldmont Plus'}
+ $arch = 'Goldmont Plus';
+ $process = 'Intel 14nm';
+ $year = '2017';}
elsif ($model =~ /^(85)$/){
- $arch = 'Knights Mill'}
+ $arch = 'Knights Mill';
+ $process = 'Intel 14nm';
+ $year = '2017-19';}
elsif ($model =~ /^(8A|96|9C)$/){
- $arch = 'Tremont'}
+ $arch = 'Tremont';
+ $process = 'Intel 10nm';
+ $year = '2019';}
elsif ($model =~ /^(8C|8D)$/){
- $arch = 'Tiger Lake'}
+ $arch = 'Tiger Lake';
+ $process = 'Intel 10nm';
+ $year = '2020';}
elsif ($model =~ /^(8E)$/){
# can be AmberL or KabyL
if ($stepping == 9){
$arch = 'Amber/Kaby Lake';
- $note = $check;}
+ $note = $check;
+ $process = 'Intel 14nm';
+ $year = '2017';}
elsif ($stepping == 10){
- $arch = 'Coffee Lake'}
+ $arch = 'Coffee Lake';
+ $process = 'Intel 14nm';
+ $year = '2017';}
elsif ($stepping == 11){
- $arch = 'Whiskey Lake'}
+ $arch = 'Whiskey Lake';
+ $process = 'Intel 14nm';
+ $year = '2018';}
# can be WhiskeyL or CometL
elsif ($stepping == 12){
$arch = 'Comet/Whiskey Lake';
- $note = $check;}
+ $note = $check;
+ $process = 'Intel 14nm';
+ $year = '2018';}
# note: had it as > 13, but 0xC seems to be CL
elsif ($stepping >= 13){
- $arch = 'Comet Lake'} # guess, have not seen docs yet
+ $arch = 'Comet Lake'; # guess, have not seen docs yet
+ $process = 'Intel 14nm';
+ $year = '2019-20';}
# NOTE: not enough info to lock this down
else {
$arch = 'Kaby Lake';
- $note = $check;}
+ $note = $check;
+ $process = 'Intel 14nm';
+ $year = '~2018-20';}
}
elsif ($model =~ /^(8F)$/){
- $arch = 'Saphire Rapids'} # server
+ $arch = 'Sapphire Rapids';
+ $process = 'Intel 7 (10nm ESF)';
+ $year = '2021';} # server
elsif ($model =~ /^(97|9A)$/){
- $arch = 'Alder Lake';}
+ $arch = 'Alder Lake';
+ $process = 'Intel 7 (10nm ESF)';
+ $year = '2021';}
+ ## IDS UNKNOWN, release late 2022
+ # elsif ($model =~ /^()$/){
+ # $arch = 'Raptor Lake'; #
+ # $process = 'Intel 7 (10nm)';}
+ # elsif ($model =~ /^()$/){
+ # $arch = 'Meteor Lake';
+ # $process = 'Intel 4';}
+ # Granite Rapids: INtel 3 (7nm)
elsif ($model =~ /^(9E)$/){
if ($stepping == 9){
- $arch = 'Kaby Lake';}
+ $arch = 'Kaby Lake';
+ $process = 'Intel 14nm';
+ $year = '2018';}
elsif ($stepping >= 10 && $stepping <= 13){
- $arch = 'Coffee Lake'}
+ $arch = 'Coffee Lake';
+ $process = 'Intel 14nm';
+ $year = '2018';}
else {
$arch = 'Kaby Lake';
- $note = $check;}
+ $note = $check;
+ $process = 'Intel 14nm';
+ $year = '2018';}
}
elsif ($model =~ /^(A5)$/){
- $arch = 'Comet Lake'} # steppings 0-5
+ $arch = 'Comet Lake'; # stepping 0-5
+ $process = 'Intel 14nm';
+ $year = '2020';}
elsif ($model =~ /^(A7)$/){
- $arch = 'Rocket Lake'}
+ $arch = 'Rocket Lake'; # stepping 1
+ $process = 'Intel 14nm';
+ $year = '2021+';}
# More info: comet: shares family/model, need to find stepping numbers
# Coming: meteor lake; granite rapids; diamond rapids
}
# itanium 1 family 7 all recalled
elsif ($family eq 'B'){
if ($model =~ /^(0)$/){
- $arch = 'Knights Ferry'}
+ $arch = 'Knights Ferry';
+ $process = 'Intel 45nm';
+ $year = '2010-11';}
if ($model =~ /^(1)$/){
- $arch = 'Knights Corner'}
+ $arch = 'Knights Corner';
+ $process = 'Intel 22nm';
+ $year = '2012-13';}
}
+ # pentium 4
elsif ($family eq 'F'){
if ($model =~ /^(0|1)$/){
- $arch = 'Netburst Willamette'}
+ $arch = 'Netburst Willamette';
+ $process = 'Intel 180nm';
+ $year = '2000-01';}
elsif ($model =~ /^(2)$/){
- $arch = 'Netburst Northwood'}
+ $arch = 'Netburst Northwood';
+ $process = 'Intel 130nm';
+ $year = '2002-03';}
elsif ($model =~ /^(3)$/){
- $arch = 'Netburst Prescott'} # 6? Nocona
+ $arch = 'Netburst Prescott';
+ $process = 'Intel 90nm';
+ $year = '2004-06';} # 6? Nocona
elsif ($model =~ /^(4)$/){
if ($stepping == 1){
- $arch = 'Netburst Prescott'}
+ $arch = 'Netburst Prescott';
+ $process = 'Intel 90nm';
+ $year = '2004-06';}
else {
- $arch = 'Netburst Smithfield'} # 6? Nocona
+ $arch = 'Netburst Smithfield';
+ $process = 'Intel 90nm';
+ $year = '2005-06';} # 6? Nocona
}
elsif ($model =~ /^(6)$/){
- $arch = 'Netburst Presler'}
+ $arch = 'Netburst Presler';
+ $process = 'Intel 65nm';
+ $year = '2006';}
else {
- $arch = 'Netburst'}
+ $arch = 'Netburst';
+ $process = 'Intel 90-180nm';
+ $year = '2000-06';}
}
# this is not going to e accurate, WhiskyL or Kaby L can ID as Skylake
# but if it's a new cpu microarch not handled yet, it may give better
# than nothing result. This is intel only
# This is probably the gcc/clang -march/-mtune value, which is not
# necessarily the same as actual microarch, and varies between gcc/clang versions
- if (!$model){
+ if (!$arch){
my $file = '/sys/devices/cpu/caps/pmu_name';
- $model = main::reader($file,'strip',0) if -r $file;
- $note = $check if $model;
+ $arch = main::reader($file,'strip',0) if -r $file;
+ $note = $check if $arch;
+ }
+ # gen 1 had no gen, only 3 digits: Core i5-661 Core i5-655K; Core i5 M 520
+ # EXCEPT gen 1: Core i7-720QM Core i7-740QM Core i7-840QM
+ # 2nd: Core i5-2390T Core i7-11700F Core i5-8400
+ if ($name){
+ if ($name =~ /\bi[357][\s-]([A-Z][\s-]?)?(\d{3}([^\d]|\b)|[78][24]00M)/){
+ $gen = ($gen) ? "$gen (core 1)": 'core 1';
+ }
+ elsif ($name =~ /\bi[3579][\s-]([A-Z][\s-]?)?([2-9]|1[0-4])\d{3}/){
+ $gen = ($gen) ? "$gen (core $2)" : "core $2";
+ }
}
}
eval $end if $b_log;
- return [$arch,$note];
+ return [$arch,$note,$process,$gen,$year];
}
+## END CPU ARCH ##
sub cp_cpu_topology {
my ($counts,$topology) = @_;
my @alpha = qw(Single Dual Triple Quad);
@@ -11257,7 +11615,7 @@ sub cp_elbrus_data {
eval $start if $b_log;
my ($family_id,$model_id,$count,$arch) = @_;
# 0: cores
- my @return = (0,1,$arch);
+ my $return = [0,1,$arch];
my %cores = (
# key=family id + model id
'41' => 1,
@@ -11276,17 +11634,17 @@ sub cp_elbrus_data {
'6B' => 16,
'6C' => 2,
);
- $return[0] = $cores{$family_id . $model_id} if $cores{$family_id . $model_id};
- if ($return[0]){
- $return[1] = ($count % $return[0]) ? int($count/$return[0]) + 1 : $count/$return[0];
+ $return->[0] = $cores{$family_id . $model_id} if $cores{$family_id . $model_id};
+ if ($return->[0]){
+ $return->[1] = ($count % $return->[0]) ? int($count/$return->[0]) + 1 : $count/$return->[0];
}
eval $end if $b_log;
- return @return;
+ return $return;
}
sub cp_speed_data {
eval $start if $b_log;
my ($cpu,$cpu_sys) = @_;
- my %info;
+ my $info = {};
if (defined $cpu_sys->{'data'}){
if (defined $cpu_sys->{'data'}{'speeds'}{'min-freq'}){
$cpu->{'min-freq'} = $cpu_sys->{'data'}{'speeds'}{'min-freq'};
@@ -11331,47 +11689,47 @@ sub cp_speed_data {
if ($agg){
$cpu->{'avg-freq'} = int($agg/scalar @{$cpu->{'processors'}});
$cpu->{'cur-freq'} = $high;
- $info{'avg-speed-key'} = 'avg';
- $info{'speed'} = $cpu->{'avg-freq'};
+ $info->{'avg-speed-key'} = 'avg';
+ $info->{'speed'} = $cpu->{'avg-freq'};
if ($high > $cpu->{'avg-freq'}){
$cpu->{'high-freq'} = $high;
- $info{'high-speed-key'} = 'high';
+ $info->{'high-speed-key'} = 'high';
}
}
}
elsif ($cpu->{'processors'}[0]) {
$cpu->{'cur-freq'} = $cpu->{'processors'}[0];
- $info{'speed'} = $cpu->{'cur-freq'};
+ $info->{'speed'} = $cpu->{'cur-freq'};
}
}
# BSDs generally will have processors count, but not per core speeds
- if ($cpu->{'cur-freq'} && !$info{'speed'}){
- $info{'speed'} = $cpu->{'cur-freq'};
+ if ($cpu->{'cur-freq'} && !$info->{'speed'}){
+ $info->{'speed'} = $cpu->{'cur-freq'};
}
if ($cpu->{'min-freq'} || $cpu->{'max-freq'}){
- ($info{'min-max'},$info{'min-max-key'}) = cp_speed_min_max(
+ ($info->{'min-max'},$info->{'min-max-key'}) = cp_speed_min_max(
$cpu->{'min-freq'},
$cpu->{'max-freq'});
}
if ($cpu->{'scaling-min-freq'} || $cpu->{'scaling-max-freq'}){
- ($info{'scaling-min-max'},$info{'scaling-min-max-key'}) = cp_speed_min_max(
+ ($info->{'scaling-min-max'},$info->{'scaling-min-max-key'}) = cp_speed_min_max(
$cpu->{'scaling-min-freq'},
$cpu->{'scaling-max-freq'},
'sc');
}
if ($cpu->{'cur-freq'}){
if ($show{'short'}){
- $info{'speed-key'} = 'speed';
+ $info->{'speed-key'} = 'speed';
}
elsif ($show{'cpu-basic'}){
- $info{'speed-key'} = 'speed (MHz)';
+ $info->{'speed-key'} = 'speed (MHz)';
}
else {
- $info{'speed-key'} = 'Speed (MHz)';
+ $info->{'speed-key'} = 'Speed (MHz)';
}
}
eval $end if $b_log;
- return \%info;
+ return $info;
}
sub cp_speed_min_max {
my ($min,$max,$type) = @_;
@@ -11441,7 +11799,7 @@ sub cpu_vendor {
}
# do not define model-id, stepping, or revision, those can be 0 valid value
sub set_cpu_data {
- my %cpu = (
+ ${$_[0]} = {
'arch' => '',
'avg-freq' => 0, # MHz
'bogomips' => 0,
@@ -11461,12 +11819,12 @@ sub set_cpu_data {
'scalings' => [],
'siblings' => 0,
'type' => '',
- );
- return %cpu;
+ };
}
sub system_cpu_name {
eval $start if $b_log;
- my (%cpus,$compat,@working);
+ my ($compat,@working);
+ my $cpus = {};
if (@working = main::globber('/sys/firmware/devicetree/base/cpus/cpu@*/compatible')){
foreach my $file (@working){
$compat = main::reader($file,'',0);
@@ -11475,7 +11833,7 @@ sub system_cpu_name {
# splits for: null 00/start header 01/start text 02/end text 03
$compat = (split(/\x01|\x02|\x03|\x00/, $compat))[0] if $compat;
$compat = (split(/,\s*/, $compat))[-1] if $compat;
- $cpus{$compat} = ($cpus{$compat}) ? ++$cpus{$compat}: 1;
+ $cpus->{$compat} = ($cpus->{$compat}) ? ++$cpus->{$compat}: 1;
}
}
# synthesize it, [4] will be like: cortex-a15-timer; sunxi-timer
@@ -11485,12 +11843,12 @@ sub system_cpu_name {
next if $working->[0] ne 'timer' || !$working->[4] || $working->[4] =~ /timer-mem$/;
$working->[4] =~ s/(-system)?-timer$//;
$compat = $working->[4];
- $cpus{$compat} = ($cpus{$compat}) ? ++$cpus{$compat}: 1;
+ $cpus->{$compat} = ($cpus->{$compat}) ? ++$cpus->{$compat}: 1;
}
}
- main::log_data('dump','%cpus',\%cpus) if $b_log;
+ main::log_data('dump','%$cpus',$cpus) if $b_log;
eval $end if $b_log;
- return \%cpus;
+ return $cpus;
}
## CLEANERS/OUTPUT HANDLERS ##
@@ -11541,16 +11899,17 @@ my ($debugger_dir);
# main::writer("$debugger_dir/system-repo-data-urpmq.txt",\@data2) if $debugger_dir;
sub get {
eval $start if $b_log;
- my (@data,@rows,$key1,$val1);
my ($type) = @_;
$type ||= 'standard';
+ my ($key1,$val1);
+ my $rows = [];
my $num = 0;
- @data = drive_data($type);
+ my $data = drive_data($type);
# NOTE:
- if (@data){
+ if (@$data){
if ($type eq 'standard'){
- push(@rows,storage_output(\@data));
- push(@rows,drive_output(\@data)) if $show{'disk'} && @data;
+ storage_output($rows,$data);
+ drive_output($rows,$data) if $show{'disk'};
if ($bsd_type && !$dboot{'disk'} && $type eq 'standard' && $show{'disk'}){
$key1 = 'Drive Report';
my $file = $system_files{'dmesg-boot'};
@@ -11563,85 +11922,84 @@ sub get {
else {
$val1 = main::message('disk-data-bsd');
}
- push(@rows,{main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1,});
}
}
# used by short form, raw data returned
else {
- @rows = @data;
- # print Data::Dumper::Dumper \@rows;
+ $rows = $data;
+ # print Data::Dumper::Dumper $rows;
}
}
else {
$key1 = 'Message';
$val1 = main::message('disk-data');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
- if (!@rows){
+ if (!@$rows){
$key1 = 'Message';
$val1 = main::message('disk-data');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
# push(@rows,@data);
if ($show{'optical'} || $show{'optical-basic'}){
- push(@rows,OpticalItem::get());
+ OpticalItem::get($rows);
}
($b_hddtemp,$b_nvme,$hddtemp,$nvme,$vendors) = ();
(@by_id,@by_path) = ();
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub storage_output {
eval $start if $b_log;
- my ($disks) = @_;
- my (@rows);
+ my ($rows,$disks) = @_;
my ($num,$j) = (0,0);
my ($size,$size_value,$used) = ('','','');
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Local Storage') => '',
});
# print Data::Dumper::Dumper $disks;
$size = main::get_size($disks->[0]{'size'},'string','N/A');
if ($disks->[0]{'logical-size'}){
- $rows[$j]->{main::key($num++,1,2,'total')} = '';
- $rows[$j]->{main::key($num++,0,3,'raw')} = $size;
+ $rows->[$j]{main::key($num++,1,2,'total')} = '';
+ $rows->[$j]{main::key($num++,0,3,'raw')} = $size;
$size = main::get_size($disks->[0]{'logical-size'},'string');
$size_value = $disks->[0]{'logical-size'};
# print Data::Dumper::Dumper $disks;
- $rows[$j]->{main::key($num++,1,3,'usable')} = $size;
+ $rows->[$j]{main::key($num++,1,3,'usable')} = $size;
}
else {
$size_value = $disks->[0]{'size'} if $disks->[0]{'size'};
- $rows[$j]->{main::key($num++,0,2,'total')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'total')} = $size;
}
$used = main::get_size($disks->[0]{'used'},'string','N/A');
if ($extra > 0 && $disks->[0]{'logical-free'}){
$size = main::get_size($disks->[0]{'logical-free'},'string');
- $rows[$j]->{main::key($num++,0,4,'lvm-free')} = $size;
+ $rows->[$j]{main::key($num++,0,4,'lvm-free')} = $size;
}
if (($size_value && $size_value =~ /^[0-9]/) &&
($used && $disks->[0]{'used'} =~ /^[0-9]/)){
$used = $used . ' (' . sprintf("%0.1f", $disks->[0]{'used'}/$size_value*100) . '%)';
}
- $rows[$j]->{main::key($num++,0,2,'used')} = $used;
+ $rows->[$j]{main::key($num++,0,2,'used')} = $used;
shift @$disks;
eval $end if $b_log;
- return @rows;
}
sub drive_output {
eval $start if $b_log;
- my ($disks) = @_;
+ my ($rows,$disks) = @_;
# print Data::Dumper::Dumper $disks;
- my ($b_smart_permissions,@rows,$smart_age,$smart_basic,$smart_fail);
+ my ($b_smart_permissions,$smart_age,$smart_basic,$smart_fail);
my ($num,$j) = (0,0);
my ($id,$model,$size) = ('','','');
# note: specific smartctl non-missing errors handled inside loop
if ($smartctl_missing){
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,0,1,'SMART Message')} = $smartctl_missing;
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,0,1,'SMART Message')} = $smartctl_missing;
}
elsif ($b_admin){
- ($smart_age,$smart_basic,$smart_fail) = smartctl_fields();
+ my $result = smartctl_fields();
+ ($smart_age,$smart_basic,$smart_fail) = @$result;
}
foreach my $row (sort { $a->{'id'} cmp $b->{'id'} } @$disks){
($id,$model,$size) = ('','','');
@@ -11650,52 +12008,52 @@ sub drive_output {
$id = ($row->{'id'}) ? "/dev/$row->{'id'}":'N/A';
$size = ($row->{'size'}) ? main::get_size($row->{'size'},'string') : 'N/A';
# print Data::Dumper::Dumper $disks;
- $j = scalar @rows;
+ $j = scalar @$rows;
if (!$b_smart_permissions && $row->{'smart-permissions'}){
$b_smart_permissions = 1;
- $rows[$j]->{main::key($num++,0,1,'SMART Message')} = $row->{'smart-permissions'};
- $j = scalar @rows;
+ $rows->[$j]{main::key($num++,0,1,'SMART Message')} = $row->{'smart-permissions'};
+ $j = scalar @$rows;
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'ID') => $id,
});
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
}
if ($row->{'type'}){
- $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'type'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $row->{'type'};
}
if ($row->{'vendor'}){
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $row->{'vendor'};
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $row->{'vendor'};
}
- $rows[$j]->{main::key($num++,0,2,'model')} = $model;
+ $rows->[$j]{main::key($num++,0,2,'model')} = $model;
if ($row->{'drive-vendor'}){
- $rows[$j]->{main::key($num++,0,2,'drive vendor')} = $row->{'drive-vendor'};
+ $rows->[$j]{main::key($num++,0,2,'drive vendor')} = $row->{'drive-vendor'};
}
if ($row->{'drive-model'}){
- $rows[$j]->{main::key($num++,0,2,'drive model')} = $row->{'drive-model'};
+ $rows->[$j]{main::key($num++,0,2,'drive model')} = $row->{'drive-model'};
}
if ($row->{'family'}){
- $rows[$j]->{main::key($num++,0,2,'family')} = $row->{'family'};
+ $rows->[$j]{main::key($num++,0,2,'family')} = $row->{'family'};
}
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
if ($b_admin && $row->{'block-physical'}){
- $rows[$j]->{main::key($num++,1,2,'block-size')} = '';
- $rows[$j]->{main::key($num++,0,3,'physical')} = $row->{'block-physical'} . ' B';
- $rows[$j]->{main::key($num++,0,3,'logical')} = ($row->{'block-logical'}) ? $row->{'block-logical'} . ' B' : 'N/A';
+ $rows->[$j]{main::key($num++,1,2,'block-size')} = '';
+ $rows->[$j]{main::key($num++,0,3,'physical')} = $row->{'block-physical'} . ' B';
+ $rows->[$j]{main::key($num++,0,3,'logical')} = ($row->{'block-logical'}) ? $row->{'block-logical'} . ' B' : 'N/A';
}
if ($extra > 1 && $row->{'speed'}){
if ($row->{'sata'}){
- $rows[$j]->{main::key($num++,0,2,'sata')} = $row->{'sata'};
+ $rows->[$j]{main::key($num++,0,2,'sata')} = $row->{'sata'};
}
- $rows[$j]->{main::key($num++,0,2,'speed')} = $row->{'speed'};
- $rows[$j]->{main::key($num++,0,2,'lanes')} = $row->{'lanes'} if $row->{'lanes'};
+ $rows->[$j]{main::key($num++,0,2,'speed')} = $row->{'speed'};
+ $rows->[$j]{main::key($num++,0,2,'lanes')} = $row->{'lanes'} if $row->{'lanes'};
}
if ($extra > 2){
$row->{'drive-type'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'drive-type'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $row->{'drive-type'};
if ($row->{'rotation'}){
- $rows[$j]->{main::key($num++,0,2,'rpm')} = $row->{'rotation'};
+ $rows->[$j]{main::key($num++,0,2,'rpm')} = $row->{'rotation'};
}
}
if ($extra > 1){
@@ -11706,45 +12064,44 @@ sub drive_output {
else {
$row->{'serial'} = main::filter($row->{'serial'});
}
- $rows[$j]->{main::key($num++,0,2,'serial')} = $row->{'serial'};
+ $rows->[$j]{main::key($num++,0,2,'serial')} = $row->{'serial'};
if ($row->{'drive-serial'}){
- $rows[$j]->{main::key($num++,0,2,'drive serial')} = main::filter($row->{'drive-serial'});
+ $rows->[$j]{main::key($num++,0,2,'drive serial')} = main::filter($row->{'drive-serial'});
}
if ($row->{'firmware'}){
- $rows[$j]->{main::key($num++,0,2,'rev')} = $row->{'firmware'};
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $row->{'firmware'};
}
if ($row->{'drive-firmware'}){
- $rows[$j]->{main::key($num++,0,2,'drive rev')} = $row->{'drive-firmware'};
+ $rows->[$j]{main::key($num++,0,2,'drive rev')} = $row->{'drive-firmware'};
}
}
if ($extra > 0 && $row->{'temp'}){
- $rows[$j]->{main::key($num++,0,2,'temp')} = $row->{'temp'} . ' C';
+ $rows->[$j]{main::key($num++,0,2,'temp')} = $row->{'temp'} . ' C';
}
if ($extra > 1 && $alerts{'bioctl'}){
if (!$row->{'duid'} && $alerts{'bioctl'}->{'action'} eq 'permissions'){
- $rows[$j]->{main::key($num++,0,2,'duid')} = main::message('root-required');
+ $rows->[$j]{main::key($num++,0,2,'duid')} = main::message('root-required');
}
elsif ($row->{'duid'}){
- $rows[$j]->{main::key($num++,0,2,'duid')} = main::filter($row->{'duid'});
+ $rows->[$j]{main::key($num++,0,2,'duid')} = main::filter($row->{'duid'});
}
}
# extra level tests already done
if (defined $row->{'partition-table'}){
- $rows[$j]->{main::key($num++,0,2,'scheme')} = $row->{'partition-table'};
+ $rows->[$j]{main::key($num++,0,2,'scheme')} = $row->{'partition-table'};
}
if ($row->{'smart'} || $row->{'smart-error'}){
- $j = scalar @rows;
+ $j = scalar @$rows;
## Basic SMART and drive info ##
- smart_output('basic',$smart_basic,$row,$j,\$num,\@rows);
+ smart_output('basic',$smart_basic,$row,$j,\$num,$rows);
## Old-Age errors ##
- smart_output('age',$smart_age,$row,$j,\$num,\@rows);
+ smart_output('age',$smart_age,$row,$j,\$num,$rows);
## Pre-Fail errors ##
- smart_output('fail',$smart_fail,$row,$j,\$num,\@rows);
+ smart_output('fail',$smart_fail,$row,$j,\$num,$rows);
}
}
eval $end if $b_log;
- return @rows;
}
# $num and $rows passed by reference
sub smart_output {
@@ -11763,7 +12120,7 @@ sub smart_output {
}
elsif ($type eq 'age'){$key = 'Old-Age';}
elsif ($type eq 'fail'){$key = 'Pre-Fail';}
- $$rows[$j]->{main::key($$num++,1,$l,$key)} = $support;
+ $rows->[$j]{main::key($$num++,1,$l,$key)} = $support;
$b_found = 1;
next if $type eq 'basic';
}
@@ -11778,7 +12135,7 @@ sub smart_output {
($p,$m) = ($p_h,$m_h);
}
}
- $$rows[$j]->{main::key($$num++,$p,$m,$smart_data->[$i][1])} = $row->{$smart_data->[$i][0]};
+ $rows->[$j]{main::key($$num++,$p,$m,$smart_data->[$i][1])} = $row->{$smart_data->[$i][0]};
}
}
eval $end if $b_log;
@@ -11787,7 +12144,7 @@ sub smart_output {
sub drive_data {
eval $start if $b_log;
my ($type) = @_;
- my (@rows,@data,@devs);
+ my ($data,@devs);
my $num = 0;
my ($used) = (0);
PartitionItem::set_partitions() if !$loaded{'set-partitions'};
@@ -11811,28 +12168,28 @@ sub drive_data {
}
}
if (!$bsd_type){
- @data = proc_data($used);
+ $data = proc_data($used);
}
else {
- @data = bsd_data($used);
+ $data = bsd_data($used);
}
if ($b_admin){
if ($alerts{'smartctl'} && $alerts{'smartctl'}->{'action'} eq 'use'){
- @data = smartctl_data(\@data);
+ smartctl_data($data);
}
else {
$smartctl_missing = $alerts{'smartctl'}->{'message'};
}
}
- print Data::Dumper::Dumper \@data if $dbg[13];;
+ print Data::Dumper::Dumper $data if $dbg[13];
main::log_data('data',"used: $used") if $b_log;
eval $end if $b_log;
- return @data;
+ return $data;
}
sub proc_data {
eval $start if $b_log;
my ($used) = @_;
- my (@data,@drives);
+ my (@drives);
my ($b_hdx,$logical_size,$size) = (0,0,0);
PartitionData::set() if !$bsd_type && !$loaded{'partition-data'};
foreach my $row (@proc_partitions){
@@ -11879,29 +12236,29 @@ sub proc_data {
}
# print Data::Dumper::Dumper \@drives;
main::log_data('data',"size: $size") if $b_log;
- @data = ({
+ my $result = [{
'logical-size' => $logical_size,
'logical-free' => $raw_logical[2],
'size' => $size,
'used' => $used,
- });
+ }];
# print Data::Dumper::Dumper \@data;
if ($show{'disk'}){
- unshift(@drives,@data);
+ unshift(@drives,@$result);
# print 'drives:', Data::Dumper::Dumper \@drives;
- @data = proc_data_advanced($b_hdx,\@drives);
+ $result = proc_data_advanced($b_hdx,\@drives);
}
- main::log_data('dump','@data',\@data) if $b_log;
- print Data::Dumper::Dumper \@data if $dbg[24];
+ main::log_data('dump','@$result',$result) if $b_log;
+ print Data::Dumper::Dumper $result if $dbg[24];
eval $end if $b_log;
- return @data;
+ return $result;
}
sub proc_data_advanced {
eval $start if $b_log;
my ($b_hdx,$drives) = @_;
my ($i) = (0);
- my (@data,@disk_data,@rows,@scsi,@temp,@working);
+ my ($disk_data,$scsi,@temp,@working);
my ($pt_cmd) = ('unset');
my ($block_type,$file,$firmware,$model,$path,
$partition_scheme,$serial,$vendor,$working_path);
@@ -11928,7 +12285,7 @@ sub proc_data_advanced {
}
# scsi stuff
if ($file = $system_files{'proc-scsi'}){
- @scsi = scsi_data($file);
+ $scsi = scsi_data($file);
}
# print 'drives:', Data::Dumper::Dumper $drives;
for ($i = 1; $i < scalar @$drives; $i++){
@@ -11936,8 +12293,8 @@ sub proc_data_advanced {
($block_type,$firmware,$model,$partition_scheme,
$serial,$vendor,$working_path) = ('','','','','','','');
# print "$drives->[$i]{'id'}\n";
- @disk_data = disk_data_by_id("/dev/$drives->[$i]{'id'}");
- main::log_data('dump','@disk_data', \@disk_data) if $b_log;
+ $disk_data = disk_data_by_id("/dev/$drives->[$i]{'id'}");
+ main::log_data('dump','@$disk_data', $disk_data) if $b_log;
if ($drives->[$i]{'id'} =~ /[sv]d[a-z]/){
$block_type = 'sdx';
$working_path = "/sys/block/$drives->[$i]{'id'}/device/";
@@ -11956,16 +12313,15 @@ sub proc_data_advanced {
}
main::log_data('data',"working path: $working_path") if $b_log;
if ($b_admin && -e "/sys/block/"){
- my @working = block_data($drives->[$i]{'id'});
- $drives->[$i]{'block-logical'} = $working[0];
- $drives->[$i]{'block-physical'} = $working[1];
+ ($drives->[$i]{'block-logical'},$drives->[$i]{'block-physical'}) = @{block_data($drives->[$i]{'id'})};
}
- if ($block_type && @scsi && @by_id && ! -e "${working_path}model" && ! -e "${working_path}name"){
+ if ($block_type && $scsi && @$scsi && @by_id && ! -e "${working_path}model" &&
+ ! -e "${working_path}name"){
## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the
# discovered disk name AND ends with the correct identifier, sdx
# get rid of whitespace for some drive names and ids, and extra data after - in name
SCSI:
- foreach my $row (@scsi){
+ foreach my $row (@$scsi){
if ($row->{'model'}){
$row->{'model'} = (split(/\s*-\s*/,$row->{'model'}))[0];
foreach my $id (@by_id){
@@ -11981,7 +12337,7 @@ sub proc_data_advanced {
}
# note: an entire class of model names gets truncated by /sys so that should be the last
# in priority re tests.
- elsif ((!@disk_data || !$disk_data[0]) && $block_type){
+ elsif ((!@$disk_data || !$disk_data->[0]) && $block_type){
# NOTE: while path ${working_path}vendor exists, it contains junk value, like: ATA
$path = "${working_path}model";
if (-r $path){
@@ -11994,16 +12350,16 @@ sub proc_data_advanced {
$drives->[$i]{'model'} = $model if $model;
}
}
- if (!$drives->[$i]{'model'} && @disk_data){
- $drives->[$i]{'model'} = $disk_data[0] if $disk_data[0];
- $drives->[$i]{'vendor'} = $disk_data[1] if $disk_data[1];
+ if (!$drives->[$i]{'model'} && @$disk_data){
+ $drives->[$i]{'model'} = $disk_data->[0] if $disk_data->[0];
+ $drives->[$i]{'vendor'} = $disk_data->[1] if $disk_data->[1];
}
# maybe rework logic if find good scsi data example, but for now use this
elsif ($drives->[$i]{'model'} && !$drives->[$i]{'vendor'}){
$drives->[$i]{'model'} = main::clean_disk($drives->[$i]{'model'});
- my @device_data = device_vendor($drives->[$i]{'model'},'');
- $drives->[$i]{'model'} = $device_data[1] if $device_data[1];
- $drives->[$i]{'vendor'} = $device_data[0] if $device_data[0];
+ my $result = disk_vendor($drives->[$i]{'model'},'');
+ $drives->[$i]{'model'} = $result->[1] if $result->[1];
+ $drives->[$i]{'vendor'} = $result->[0] if $result->[0];
}
if ($working_path){
$path = "${working_path}removable";
@@ -12016,11 +12372,12 @@ sub proc_data_advanced {
if ($extra > 0){
$drives->[$i]{'temp'} = hdd_temp("$drives->[$i]{'id'}");
if ($extra > 1){
- my @speed_data = device_speed($drives->[$i]{'id'});
- $drives->[$i]{'speed'} = $speed_data[0] if $speed_data[0];
- $drives->[$i]{'lanes'} = $speed_data[1] if $speed_data[1];
- if (@disk_data && $disk_data[2]){
- $drives->[$i]{'serial'} = $disk_data[2];
+ my $speed_data = drive_speed($drives->[$i]{'id'});
+ # only assign if defined / not 0
+ $drives->[$i]{'speed'} = $speed_data->[0] if $speed_data->[0];
+ $drives->[$i]{'lanes'} = $speed_data->[1] if $speed_data->[1];
+ if (@$disk_data && $disk_data->[2]){
+ $drives->[$i]{'serial'} = $disk_data->[2];
}
else {
$path = "${working_path}serial";
@@ -12042,26 +12399,26 @@ sub proc_data_advanced {
}
}
if ($extra > 2){
- @data = disk_data_advanced($pt_cmd,$drives->[$i]{'id'});
- $pt_cmd = $data[0];
- $drives->[$i]{'partition-table'} = uc($data[1]) if $data[1];
- if ($data[2]){
- $drives->[$i]{'rotation'} = $data[2];
+ my $result = disk_data_advanced($pt_cmd,$drives->[$i]{'id'});
+ $pt_cmd = $result->[0];
+ $drives->[$i]{'partition-table'} = uc($result->[1]) if $result->[1];
+ if ($result->[2]){
+ $drives->[$i]{'rotation'} = $result->[2];
$drives->[$i]{'drive-type'} = 'HDD';
}
elsif (($block_type && $block_type ne 'sdx') ||
# note: this case could conceivabley be wrong for a spun down HDD
- (defined $data[2] && $data[2] eq '0') ||
+ (defined $result->[2] && $result->[2] eq '0') ||
($drives->[$i]{'model'} &&
$drives->[$i]{'model'} =~ /(flash|mmc|msata|\bm[\.-]?2\b|nvme|ssd|solid\s?state)/i)){
$drives->[$i]{'drive-type'} = 'SSD';
}
}
}
- main::log_data('dump','$drives',\$drives) if $b_log;
+ main::log_data('dump','$drives',$drives) if $b_log;
print Data::Dumper::Dumper $drives if $dbg[24];
eval $end if $b_log;
- return @$drives;
+ return $drives;
}
# camcontrol identify <device> |grep ^serial (this might be (S)ATA specific)
# smartcl -i <device> |grep ^Serial
@@ -12069,7 +12426,7 @@ sub proc_data_advanced {
sub bsd_data {
eval $start if $b_log;
my ($used) = @_;
- my (@data,@drives,@softraid,@temp);
+ my (@drives,@softraid,@temp);
my ($i,$logical_size,$size,$working) = (0,0,0,0);
my $file = $system_files{'dmesg-boot'};
DiskDataBSD::set() if !$loaded{'disk-data-bsd'};
@@ -12106,9 +12463,9 @@ sub bsd_data {
# generate the synthetic model/vendor data
$drives[$i]->{'model'} = $disks_bsd{$id}->{'model'};
if ($drives[$i]->{'model'}){
- my @device_data = device_vendor($drives[$i]->{'model'},'');
- $drives[$i]->{'vendor'} = $device_data[0] if $device_data[0];
- $drives[$i]->{'model'} = $device_data[1] if $device_data[1];
+ my $result = disk_vendor($drives[$i]->{'model'},'');
+ $drives[$i]->{'vendor'} = $result->[0] if $result->[0];
+ $drives[$i]->{'model'} = $result->[1] if $result->[1];
}
if ($disks_bsd{$id}->{'duid'}){
$drives[$i]->{'duid'} = $disks_bsd{$id}->{'duid'};
@@ -12129,28 +12486,28 @@ sub bsd_data {
$size = main::message('data-bsd');
}
}
- @data = ({
+ my $result = [{
'logical-size' => $logical_size,
'logical-free' => $raw_logical[2],
'size' => $size,
'used' => $used,
- });
+ }];
#main::log_data('dump','$data',\@data) if $b_log;
if ($show{'disk'}){
- push(@data,@drives);
+ push(@$result,@drives);
# print 'data:', Data::Dumper::Dumper \@data;
}
- main::log_data('dump','$data',\@data) if $b_log;
- print Data::Dumper::Dumper \@data if $dbg[24];
+ main::log_data('dump','$result',$result) if $b_log;
+ print Data::Dumper::Dumper $result if $dbg[24];
eval $end if $b_log;
- return @data;
+ return $result;
}
# return indexes: 0 - age; 1 - basic; 2 - fail
# make sure to update if fields added in smartctl_data()
sub smartctl_fields {
eval $start if $b_log;
- my @data = (
+ my $data = [
[ # age
['smart-gsense-error-rate-ar','g-sense error rate'],
['smart-media-wearout-a','media wearout'],
@@ -12231,9 +12588,9 @@ sub smartctl_fields {
['smart-unknown-5-t','threshold'],
['smart-unknown-5-f','alert'],
]
- );
+ ];
eval $end if $b_log;
- return @data;
+ return $data;
}
sub smartctl_data {
@@ -12303,20 +12660,24 @@ sub smartctl_data {
$b_kingston = 1 if $split[$r] =~/kingston/i;
# usb/firewire/thunderbolt enclosure id method
if ($data->[$i]{'type'}){
- @working = device_vendor("$split[$r]");
- $data->[$i]{'drive-model'} = $working[1] if $data->[$i]{'model'} && $data->[$i]{'model'} ne $working[1];
- $data->[$i]{'drive-vendor'} = $working[0] if $data->[$i]{'vendor'} && $data->[$i]{'vendor'} ne $working[0];
+ my $result = disk_vendor("$split[$r]");
+ if ($data->[$i]{'model'} && $data->[$i]{'model'} ne $result->[1]){
+ $data->[$i]{'drive-model'} = $result->[1];
+ }
+ if ($data->[$i]{'vendor'} && $data->[$i]{'vendor'} ne $result->[0]){
+ $data->[$i]{'drive-vendor'} = $result->[0];
+ }
}
# fallback for very corner cases where primary model id failed
if (!$data->[$i]{'model'} && $split[$r]){
- @working = device_vendor("$split[$r]");
- $data->[$i]{'model'} = $working[1] if $working[1];
- $data->[$i]{'vendor'} = $working[0] if $working[0] && !$data->[$i]{'vendor'};
+ my $result = disk_vendor("$split[$r]");
+ $data->[$i]{'model'} = $result->[1] if $result->[1];
+ $data->[$i]{'vendor'} = $result->[0] if $result->[0] && !$data->[$i]{'vendor'};
}
}
elsif ($split[$a] eq 'Model Family'){
- @working = device_vendor("$split[$r]");
- $data->[$i]{'family'} = $working[1];
+ my $result = disk_vendor("$split[$r]");
+ $data->[$i]{'family'} = $result->[1] if $result->[1];
# $data->[$i]{'family'} =~ s/$data->[$i]{'vendor'}\s*// if $data->[$i]{'vendor'};
}
elsif ($split[$a] eq 'Firmware Version'){
@@ -12628,7 +12989,6 @@ sub smartctl_data {
}
print Data::Dumper::Dumper $data if $dbg[19];
eval $end if $b_log;
- return @$data;
}
# check for usb/firewire/[and thunderbolt when data found]
@@ -12671,29 +13031,30 @@ sub peripheral_data {
sub disk_data_advanced {
eval $start if $b_log;
my ($set_cmd,$id) = @_;
- my ($cmd,$pt,$program,@data,@return);
+ my ($cmd,$pt,$program,@data);
+ my $advanced = [];
if ($set_cmd ne 'unset'){
- $return[0] = $set_cmd;
+ $advanced->[0] = $set_cmd;
}
else {
# runs as user, but is SLOW: udisksctl info -b /dev/sda
# line: org.freedesktop.UDisks2.PartitionTable:
# Type: dos
if ($program = main::check_program('udevadm')){
- $return[0] = "$program info -q property -n ";
+ $advanced->[0] = "$program info -q property -n ";
}
elsif ($b_root && -e "/lib/udev/udisks-part-id"){
- $return[0] = "/lib/udev/udisks-part-id /dev/";
+ $advanced->[0] = "/lib/udev/udisks-part-id /dev/";
}
elsif ($b_root && ($program = main::check_program('fdisk'))){
- $return[0] = "$program -l /dev/";
+ $advanced->[0] = "$program -l /dev/";
}
- if (!$return[0]){
- $return[0] = 'na'
+ if (!$advanced->[0]){
+ $advanced->[0] = 'na'
}
}
- if ($return[0] ne 'na'){
- $cmd = "$return[0]$id 2>&1";
+ if ($advanced->[0] ne 'na'){
+ $cmd = "$advanced->[0]$id 2>&1";
main::log_data('cmd',$cmd) if $b_log;
@data = main::grabber($cmd);
# for pre ~ 2.30 fdisk did not show gpt, but did show gpt scheme error, so
@@ -12701,39 +13062,39 @@ sub disk_data_advanced {
if ($cmd =~ /fdisk/){
foreach (@data){
if (/^WARNING:\s+GPT/){
- $return[1] = 'gpt';
+ $advanced->[1] = 'gpt';
last;
}
elsif (/^Disklabel\stype:\s*(.+)/i){
- $return[1] = $1;
+ $advanced->[1] = $1;
last;
}
}
- $return[1] = 'dos' if !$return[1];
+ $advanced->[1] = 'dos' if !$advanced->[1];
}
else {
foreach (@data){
if (/^(UDISKS_PARTITION_TABLE_SCHEME|ID_PART_TABLE_TYPE)/){
my @working = split('=', $_);
- $return[1] = $working[1];
+ $advanced->[1] = $working[1];
}
elsif (/^ID_ATA_ROTATION_RATE_RPM/){
my @working = split('=', $_);
- $return[2] = $working[1];
+ $advanced->[2] = $working[1];
}
- last if defined $return[1] && defined $return[2];
+ last if defined $advanced->[1] && defined $advanced->[2];
}
}
- $return[1] = 'mbr' if $return[1] && lc($return[1]) eq 'dos';
+ $advanced->[1] = 'mbr' if $advanced->[1] && lc($advanced->[1]) eq 'dos';
}
eval $end if $b_log;
- return @return;
+ return $advanced;
}
sub scsi_data {
eval $start if $b_log;
my ($file) = @_;
my @temp = main::reader($file);
- my (@scsi);
+ my $scsi = [];
my ($firmware,$model,$vendor) = ('','','');
foreach (@temp){
if (/Vendor:\s*(.*)\s+Model:\s*(.*)\s+Rev:\s*(.*)/i){
@@ -12743,7 +13104,7 @@ sub scsi_data {
}
if (/Type:/i){
if (/Type:\s*Direct-Access/i){
- push(@scsi, {
+ push(@$scsi, {
'vendor' => $vendor,
'model' => $model,
'firmware' => $firmware,
@@ -12754,20 +13115,19 @@ sub scsi_data {
}
}
}
- main::log_data('dump','@scsi', \@scsi) if $b_log;
+ main::log_data('dump','@$scsi', $scsi) if $b_log;
eval $end if $b_log;
- return @scsi;
+ return $scsi;
}
# @b_id has already been cleaned of partitions, wwn-, nvme-eui
sub disk_data_by_id {
eval $start if $b_log;
my ($device) = @_;
my ($model,$serial,$vendor) = ('','','');
- my (@disk_data);
+ my $disk_data = [];
foreach (@by_id){
if ($device eq Cwd::abs_path($_)){
my @data = split('_', $_);
- my @device_data;
last if scalar @data < 2; # scsi-3600508e000000000876995df43efa500
$serial = pop @data if @data;
# usb-PNY_USB_3.0_FD_3715202280-0:0
@@ -12776,19 +13136,20 @@ sub disk_data_by_id {
# get rid of the ata-|nvme-|mmc- etc
$model =~ s/^\/dev\/disk\/by-id\/([^-]+-)?//;
$model = main::clean_disk($model);
- @device_data = device_vendor($model,$serial);
- $vendor = $device_data[0] if $device_data[0];
- $model = $device_data[1] if $device_data[1];
+ my $result = disk_vendor($model,$serial);
+ $vendor = $result->[0] if $result->[0];
+ $model = $result->[1] if $result->[1];
# print $device, '::', Cwd::abs_path($_),'::', $model, '::', $vendor, '::', $serial, "\n";
- (@disk_data) = ($model,$vendor,$serial);
+ @$disk_data = ($model,$vendor,$serial);
last;
}
}
eval $end if $b_log;
- return @disk_data;
+ return $disk_data;
}
+## START DISK VENDOR BLOCK ##
# 0 - match pattern; 1 - replace pattern; 2 - vendor print; 3 - serial pattern
-sub set_vendors {
+sub set_disk_vendors {
eval $start if $b_log;
$vendors = [
## MOST LIKELY/COMMON MATCHES ##
@@ -12796,20 +13157,20 @@ sub set_vendors {
# H10 HBRPEKNX0202A NVMe INTEL 512GB
['(\bINTEL\b|^(SSD(PAM|SA2)|HBR|(MEM|SSD)PEB?K|SSD(MCE|S[AC])))','\bINTEL\b','Intel',''],
# note: S[AV][1-9]\d can trigger false positives
- ['(K(ING)?STON|^(OM8P|RBU|S[AV][1234]00|S[HMN]S|SK[CY]|SQ5|SS200|SVP|SS0|SUV|SNV|T52|T[AB]29|Ultimate CF)|DataTraveler|DT\s?(DUO|Microduo|101)|HyperX|13fe\b)','(KINGSTON|13fe)','Kingston',''], # maybe SHS: SHSS37A SKC SUV
+ ['(K(ING)?STON|^(OM8P|RBU|S[AV][1234]00|S[HMN]S|SK[CY]|SQ5|SS200|SVP|SS0|SUV|SNV|T52|T[AB]29|Ultimate CF)|V100|DataTraveler|DT\s?(DUO|Microduo|101)|HyperX|13fe\b)','(KINGSTON|13fe)','Kingston',''], # maybe SHS: SHSS37A SKC SUV
# must come before samsung MU. NOTE: toshiba can have: TOSHIBA_MK6475GSX: mush: MKNSSDCR120GB_
['(^MKN|Mushkin)','Mushkin','Mushkin',''], # MKNS
# MU = Multiple_Flash_Reader too risky: |M[UZ][^L] HD103SI HD start risky
# HM320II HM320II HM
- ['(SAMSUNG|^(AWMB|[BC]DS20|[BC]WB|BJ[NT]|CJN|CUT|[DG]3 Station|DUO\b|DUT|CKT|[GS]2 Portable|GN|HD\d{3}[A-Z]{2}$|(HM|SP)\d{2}|HS\d|M[AB]G\d[FG]|MCC|MCBOE|MCG\d+GC|[CD]JN|MZ|^G[CD][1-9][QS]|P[BM]\d|(SSD\s?)?SM\s?841)|^SSD\s?[89]\d{2}\s(DCT|PRO|QVD|\d+[GT]B)|\bEVO\b|SV\d|[BE][A-Z][1-9]QT|YP\b|[CH]N-M|MMC[QR]E)','SAMSUNG','Samsung',''], # maybe ^SM, ^HM
+ ['(SAMSUNG|^(AWMB|[BC]DS20|[BC]WB|BJ[NT]|[BC]GND|CJN|CUT|[DG]3 Station|DUO\b|DUT|CKT|[GS]2 Portable|GN|HD\d{3}[A-Z]{2}$|(HM|SP)\d{2}|HS\d|M[AB]G\d[FG]|MCC|MCBOE|MCG\d+GC|[CD]JN|MZ|^G[CD][1-9][QS]|P[BM]\d|(SSD\s?)?SM\s?841)|^SSD\s?[89]\d{2}\s(DCT|PRO|QVD|\d+[GT]B)|\bEVO\b|SV\d|[BE][A-Z][1-9]QT|YP\b|[CH]N-M|MMC[QR]E)','SAMSUNG','Samsung',''], # maybe ^SM, ^HM
# Android UMS Composite?U1
- ['(SanDisk|^(ABLCD|AFGCE|D[AB]4|DX[1-9]|Extreme|Firebird|S[CD]\d{2}G|SD(S[S]?[ADQ]|SDW[1-9]|SEM[1-9]|SL(\d+)G|SU\d|U(3\b|1\d0))|\d[STU])|ULTRA\s(FIT|trek|II)|Clip Sport|Cruzer|iXpand|SSD (Plus|U1[01]0) [1-9]|0781|X[1-6]\d{2})','(SanDisk|0781)','SanDisk',''],
+ ['(SanDisk|0781|^(ABLCD|AFGCE|D[AB]4|DX[1-9]|Extreme|Firebird|S[CD]\d{2}G|SD(S[S]?[ADQ]|SL\d+G|SU\d)|SDW[1-9]|SEM[1-9]|\d[STU]|U(3\b|1\d0))|Clip Sport|Cruzer|iXpand|SSD (Plus|U1[01]0) [1-9]|ULTRA\s(FIT|trek|II)|X[1-6]\d{2})','(SanDisk|0781)','SanDisk',''],
# these are HP/Sandisk cobranded. DX110064A5xnNMRI ids as HP and Sandisc
['(^DX[1-9])','^(HP\b|SANDDISK)','Sandisk/HP',''], # ssd drive, must come before seagate ST test
# real, SSEAGATE Backup+; XP1600HE30002 | 024 HN (spinpoint) ; possible usb: 24AS
# ST[numbers] excludes other ST starting devices
- ['([S]?SEAGATE|^(^(Barra|Fire)Cuda|BUP|Expansion|(ATA\s|HDD\s)?ST\d{2}|5AS|X[AFP])|Expansion Desk|FreeAgent|GoFlex|Backup(\+|\s?Plus)\s?(Hub)?|OneTouch|Slim\s?BK)','[S]?SEAGATE','Seagate',''],
- ['^(WD|WL[0]9]|Western Digital|My (Book|Passport)|\d*LPCX|Elements|easystore|MD0|M000|EARX|EFRX|\d*EAVS|0JD|JP[CV]|\d+(BEV|(00)?AAK|AAV|AZL|EA[CD]S)|PC\sSN|3200[AB]|2500[BJ]|EA[A-Z]S|20G2|5000[AB]|6400[AB]|7500[AB]|i HTS|00[ABL][A-Z]{2}|EZRX|SSC\b)','(^WDC|Western\s?Digital)','Western Digital',''],
+ ['([S]?SEAGATE|^((Barra|Fire)Cuda|BUP|Expansion|(ATA\s|HDD\s)?ST\d{2}|5AS|X[AFP])|Expansion Desk|FreeAgent|GoFlex|INIC|Backup(\+|\s?Plus)\s?(Hub)?|OneTouch|Slim\s?BK)','[S]?SEAGATE','Seagate',''],
+ ['^(WD|WL[0]9]|Western Digital|My (Book|Passport)|\d*LPCX|Elements|easystore|EA[A-Z]S|EARX|EFRX|EZRX|\d*EAVS|G[\s-]Drive|i HTS|0JD|JP[CV]|MD0|M000|\d+(BEV|(00)?AAK|AAV|AZL|EA[CD]S)|PC\sSN|SPZX|3200[AB]|2500[BJ]|20G2|5000[AB]|6400[AB]|7500[AB]|00[ABL][A-Z]{2}|SSC\b)','(^WDC|Western\s?Digital)','Western Digital',''],
# rare cases WDC is in middle of string
['(\bWDC\b|1002FAEX)','','Western Digital',''],
## THEN BETTER KNOWN ONESs ##
@@ -12833,8 +13194,8 @@ sub set_vendors {
# these must come before maxtor because STM
['^STmagic','^STmagic','STmagic',''],
['^(STMicro|SMI|CBA)','^(STMicroelectronics|SMI)','SMI (STMicroelectronics)',''],
- # note M2 M3 is usually maxtor, but can be samsung: can conflict with Team: TM\d{4}|
- ['^(MAXTOR|Atlas|L(250|500)|[KL]0[1-9]|Y\d{3}[A-Z]|STM\d|F\d{3}L)','^MAXTOR','Maxtor',''],
+ # note M2 M3 is usually maxtor, but can be samsung. Can conflict with Team: TM\d{4}|
+ ['^(MAXTOR|Atlas|E0\d0L|L(250|500)|[KL]0[1-9]|Y\d{3}[A-Z]|STM\d|F\d{3}L)','^MAXTOR','Maxtor',''],
# OCZSSD2-2VTXE120G is OCZ-VERTEX2_3.5
['^(OCZ|Agility|APOC|D2|DEN|DEN|DRSAK|EC188|FTNC|GFGC|MANG|MMOC|NIMC|NIMR|PSIR|RALLY2|TALOS2|TMSC|TRSAK|VERTEX|Trion|Onyx|Vector[\s-]?15)','^OCZ[\s-]','OCZ',''],
['^(OWC|Aura|Mercury[\s-]?(Electra|Extreme))','^OWC\b','OWC',''],
@@ -12843,7 +13204,7 @@ sub set_vendors {
['^(PNY|Hook\s?Attache|SSD2SC|(SSD7?)?EP7|CS\d{3}|Elite\s?P)','^PNY\s','PNY','','^PNY'],
# note: get rid of: M[DGK] becasue mushkin starts with MK
# note: seen: KXG50ZNV512G NVMe TOSHIBA 512GB | THNSN51T02DUK NVMe TOSHIBA 1024GB
- ['(^[S]?TOS|^THN|TOSHIBA|TransMemory|^M[GKQ]\d|KBG4|^HDW|^SA\d{2}G$|^(008|016|032|064|128)G[379E][0-9A]$|0930|KSG\d)','S?(TOSHIBA|0930)','Toshiba',''], # scsi-STOSHIBA_STOR.E_EDITION_
+ ['(TOSHIBA|TransMemory|KBG4|^((A\s)?DT01A|M[GKQ]\d|HDW|SA\d{2}G$|(008|016|032|064|128)G[379E][0-9A]$|[S]?TOS|THN)|0930|KSG\d)','S?(TOSHIBA|0930)','Toshiba',''], # scsi-STOSHIBA_STOR.E_EDITION_
## LAST: THEY ARE SHORT AND COULD LEAD TO FALSE ID, OR ARE UNLIKELY ##
# unknown: AL25744_12345678; ADP may be usb 2.5" adapter; udisk unknown: Z1E6FTKJ 00AAKS
# SSD2SC240G726A10 MRS020A128GTS25C EHSAJM0016GB
@@ -12991,7 +13352,7 @@ sub set_vendors {
['^Gritronix','^Gritronixx?','Gritronix',''],
# supertalent also has FM: |FM
['^(G[\.]?SKILL)','^G[\.]?SKILL','G.SKILL',''],
- ['^G[\s-]*Tech','^G[\s-]*Technology','G-Technology',''],
+ ['^G[\s-]*Tech','^G[\s-]*Tech(nology)?','G-Technology',''],
['^Gaiver','^Gaiver','Gaiver',''],
['^(Hajaan|HS[1-9])','^Haajan','Haajan',''],
['^Haizhide','^Haizhide','Haizhide',''],
@@ -13031,12 +13392,14 @@ sub set_vendors {
['^(Integrated[\s-]?Technology|IT\d+)','^Integrated[\s-]?Technology','Integrated Technology',''],
['^(Iomega|ZIP\b|Clik!)','^Iomega','Iomega',''],
['^ISOCOM','^ISOCOM','ISOCOM (Shenzhen Longsys Electronics)',''],
+ ['^iTE[\s-]*Tech','^iTE[\s-]*Tech(nology)?','iTE Tech',''],
['^(Jaster|JS\d)','^Jaster','Jaster',''],
['^JingX','^JingX','JingX',''], #JingX 120G SSD - not confirmed, but guessing
['^Jingyi','^Jingyi','Jingyi',''],
# NOTE: ITY2 120GB hard to find
['^JMicron','^JMicron(\s?Tech(nology)?)?','JMicron Tech',''], #JMicron H/W raid
['^Kazuk','^Kazuk','Kazuk',''],
+ ['(\bKDI\b|^OM3P)','\bKDI\b','KDI',''],
['^KimMIDI','^KimMIDI','KimMIDI',''],
['^Kimtigo','^Kimtigo','Kimtigo',''],
['^Kingbank','^Kingbank','Kingbank',''],
@@ -13185,6 +13548,7 @@ sub set_vendors {
['\dSUN\d','^SUN(\sMicrosystems)?','Sun Microsystems',''],
['^Sundisk','^Sundisk','Sundisk',''],
['^SUNEAST','^SUNEAST','SunEast',''],
+ ['^SuperMicro','^SuperMicro','SuperMicro',''],
['^Supersonic','^Supersonic','Supersonic',''],
['^SuperSSpeed','^SuperSSpeed','SuperSSpeed',''],
# NOTE: F[MNETU] not reliable, g.skill starts with FM too:
@@ -13199,7 +13563,7 @@ sub set_vendors {
['^(TC[\s-]*SUNBOW|X3\s\d+[GT])','^TC[\s-]*SUNBOW','TCSunBow',''],
['^(TDK|TF[1-9]\d|LoR)','^TDK','TDK',''],
['^TEAC','^TEAC','TEAC',''],
- ['^(TEAM|T[\s-]?Create|L\d\s?Lite|T\d{3,}[A-Z]|TM\d|(Dark\s?)?L3\b)','^TEAM(\s*Group)?','TeamGroup',''],
+ ['^(TEAM|T[\s-]?Create|L\d\s?Lite|T\d{3,}[A-Z]|TM\d|(Dark\s?)?L3\b|T[\s-]?Force)','^TEAM(\s*Group)?','TeamGroup',''],
['^(Teclast|CoolFlash)','^Teclast','Teclast',''],
['^Teelkoou','^Teelkoou','Teelkoou',''],
['^Tele2','^Tele2','Tele2',''],
@@ -13212,7 +13576,7 @@ sub set_vendors {
['^TopSunligt','^TopSunligt','TopSunligt',''], # is this a typo? hard to know
['^TopSunlight','^TopSunlight','TopSunlight',''],
['^TOROSUS','^TOROSUS','Torosus',''],
- ['(^(Transcend|SSD\s|F)?TS|JetDrive|JetFlash|^USDU|^EZEX|^1307)','\b(Transcend|1307)\b','Transcend',''],
+ ['(Transcend|^((SSD\s|F)?TS|EZEX|USDU)|1307|JetDrive|JetFlash)','\b(Transcend|1307)\b','Transcend',''],
['^(TrekStor|DS (maxi|pocket)|DataStation)','^TrekStor','TrekStor',''],
['^Turbox','^Turbox','Turbox',''],
['^(TwinMOS|TW\d)','^TwinMOS','TwinMOS',''],
@@ -13228,6 +13592,7 @@ sub set_vendors {
['^VBOX','','VirtualBox',''],
['^(Verbatim|STORE\s?\'?N\'?\s?(FLIP|GO)|Vi[1-9]|OTG\s?Tiny)','^Verbatim','Verbatim',''],
['^V-GEN','^V-GEN','V-Gen',''],
+ ['^V[\s-]?(7|Seven)','^V[\s-]?(7|Seven)\b','VSeven',''],
['^(Victorinox|Swissflash)','^Victorinox','Victorinox',''],
['^(Visipro|SDVP)','^Visipro','Visipro',''],
['^VISIONTEK','^VISIONTEK','VisionTek',''],
@@ -13268,18 +13633,18 @@ sub set_vendors {
];
eval $end if $b_log;
}
+## END DISK VENDOR BLOCK ##
# receives space separated string that may or may not contain vendor data
-sub device_vendor {
+sub disk_vendor {
eval $start if $b_log;
my ($model,$serial) = @_;
my ($vendor) = ('');
- my (@data);
return if !$model;
# 0 - match pattern; 1 - replace pattern; 2 - vendor print; 3 - serial pattern
- # Data URLs: inxi-resources.txt Section: DriveItem device_vendor()
+ # Data URLs: inxi-resources.txt Section: DriveItem disk_vendor()
# $model = 'H10 HBRPEKNX0202A NVMe INTEL 512GB';
# $model = 'Patriot Memory';
- set_vendors() if !$vendors;
+ set_disk_vendors() if !$vendors;
foreach my $row (@$vendors){
if ($model =~ /$row->[0]/i || ($row->[3] && $serial && $serial =~ /$row->[3]/)){
$vendor = $row->[2];
@@ -13294,12 +13659,11 @@ sub device_vendor {
}
$model =~ s/^[\/\[\s_-]+|[\/\s_-]+$//g;
$model =~ s/\s\s/ /g;
- @data = ($vendor,$model);
last;
}
}
eval $end if $b_log;
- return @data;
+ return [$vendor,$model];
}
# Normally hddtemp requires root, but you can set user rights in /etc/sudoers.
@@ -13426,7 +13790,6 @@ sub block_data {
eval $start if $b_log;
my ($id) = @_;
# 0: logical block size 1: disk physical block size/partition block size;
- my @blocks = (0,0);
my ($block_log,$block_size) = (0,0);
# my $path_size = "/sys/block/$id/size";
my $path_log_block = "/sys/block/$id/queue/logical_block_size";
@@ -13438,15 +13801,15 @@ sub block_data {
$block_log = main::reader($path_log_block,'',0) if -r $path_log_block;
$block_size = main::reader($path_phy_block,'',0) if -r $path_phy_block;
# print "l-b: $block_log p-b: $block_size raw: $size_raw\n";
- @blocks = ($block_log,$block_size);
- main::log_data('dump','@blocks',\@blocks) if $b_log;
+ my $blocks = [$block_log,$block_size];
+ main::log_data('dump','@blocks',$blocks) if $b_log;
eval $end if $b_log;
- return @blocks;
+ return $blocks;
}
-sub device_speed {
+sub drive_speed {
eval $start if $b_log;
my ($device) = @_;
- my ($b_nvme,$lanes,$speed,@data);
+ my ($b_nvme,$lanes,$speed);
my $working = Cwd::abs_path("/sys/class/block/$device");
# print "$working\n";
if ($working){
@@ -13501,55 +13864,55 @@ sub device_speed {
}
}
}
- @data = ($speed,$lanes);
# print "$working $speed\n";
eval $end if $b_log;
- return @data;
+ return [$speed,$lanes];
}
}
## GraphicItem
{
package GraphicItem;
-my ($b_wayland_data,%graphics,$monitor_ids,$monitor_map,$nv_arch,$nv_legacy);
+my ($b_wayland_data,%graphics,$monitor_ids,$monitor_map);
+my ($gpu_amd,$gpu_intel,$gpu_nv);
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
if (%risc && !$use{'soc-gfx'} && !$use{'pci-tool'}){
my $key = 'Message';
- push(@rows, {
- main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'}),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'})
+ });
}
else {
- push(@rows,device_output());
- ($nv_arch,$nv_legacy) = ();
- if (!@rows){
+ device_output($rows);
+ ($gpu_amd,$gpu_intel,$gpu_nv) = ();
+ if (!@$rows){
my $key = 'Message';
my $type = 'pci-card-data';
if ($pci_tool && $alerts{$pci_tool}->{'action'} eq 'permissions'){
$type = 'pci-card-data-root';
}
- push(@rows, {
- main::key($num++,0,1,$key) => main::message($type,''),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message($type,'')
+ });
}
}
# note: not perfect, but we need usb gfx to show for all types, soc, pci, etc
- push(@rows,usb_output());
- push(@rows,display_output());
- push(@rows,interface_output());
+ usb_output($rows);
+ display_output($rows);
+ interface_output($rows);
(%graphics,$monitor_ids,$monitor_map) = ();
eval $end if $b_log;
- return @rows;
+ return $rows;
}
## DEVICE OUTPUT ##
sub device_output {
eval $start if $b_log;
return if !$devices{'graphics'};
- my (@rows);
+ my $rows = $_[0];
my ($j,$num) = (0,1);
set_monitors_sys() if !$monitor_ids && -e '/sys/class/drm';
foreach my $row (@{$devices{'graphics'}}){
@@ -13562,97 +13925,101 @@ sub device_output {
# card. .1 would be for example: Display Adapter with bus id x:xx.1, not the right one
next if $row->[3] != 0;
# print "$row->[0] $row->[3]\n";
- $j = scalar @rows;
+ $j = scalar @$rows;
my $device = main::trimmer($row->[4]);
$device = ($device) ? main::clean_pci($device,'output') : 'N/A';
# have seen absurdly verbose card descriptions, with non related data etc
if (length($device) > 85 || $size{'max-cols'} < 110){
$device = main::filter_pci_long($device);
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $device,
},);
if ($extra > 0 && $use{'pci-tool'} && $row->[12]){
my $item = main::get_pci_vendor($row->[4],$row->[12]);
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $item if $item;
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $item if $item;
}
push(@{$graphics{'gpu-drivers'}},$row->[9]) if $row->[9];
my $driver = ($row->[9]) ? $row->[9]:'N/A';
- $rows[$j]->{main::key($num++,1,2,'driver')} = $driver;
+ $rows->[$j]{main::key($num++,1,2,'driver')} = $driver;
if ($row->[9] && !$bsd_type){
my $version = main::get_module_version($row->[9]);
$version ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'v')} = $version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version;
}
if ($b_admin && $row->[10]){
$row->[10] = main::get_driver_modules($row->[9],$row->[10]);
- $rows[$j]->{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
+ $rows->[$j]{main::key($num++,0,3,'alternate')} = $row->[10] if $row->[10];
}
if ($extra > 0 && $row->[5] && $row->[6] &&
- $row->[5] =~ /^(10de|12d2)$/){
- my $nv_info = nvidia_data($row->[6]);
- # my $nv_info = nvidia_data('1bb5');
- if (!$bsd_type && $b_admin){
- if ($nv_info->{'legacy'} && $show{'nvidia'}){
- $rows[$j]->{main::key($num++,1,3,'non-free')} = '';
- $rows[$j]->{main::key($num++,0,4,'series')} = $nv_info->{'series'};
- $rows[$j]->{main::key($num++,0,4,'status')} = $nv_info->{'status'};
- if ($nv_info->{'xorg'}){
- $rows[$j]->{main::key($num++,1,4,'last')} = '';
- $rows[$j]->{main::key($num++,0,5,'release')} = $nv_info->{'release'};
- $rows[$j]->{main::key($num++,0,5,'kernel')} = $nv_info->{'kernel'};
- $rows[$j]->{main::key($num++,0,5,'xorg')} = $nv_info->{'xorg'};
+ $row->[5] =~ /^(1002|10de|12d2|8086)$/){
+ # legacy: 1180 0df7 0029 current: 13bc 1c8d 24b1 regex: H100, RTX 4000
+ # ($row->[5],$row->[6],$row->[4]) = ('12de','0029','');
+ my ($gpu_data,$b_nv) = gpu_data($row->[5],$row->[6],$row->[4]);
+ if (!$bsd_type && $b_nv && $b_admin){
+ if ($gpu_data->{'legacy'} && $show{'gpu-data'}){
+ $rows->[$j]{main::key($num++,1,3,'non-free')} = '';
+ $rows->[$j]{main::key($num++,0,4,'series')} = $gpu_data->{'series'};
+ $rows->[$j]{main::key($num++,0,4,'status')} = $gpu_data->{'status'};
+ if ($gpu_data->{'xorg'}){
+ $rows->[$j]{main::key($num++,1,4,'last')} = '';
+ $rows->[$j]{main::key($num++,0,5,'release')} = $gpu_data->{'release'};
+ $rows->[$j]{main::key($num++,0,5,'kernel')} = $gpu_data->{'kernel'};
+ $rows->[$j]{main::key($num++,0,5,'xorg')} = $gpu_data->{'xorg'};
}
}
else {
- $nv_info->{'series'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,3,'non-free')} = $nv_info->{'series'};
- $rows[$j]->{main::key($num++,0,4,'status')} = $nv_info->{'status'};
+ $gpu_data->{'series'} ||= 'N/A';
+ $rows->[$j]{main::key($num++,1,3,'non-free')} = $gpu_data->{'series'};
+ $rows->[$j]{main::key($num++,0,4,'status')} = $gpu_data->{'status'};
}
}
- if ($nv_info->{'arch'}){
- $rows[$j]->{main::key($num++,1,2,'arch')} = $nv_info->{'arch'};
- if ($show{'nvidia'}){
- if ($nv_info->{'code'}){
- $rows[$j]->{main::key($num++,0,3,'code')} = $nv_info->{'code'};
- }
- if ($nv_info->{'process'}){
- $rows[$j]->{main::key($num++,0,3,'process')} = $nv_info->{'process'};
- }
+ if ($gpu_data->{'arch'}){
+ $rows->[$j]{main::key($num++,1,2,'arch')} = $gpu_data->{'arch'};
+ # we don't need to see repeated values here, but usually code is different.
+ if ($show{'gpu-data'} && $gpu_data->{'code'} &&
+ $gpu_data->{'code'} ne $gpu_data->{'arch'}){
+ $rows->[$j]{main::key($num++,0,3,'code')} = $gpu_data->{'code'};
+ }
+ if ($b_admin && $gpu_data->{'process'}){
+ $rows->[$j]{main::key($num++,0,3,'process')} = $gpu_data->{'process'};
+ }
+ if ($b_admin && $gpu_data->{'years'}){
+ $rows->[$j]{main::key($num++,0,3,'built')} = $gpu_data->{'years'};
}
}
}
if ($extra > 0){
my $bus_id = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]";
if ($extra > 1 && $bus_id ne 'N/A'){
- main::get_pcie_data($bus_id,$j,\@rows,\$num,'gpu');
+ main::get_pcie_data($bus_id,$j,$rows,\$num,'gpu');
}
if ($extra > 1 && $monitor_ids){
- port_output($bus_id,$j,\@rows,\$num);
+ port_output($bus_id,$j,$rows,\$num);
}
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
my $chip_id = main::get_chip_id($row->[5],$row->[6]);
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $chip_id;
}
if ($extra > 2 && $row->[1]){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = $row->[1];
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = $row->[1];
}
# print "$row->[0]\n";
}
eval $end if $b_log;
- return @rows;
}
sub usb_output {
eval $start if $b_log;
- my (@rows,@ids,$driver,$path_id,$product,@temp2);
+ my $rows = $_[0];
+ my (@ids,$driver,$path_id,$product,@temp2);
my ($j,$num) = (0,1);
return if !$usb{'graphics'};
foreach my $row (@{$usb{'graphics'}}){
# these tests only work for /sys based usb data for now
$num = 1;
- $j = scalar @rows;
+ $j = scalar @$rows;
# make sure to reset, or second device trips last flag
($driver,$path_id,$product) = ('','','');
$product = main::clean($row->[13]) if $row->[13];
@@ -13668,7 +14035,7 @@ sub usb_output {
$driver = 'N/A';
}
}
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $product,
main::key($num++,0,2,'type') => 'USB',
main::key($num++,0,2,'driver') => $driver,
@@ -13676,23 +14043,22 @@ sub usb_output {
if ($extra > 0){
my $bus_id = "$path_id:$row->[1]";
if ($extra > 1 && $monitor_ids){
- port_output($bus_id,$j,\@rows,\$num);
+ port_output($bus_id,$j,$rows,\$num);
}
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
$row->[7] ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $row->[7];
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $row->[7];
}
if ($extra > 2 && defined $row->[5] && $row->[5] ne ''){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
}
if ($extra > 2 && $row->[16]){
- $rows[$j]->{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
+ $rows->[$j]{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
}
}
eval $end if $b_log;
- return @rows;
}
# $rows, $num by ref
sub port_output {
@@ -13718,26 +14084,26 @@ sub port_output {
if (@connected || @empty || @disabled){
my ($off,$active,$unused);
my $split = ','; # add space if many to allow for wrapping
- $$rows[$j]->{main::key($$num++,1,2,'ports')} = '';
+ $rows->[$j]{main::key($$num++,1,2,'ports')} = '';
$split = ', ' if scalar @connected > 3;
$active = (@connected) ? join($split,sort @connected) : 'none';
- $$rows[$j]->{main::key($$num++,0,3,'active')} = $active;
+ $rows->[$j]{main::key($$num++,0,3,'active')} = $active;
if (@disabled){
$split = (scalar @disabled > 3) ? ', ' : ',';
$off = join($split,sort @disabled);
- $$rows[$j]->{main::key($$num++,0,3,'off')} = $off;
+ $rows->[$j]{main::key($$num++,0,3,'off')} = $off;
}
$split = (scalar @empty > 3) ? ', ' : ',';
$unused = (@empty) ? join($split,sort @empty) : 'none';
- $$rows[$j]->{main::key($$num++,0,3,'empty')} = $unused;
+ $rows->[$j]{main::key($$num++,0,3,'empty')} = $unused;
}
}
## DISPLAY OUTPUT ##
sub display_output(){
eval $start if $b_log;
- my (@row);
- my ($num,$j) = (0,0);
+ my $rows = $_[0];
+ my ($num,$j) = (0,scalar @$rows);
# note: these may not always be set, they won't be out of X, for example
display_protocol();
# get rid of all inactive or disabled monitor port ids
@@ -13778,42 +14144,42 @@ sub display_output(){
# print "$server_string\n";
}
if (!$graphics{'protocol'} && !$server_string && !$graphics{'x-server'} &&
- !$x_drivers){
+ !@$x_drivers){
$server_string = main::message('display-server');
- @row = ({
+ push(@$rows,{
main::key($num++,1,1,'Display') => '',
main::key($num++,0,2,'server') => $server_string,
});
}
else {
$server_string ||= 'N/A';
- @row = ({
+ push(@$rows, {
main::key($num++,1,1,'Display') => $graphics{'protocol'},
main::key($num++,1,2,'server') => $server_string,
});
if ($graphics{'x-server'} && $graphics{'x-server'}->[0][1]){
- $row[0]->{main::key($num++,0,3,'v')} = $graphics{'x-server'}->[0][1];
+ $rows->[$j]{main::key($num++,0,3,'v')} = $graphics{'x-server'}->[0][1];
}
if ($graphics{'x-server'} && $graphics{'x-server'}->[1][0]){
- $row[0]->{main::key($num++,1,3,'with')} = $graphics{'x-server'}->[1][0];
+ $rows->[$j]{main::key($num++,1,3,'with')} = $graphics{'x-server'}->[1][0];
if ($graphics{'x-server'}->[1][1]){
- $row[0]->{main::key($num++,0,4,'v')} = $graphics{'x-server'}->[1][1];
+ $rows->[$j]{main::key($num++,0,4,'v')} = $graphics{'x-server'}->[1][1];
}
}
if ($graphics{'compositors'}){
if (scalar @{$graphics{'compositors'}} == 1){
- $row[0]->{main::key($num++,1,2,'compositor')} = $graphics{'compositors'}->[0][0];
+ $rows->[$j]{main::key($num++,1,2,'compositor')} = $graphics{'compositors'}->[0][0];
if ($graphics{'compositors'}->[0][1]){
- $row[0]->{main::key($num++,0,3,'v')} = $graphics{'compositors'}->[0][1];
+ $rows->[$j]{main::key($num++,0,3,'v')} = $graphics{'compositors'}->[0][1];
}
}
else {
my $i =1;
- $row[0]->{main::key($num++,1,2,'compositors')} = '';
+ $rows->[$j]{main::key($num++,1,2,'compositors')} = '';
foreach (@{$graphics{'compositors'}}){
- $row[0]->{main::key($num++,1,3,$i)} = $_->[0];
+ $rows->[$j]{main::key($num++,1,3,$i)} = $_->[0];
if ($_->[1]){
- $row[0]->{main::key($num++,0,4,'v')} = $_->[1];
+ $rows->[$j]{main::key($num++,0,4,'v')} = $_->[1];
}
$i++;
}
@@ -13822,7 +14188,7 @@ sub display_output(){
# note: if no xorg log, and if wayland, there will be no xorg drivers,
# obviously, so we use the last driver found on the card section in that case.
# those come from lscpi kernel drivers so there should be no xorg/wayland issues.
- if (!$x_drivers || !$x_drivers->[0]){
+ if (!@$x_drivers || !$x_drivers->[0]){
# Fallback: specific case: in Arch/Manjaro gdm run systems, their Xorg.0.log is
# located inside this directory, which is not readable unless you are root
# Normally Arch gdm log is here: ~/.local/share/xorg/Xorg.1.log
@@ -13844,64 +14210,64 @@ sub display_output(){
}
# if xvesa, will always have display-driver set
if ($graphics{'xvesa'} && $graphics{'display-driver'}){
- $row[0]->{main::key($num++,0,2,'driver')} = join(',',@{$graphics{'display-driver'}});
+ $rows->[$j]{main::key($num++,0,2,'driver')} = join(',',@{$graphics{'display-driver'}});
}
else {
my $gpu_drivers = gpu_drivers_sys('all');
my $note_indent = 4;
- if ($gpu_drivers || $x_drivers){
- $row[0]->{main::key($num++,1,2,'driver')} = '';
+ if (@$gpu_drivers || @$x_drivers){
+ $rows->[$j]{main::key($num++,1,2,'driver')} = '';
# The only wayland setups with x drivers have xorg, transitional that is.
- if ($x_drivers){
- $row[0]->{main::key($num++,1,3,'X')} = '';
+ if (@$x_drivers){
+ $rows->[$j]{main::key($num++,1,3,'X')} = '';
my $driver = ($x_drivers->[0]) ? $x_drivers->[0] : 'N/A';
- $row[0]->{main::key($num++,1,4,'loaded')} = $driver;
+ $rows->[$j]{main::key($num++,1,4,'loaded')} = $driver;
if ($x_drivers->[1]){
- $row[0]->{main::key($num++,0,4,'unloaded')} = $x_drivers->[1];
+ $rows->[$j]{main::key($num++,0,4,'unloaded')} = $x_drivers->[1];
}
if ($x_drivers->[2]){
- $row[0]->{main::key($num++,0,4,'failed')} = $x_drivers->[2];
+ $rows->[$j]{main::key($num++,0,4,'failed')} = $x_drivers->[2];
}
if ($extra > 1 && $x_drivers->[3]){
- $row[0]->{main::key($num++,0,4,'alternate')} = $x_drivers->[3];
+ $rows->[$j]{main::key($num++,0,4,'alternate')} = $x_drivers->[3];
}
}
my $drivers;
- if ($gpu_drivers){
- $drivers = join(',',@{$gpu_drivers});
+ if (@$gpu_drivers){
+ $drivers = join(',',@$gpu_drivers);
}
else {
$drivers = ($graphics{'gpu-drivers'}) ? join(',',@{$graphics{'gpu-drivers'}}): 'N/A';
}
- $row[0]->{main::key($num++,1,3,'gpu')} = $drivers;
+ $rows->[$j]{main::key($num++,1,3,'gpu')} = $drivers;
}
else {
$note_indent = 3;
- $row[0]->{main::key($num++,1,2,'driver')} = 'N/A';
+ $rows->[$j]{main::key($num++,1,2,'driver')} = 'N/A';
}
if ($driver_note){
- $row[0]->{main::key($num++,0,$note_indent,'note')} = $driver_note;
+ $rows->[$j]{main::key($num++,0,$note_indent,'note')} = $driver_note;
}
}
}
if (!$show{'graphic-basic'} && $extra > 1 && $graphics{'display-rect'}){
- $row[0]->{main::key($num++,0,2,'d-rect')} = $graphics{'display-rect'};
+ $rows->[$j]{main::key($num++,0,2,'d-rect')} = $graphics{'display-rect'};
}
if (!$show{'graphic-basic'} && $extra > 1){
if (defined $graphics{'display-id'}){
- $row[0]->{main::key($num++,0,2,'display-ID')} = $graphics{'display-id'};
+ $rows->[$j]{main::key($num++,0,2,'display-ID')} = $graphics{'display-id'};
}
if (defined $graphics{'display-screens'}){
- $row[0]->{main::key($num++,0,2,'screens')} = $graphics{'display-screens'};
+ $rows->[$j]{main::key($num++,0,2,'screens')} = $graphics{'display-screens'};
}
if (defined $graphics{'display-default-screen'} &&
$graphics{'display-screens'} && $graphics{'display-screens'} > 1){
- $row[0]->{main::key($num++,0,2,'default screen')} = $graphics{'display-default-screen'};
+ $rows->[$j]{main::key($num++,0,2,'default screen')} = $graphics{'display-default-screen'};
}
}
if ($graphics{'no-screens'}){
my $res = (!$show{'graphic-basic'} && $extra > 1 && !$graphics{'xvesa'}) ? 'note' : 'resolution';
- $row[0]->{main::key($num++,0,2,$res)} = $graphics{'no-screens'};
+ $rows->[$j]{main::key($num++,0,2,$res)} = $graphics{'no-screens'};
}
elsif ($graphics{'screens'}){
my ($diag,$dpi,$hz,$size);
@@ -13914,7 +14280,7 @@ sub display_output(){
$j++ if !$show{'graphic-basic'};
if (!$show{'graphic-basic'} || $m_count == 0){
if (!$show{'graphic-basic'} && defined $main->{'screen'}){
- $row[$j]->{main::key($num++,1,2,'Screen')} = $main->{'screen'};
+ $rows->[$j]{main::key($num++,1,2,'Screen')} = $main->{'screen'};
}
if ($main->{'res-x'} && $main->{'res-y'}){
$resolution = $main->{'res-x'} . 'x' . $main->{'res-y'};
@@ -13922,28 +14288,28 @@ sub display_output(){
}
$resolution ||= 'N/A';
if ($s_count == 1 || !$show{'graphic-basic'}){
- $row[$j]->{main::key($num++,0,3,'s-res')} = $resolution;
+ $rows->[$j]{main::key($num++,0,3,'s-res')} = $resolution;
}
elsif ($show{'graphic-basic'}){
- $row[$j]->{main::key($num++,0,3,'s-res')} = '' if $screen_count == 1;
- $row[$j]->{main::key($num++,0,3,$screen_count)} = $resolution;
+ $rows->[$j]{main::key($num++,0,3,'s-res')} = '' if $screen_count == 1;
+ $rows->[$j]{main::key($num++,0,3,$screen_count)} = $resolution;
}
if ($main->{'s-dpi'} && (!$show{'graphic-basic'} && $extra > 1)){
- $row[$j]->{main::key($num++,0,3,'s-dpi')} = $main->{'s-dpi'};
+ $rows->[$j]{main::key($num++,0,3,'s-dpi')} = $main->{'s-dpi'};
}
if (!$show{'graphic-basic'} && $extra > 2){
if ($main->{'size-missing'}){
- $row[$j]->{main::key($num++,0,3,'s-size')} = $main->{'size-missing'};
+ $rows->[$j]{main::key($num++,0,3,'s-size')} = $main->{'size-missing'};
}
else {
if ($main->{'size-x'} && $main->{'size-y'}){
$size = $main->{'size-x'} . 'x' . $main->{'size-y'} .
'mm ('. $main->{'size-x-i'} . 'x' . $main->{'size-y-i'} . '")';
- $row[$j]->{main::key($num++,0,3,'s-size')} = $size;
+ $rows->[$j]{main::key($num++,0,3,'s-size')} = $size;
}
if ($main->{'diagonal'}){
$diag = $main->{'diagonal-m'} . 'mm ('. $main->{'diagonal'} . '")';
- $row[$j]->{main::key($num++,0,3,'s-diag')} = $diag;
+ $rows->[$j]{main::key($num++,0,3,'s-diag')} = $diag;
}
}
}
@@ -13953,35 +14319,34 @@ sub display_output(){
$b_screen_monitors = 1;
if ($show{'graphic-basic'}){
monitors_output_basic('screen',$main->{'monitors'},
- $main->{'s-dpi'},$j,\@row,\$num);
+ $main->{'s-dpi'},$j,$rows,\$num);
}
else {
monitors_output_full('screen',$main->{'monitors'},
- $j,\@row,\$num);
+ $j,$rows,\$num);
}
}
elsif (!$show{'graphic-basic'} && $graphics{'no-monitors'}){
- $row[$j]->{main::key($num++,0,4,'monitors')} = $graphics{'no-monitors'};
+ $rows->[$j]{main::key($num++,0,4,'monitors')} = $graphics{'no-monitors'};
}
}
}
elsif (!$b_display){
$graphics{'tty'} ||= 'N/A';
- $row[0]->{main::key($num++,0,2,'tty')} = $graphics{'tty'};
+ $rows->[$j]{main::key($num++,0,2,'tty')} = $graphics{'tty'};
}
# fallback, if no xrandr/xdpyinfo, if wayland, if console. Note we've
# deleted each key used in advanced_monitor_data() so those won't show again
if (!$b_screen_monitors && $monitor_ids && %$monitor_ids){
if ($show{'graphic-basic'}){
- monitors_output_basic('monitor',$monitor_ids,'',$j,\@row,\$num);
+ monitors_output_basic('monitor',$monitor_ids,'',$j,$rows,\$num);
}
else {
- monitors_output_full('monitor',$monitor_ids,$j,\@row,\$num);
+ monitors_output_full('monitor',$monitor_ids,$j,$rows,\$num);
}
}
}
eval $end if $b_log;
- return @row;
}
sub monitors_output_basic {
eval $start if $b_log;
@@ -14022,33 +14387,33 @@ sub monitors_output_basic {
# $j, $row, $num passed by ref
sub monitors_output_full {
eval $start if $b_log;
- my ($type,$monitors,$j,$row,$num) = @_;
+ my ($type,$monitors,$j,$rows,$num) = @_;
my ($b_no_size,$resolution);
my ($m1,$m2,$m3,$m4) = ($type eq 'screen') ? (3,4,5,6) : (2,3,4,5);
# note: in case where mapped id != sys id, the key will not match 'monitor'
foreach my $key (sort keys %{$monitors}){
$j++;
- $$row[$j]->{main::key($$num++,1,$m1,'Monitor')} = $monitors->{$key}{'monitor'};
+ $rows->[$j]{main::key($$num++,1,$m1,'Monitor')} = $monitors->{$key}{'monitor'};
if ($monitors->{$key}{'monitor-mapped'}){
- $$row[$j]->{main::key($$num++,0,$m2,'mapped')} = $monitors->{$key}{'monitor-mapped'};
+ $rows->[$j]{main::key($$num++,0,$m2,'mapped')} = $monitors->{$key}{'monitor-mapped'};
}
if ($monitors->{$key}{'disabled'}){
- $$row[$j]->{main::key($$num++,0,$m2,'note')} = $monitors->{$key}{'disabled'};
+ $rows->[$j]{main::key($$num++,0,$m2,'note')} = $monitors->{$key}{'disabled'};
}
if ($monitors->{$key}{'position'}){
- $$row[$j]->{main::key($$num++,0,$m2,'pos')} = $monitors->{$key}{'position'};
+ $rows->[$j]{main::key($$num++,0,$m2,'pos')} = $monitors->{$key}{'position'};
}
if ($monitors->{$key}{'model'}){
- $$row[$j]->{main::key($$num++,0,$m2,'model')} = $monitors->{$key}{'model'};
+ $rows->[$j]{main::key($$num++,0,$m2,'model')} = $monitors->{$key}{'model'};
}
elsif ($monitors->{$key}{'model-id'}){
- $$row[$j]->{main::key($$num++,0,$m2,'model-id')} = $monitors->{$key}{'model-id'};
+ $rows->[$j]{main::key($$num++,0,$m2,'model-id')} = $monitors->{$key}{'model-id'};
}
if ($extra > 2 && $monitors->{$key}{'serial'}){
- $$row[$j]->{main::key($$num++,0,$m2,'serial')} = main::filter($monitors->{$key}{'serial'});
+ $rows->[$j]{main::key($$num++,0,$m2,'serial')} = main::filter($monitors->{$key}{'serial'});
}
if ($b_admin && $monitors->{$key}{'build-date'}){
- $$row[$j]->{main::key($$num++,0,$m2,'built')} = $monitors->{$key}{'build-date'};
+ $rows->[$j]{main::key($$num++,0,$m2,'built')} = $monitors->{$key}{'build-date'};
}
if ($monitors->{$key}{'res-x'} || $monitors->{$key}{'res-y'} ||
$monitors->{$key}{'hz'} || $monitors->{$key}{'size-x'} ||
@@ -14057,7 +14422,7 @@ sub monitors_output_full {
$resolution = $monitors->{$key}{'res-x'} . 'x' . $monitors->{$key}{'res-y'};
}
$resolution ||= 'N/A';
- $$row[$j]->{main::key($$num++,0,$m2,'res')} = $resolution;
+ $rows->[$j]{main::key($$num++,0,$m2,'res')} = $resolution;
}
else {
if ($b_display){
@@ -14067,50 +14432,50 @@ sub monitors_output_full {
$resolution = main::message('monitor-console');
}
$b_no_size = 1;
- $$row[$j]->{main::key($$num++,0,$m2,'size-res')} = $resolution;
+ $rows->[$j]{main::key($$num++,0,$m2,'size-res')} = $resolution;
}
if ($extra > 2 && $monitors->{$key}{'hz'}){
- $$row[$j]->{main::key($$num++,0,$m2,'hz')} = $monitors->{$key}{'hz'};
+ $rows->[$j]{main::key($$num++,0,$m2,'hz')} = $monitors->{$key}{'hz'};
}
if ($monitors->{$key}{'dpi'}){
- $$row[$j]->{main::key($$num++,0,$m2,'dpi')} = $monitors->{$key}{'dpi'};
+ $rows->[$j]{main::key($$num++,0,$m2,'dpi')} = $monitors->{$key}{'dpi'};
}
if ($b_admin && $monitors->{$key}{'gamma'}){
- $$row[$j]->{main::key($$num++,0,$m2,'gamma')} = $monitors->{$key}{'gamma'};
+ $rows->[$j]{main::key($$num++,0,$m2,'gamma')} = $monitors->{$key}{'gamma'};
}
if ($show{'edid'} && $monitors->{$key}{'colors'}){
- $$row[$j]->{main::key($$num++,1,$m2,'chroma')} = '';
- $$row[$j]->{main::key($$num++,1,$m3,'red')} = '';
- $$row[$j]->{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'red_x'};
- $$row[$j]->{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'red_y'};
- $$row[$j]->{main::key($$num++,1,$m3,'green')} = '';
- $$row[$j]->{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'green_x'};
- $$row[$j]->{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'green_y'};
- $$row[$j]->{main::key($$num++,1,$m3,'blue')} = '';
- $$row[$j]->{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'blue_x'};
- $$row[$j]->{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'blue_y'};
- $$row[$j]->{main::key($$num++,1,$m3,'white')} = '';
- $$row[$j]->{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'white_x'};
- $$row[$j]->{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'white_y'};
+ $rows->[$j]{main::key($$num++,1,$m2,'chroma')} = '';
+ $rows->[$j]{main::key($$num++,1,$m3,'red')} = '';
+ $rows->[$j]{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'red_x'};
+ $rows->[$j]{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'red_y'};
+ $rows->[$j]{main::key($$num++,1,$m3,'green')} = '';
+ $rows->[$j]{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'green_x'};
+ $rows->[$j]{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'green_y'};
+ $rows->[$j]{main::key($$num++,1,$m3,'blue')} = '';
+ $rows->[$j]{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'blue_x'};
+ $rows->[$j]{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'blue_y'};
+ $rows->[$j]{main::key($$num++,1,$m3,'white')} = '';
+ $rows->[$j]{main::key($$num++,0,$m4,'x')} = $monitors->{$key}{'colors'}{'white_x'};
+ $rows->[$j]{main::key($$num++,0,$m4,'y')} = $monitors->{$key}{'colors'}{'white_y'};
}
if ($extra > 2 && $monitors->{$key}{'scale'}){
- $$row[$j]->{main::key($$num++,0,$m2,'scale')} = $monitors->{$key}{'scale'};
+ $rows->[$j]{main::key($$num++,0,$m2,'scale')} = $monitors->{$key}{'scale'};
}
if ($extra > 2 && $monitors->{$key}{'size-x'} && $monitors->{$key}{'size-y'}){
my $size = $monitors->{$key}{'size-x'} . 'x' . $monitors->{$key}{'size-y'} .
'mm ('. $monitors->{$key}{'size-x-i'} . 'x' . $monitors->{$key}{'size-y-i'} . '")';
- $$row[$j]->{main::key($$num++,0,$m2,'size')} = $size;
+ $rows->[$j]{main::key($$num++,0,$m2,'size')} = $size;
}
if ($monitors->{$key}{'diagonal'}){
my $diag = $monitors->{$key}{'diagonal-m'} . 'mm ('. $monitors->{$key}{'diagonal'} . '")';
- $$row[$j]->{main::key($$num++,0,$m2,'diag')} = $diag;
+ $rows->[$j]{main::key($$num++,0,$m2,'diag')} = $diag;
}
elsif ($b_display && !$b_no_size && !$monitors->{$key}{'size-x'} &&
!$monitors->{$key}{'size-y'}){
- $$row[$j]->{main::key($$num++,0,$m2,'size')} = main::message('monitor-na');;
+ $rows->[$j]{main::key($$num++,0,$m2,'size')} = main::message('monitor-na');;
}
if ($b_admin && $monitors->{$key}{'ratio'}){
- $$row[$j]->{main::key($$num++,0,$m2,'ratio')} = $monitors->{$key}{'ratio'};
+ $rows->[$j]{main::key($$num++,0,$m2,'ratio')} = $monitors->{$key}{'ratio'};
}
if ($extra > 2){
if (!$monitors->{$key}{'modes'} || !@{$monitors->{$key}{'modes'}}){
@@ -14118,30 +14483,30 @@ sub monitors_output_full {
}
my $cnt = scalar @{$monitors->{$key}{'modes'}};
if ($cnt == 1 || ($cnt > 2 && $show{'edid'})){
- $$row[$j]->{main::key($$num++,0,$m2,'modes')} = join(', ', @{$monitors->{$key}{'modes'}});
+ $rows->[$j]{main::key($$num++,0,$m2,'modes')} = join(', ', @{$monitors->{$key}{'modes'}});
}
else {
- $$row[$j]->{main::key($$num++,1,$m2,'modes')} = '';
- $$row[$j]->{main::key($$num++,0,$m3,'max')} = ${$monitors->{$key}{'modes'}}[0];
- $$row[$j]->{main::key($$num++,0,$m3,'min')} = ${$monitors->{$key}{'modes'}}[-1];
+ $rows->[$j]{main::key($$num++,1,$m2,'modes')} = '';
+ $rows->[$j]{main::key($$num++,0,$m3,'max')} = ${$monitors->{$key}{'modes'}}[0];
+ $rows->[$j]{main::key($$num++,0,$m3,'min')} = ${$monitors->{$key}{'modes'}}[-1];
}
}
if ($show{'edid'}){
if ($monitors->{$key}{'edid-errors'}){
$j++;
my $cnt = 1;
- $$row[$j]->{main::key($$num++,1,$m2,'EDID-Errors')} = '';
+ $rows->[$j]{main::key($$num++,1,$m2,'EDID-Errors')} = '';
foreach my $err (@{$monitors->{$key}{'edid-errors'}}){
- $$row[$j]->{main::key($$num++,0,$m3,$cnt)} = $err;
+ $rows->[$j]{main::key($$num++,0,$m3,$cnt)} = $err;
$cnt++;
}
}
if ($monitors->{$key}{'edid-warnings'}){
$j++;
my $cnt = 1;
- $$row[$j]->{main::key($$num++,1,$m2,'EDID-Warnings')} = '';
+ $rows->[$j]{main::key($$num++,1,$m2,'EDID-Warnings')} = '';
foreach my $warn (@{$monitors->{$key}{'edid-warnings'}}){
- $$row[$j]->{main::key($$num++,0,$m3,$cnt)} = $warn;
+ $rows->[$j]{main::key($$num++,0,$m3,$cnt)} = $warn;
$cnt++;
}
}
@@ -14151,7 +14516,7 @@ sub monitors_output_full {
# if ($b_display && $b_admin && $graphics{'protocol'} &&
# $graphics{'protocol'} eq 'wayland' && $monitors->{$key}{'drivers'}){
# $driver = join(',',@{$monitors->{$key}{'drivers'}});
-# $$row[$j]->{main::key($$num++,0,$m2,'driver')} = $driver;
+# $rows->[$j]{main::key($$num++,0,$m2,'driver')} = $driver;
# }
eval $end if $b_log;
}
@@ -14160,30 +14525,31 @@ sub monitors_output_full {
# as soon as EGL for Wayland appears add it!
sub interface_output {
eval $start if $b_log;
+ my $rows = $_[0];
my $num = 0;
- my (@row,$program,$type);
+ my ($program,$type);
# print ("$b_display : $b_root\n");
if ($b_display){
if (!$force{'wayland'} && ($program = main::check_program('glxinfo'))){
- interface_glx_output($program,\@row,\$num);
+ interface_glx_output($program,$rows,\$num);
}
elsif ($graphics{'xvesa'}){
- interface_vesa_output(\@row,\$num);
+ interface_vesa_output($rows,\$num);
}
# handles no data until we find one for wayland egl data
elsif ($graphics{'protocol'} eq 'wayland'){
- interface_egl_output(\@row,\$num);
+ interface_egl_output($rows,\$num);
}
else {
- @row = ({
- main::key($num++,0,1,'Message') => main::message('glxinfo-missing'),
+ push(@$rows,{
+ main::key($num++,0,1,'Message') => main::message('glxinfo-missing')
});
}
}
else {
$type = 'gl-console';
if ($graphics{'xvesa'}){
- interface_vesa_output(\@row,\$num);
+ interface_vesa_output($rows,\$num);
}
elsif (!main::check_program('glxinfo')){
if ($graphics{'protocol'} eq 'wayland'){
@@ -14204,29 +14570,28 @@ sub interface_output {
$type = 'gl-try';
}
}
- @row = ({
- main::key($num++,0,1,'Message') => main::message($type),
+ push(@$rows,{
+ main::key($num++,0,1,'Message') => main::message($type)
});
}
eval $end if $b_log;
- return @row;
}
sub interface_egl_output {
eval $start if $b_log;
- my ($row,$num) = @_;
- @$row = ({
- main::key($num++,0,1,'Message') => main::message('interface-wayland'),
+ my ($rows,$num) = @_;
+ push(@$rows,{
+ main::key($num++,0,1,'Message') => main::message('interface-wayland')
});
eval $end if $b_log;
}
sub interface_glx_output {
eval $start if $b_log;
- my ($program,$row,$num) = @_;
+ my ($program,$rows,$num) = @_;
# NOTE: glxinfo -B is not always available, unfortunately
- my @glxinfo = main::grabber("$program $display_opt 2>/dev/null");
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/graphics/glxinfo/glxinfo-ssh-centos.txt";
+ my $glxinfo = main::grabber("$program $display_opt 2>/dev/null",'','','ref');
+ # my $file = "$fake_data_dir/graphics/glxinfo/glxinfo-ssh-centos.txt";
# my @glxinfo = main::reader($file);
- if (!@glxinfo){
+ if (!@$glxinfo){
my $type = 'gl-console';
if ($b_root){
$type = 'gl-root-display';
@@ -14234,16 +14599,16 @@ sub interface_glx_output {
else {
$type = 'gl-null';
}
- @$row = ({
- main::key($$num++,0,1,'Message') => main::message($type),
+ push(@$rows, {
+ main::key($$num++,0,1,'Message') => main::message($type)
});
return;
}
- # print join("\n", @glxinfo),"\n";
+ # print join("\n", @$glxinfo),"\n";
my $compat_version = '';
my ($b_compat,$b_nogl,@core_profile_version,@direct_render,@renderer,
@opengl_version,@working);
- foreach (@glxinfo){
+ foreach (@$glxinfo){
next if /^\s/;
if (/^opengl renderer/i){
@working = split(/:\s*/, $_, 2);
@@ -14313,26 +14678,28 @@ sub interface_glx_output {
}
$version = join(', ', @opengl_version) if @opengl_version;
$renderer = join(', ', @renderer) if @renderer;
- @$row = ({
+ my $j = scalar @$rows;
+ push(@$rows, {
main::key($$num++,1,1,'OpenGL') => '',
main::key($$num++,1,2,'renderer') => ($renderer) ? $renderer : 'N/A',
main::key($$num++,0,2,'v') => ($version) ? $version : 'N/A',
});
if ($b_compat && $extra > 1 && $compat_version){
- $row->[0]{main::key($$num++,0,2,'compat-v')} = $compat_version;
+ $rows->[$j]{main::key($$num++,0,2,'compat-v')} = $compat_version;
}
if ($extra > 0){
- $row->[0]{main::key($$num++,0,2,'direct render')} = $direct_render;
+ $rows->[$j]{main::key($$num++,0,2,'direct render')} = $direct_render;
}
eval $end if $b_log;
}
# WARNING! Never seen a GOP type UEFI, needs more data
sub interface_vesa_output {
eval $start if $b_log;
- my ($row,$num) = @_;
+ my ($rows,$num) = @_;
my ($controller,$dac,$interface,$ram,$source,$version);
# note: goes to stderr, not stdout
my @data = main::grabber($graphics{'xvesa'} . ' -listmodes 2>&1');
+ my $j = scalar @$rows;
if ($data[0] && $data[0] =~ /^(VBE|GOP)\s+version\s+(\S+)\s\(([^)]+)\)/i){
$interface = $1;
$version = $2;
@@ -14347,18 +14714,18 @@ sub interface_vesa_output {
$ram = main::get_size($ram,'string');
}
if (!$interface){
- $row->[0]{main::key($$num++,0,1,'Message')} = main::message('xvesa-interface');
+ $rows->[$j]{main::key($$num++,0,1,'Message')} = main::message('xvesa-interface');
}
else {
- $row->[0]{main::key($$num++,1,1,'Interface')} = $interface;
- $row->[0]{main::key($$num++,0,2,'v')} = ($version) ? $version : 'N/A';
- $row->[0]{main::key($$num++,0,2,'source')} = ($source) ? $source : 'N/A';
+ $rows->[$j]{main::key($$num++,1,1,'Interface')} = $interface;
+ $rows->[$j]{main::key($$num++,0,2,'v')} = ($version) ? $version : 'N/A';
+ $rows->[$j]{main::key($$num++,0,2,'source')} = ($source) ? $source : 'N/A';
if ($dac){
- $row->[0]{main::key($$num++,0,2,'dac')} = $dac;
- $row->[0]{main::key($$num++,0,2,'controller')} = $controller;
+ $rows->[$j]{main::key($$num++,0,2,'dac')} = $dac;
+ $rows->[$j]{main::key($$num++,0,2,'controller')} = $controller;
}
if ($ram){
- $row->[0]{main::key($$num++,0,2,'ram')} = $ram;
+ $rows->[$j]{main::key($$num++,0,2,'ram')} = $ram;
}
}
eval $end if $b_log;
@@ -14486,19 +14853,19 @@ sub wayland_data_advanced {
sub wlinfo_data {
eval $start if $b_log;
my ($program) = @_;
- my (@data,%mon,@temp,$ref);
+ my ($data,%mon,@temp,$ref);
my ($b_iwlo,$b_izxdg,$file,$hz,$id,$pos_x,$pos_y,$res_x,$res_y,$scale);
if (!$fake{'wl-info'}){
undef $monitor_ids;
- @data = main::grabber("$program 2>/dev/null",'','strip');
+ $data = main::grabber("$program 2>/dev/null",'','strip','ref');
}
else {
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/wayland/weston-info-2-mon-1.txt";
- @data = main::reader($file,'strip');
+ $file = "$fake_data_dir/wayland/weston-info-2-mon-1.txt";
+ $data = main::reader($file,'strip','ref');
}
- print 'wayland/weston-info raw: ', Data::Dumper::Dumper \@data if $dbg[46];
- main::log_data('dump','@data', \@data) if $b_log;
- foreach (@data){
+ print 'wayland/weston-info raw: ', Data::Dumper::Dumper $data if $dbg[46];
+ main::log_data('dump','@$data', $data) if $b_log;
+ foreach (@$data){
# print 'l: ', $_,"\n";
if (/^interface: 'wl_output', version: \d+, name: (\d+)$/){
$b_iwlo = 1;
@@ -14627,7 +14994,7 @@ sub swaymsg_data {
}
else {
undef $monitor_ids;
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/wayland/swaymsg-2-monitor-1.txt";
+ $file = "$fake_data_dir/wayland/swaymsg-2-monitor-1.txt";
@data = main::reader($file,'strip');
}
print 'swaymsg: ', Data::Dumper::Dumper \@data if $dbg[46];
@@ -14729,25 +15096,25 @@ sub wlrrandr_data {
eval $start if $b_log;
my ($program) = @_;
my ($file,$hz,$id,$info,$model,$pos_x,$pos_y,$res_x,$res_y,$scale,$serial);
- my (@data,@temp);
+ my ($data,@temp);
if (!$fake{'wlr-randr'}){
- @data = main::grabber("$program 2>/dev/null",'','strip');
+ $data = main::grabber("$program 2>/dev/null",'','strip','ref');
}
else {
undef $monitor_ids;
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/wayland/wlr-randr-2-monitor-1.txt";
- @data = main::reader($file,'strip');
+ $file = "$fake_data_dir/wayland/wlr-randr-2-monitor-1.txt";
+ $data = main::reader($file,'strip','ref');
}
- foreach (@data){
+ foreach (@$data){
push(@temp,'~~') if /^([A-Z]+-[ABID\d-]+)\s['"]/i;
push(@temp,$_);
}
push(@temp,'~~') if @temp;
- @data = @temp;
- $b_wayland_data = 1 if scalar @data > 4;
- print 'wlr-randr: ', Data::Dumper::Dumper \@data if $dbg[46];
- main::log_data('dump','@data', \@data) if $b_log;
- foreach (@data){
+ @$data = @temp;
+ $b_wayland_data = 1 if scalar @$data > 4;
+ print 'wlr-randr: ', Data::Dumper::Dumper $data if $dbg[46];
+ main::log_data('dump','@$data', $data) if $b_log;
+ foreach (@$data){
if ($_ eq '~~' && $id){
$monitor_ids->{$id}{'hz'} = $hz;
$monitor_ids->{$id}{'model'} = $model if $model && !$monitor_ids->{$id}{'model'};
@@ -14844,15 +15211,15 @@ sub xdpyinfo_data {
my ($diagonal,$diagonal_m,$dpi) = ('','','');
my ($screen_id,$screen,@working);
my ($res_x,$res_y,$size_x,$size_x_i,$size_y,$size_y_i);
- my @xdpyinfo = main::grabber("$program $display_opt 2>/dev/null","\n",'strip');
- # @xdpyinfo = map {s/^\s+//;$_} @xdpyinfo if @xdpyinfo;
- # print join("\n",@xdpyinfo), "\n";
+ my $xdpyinfo = main::grabber("$program $display_opt 2>/dev/null","\n",'strip','ref');
+ # @$xdpyinfo = map {s/^\s+//;$_} @$xdpyinfo if @$xdpyinfo;
+ # print join("\n",@$xdpyinfo), "\n";
# X vendor and version detection.
# new method added since radeon and X.org and the disappearance of
# <X server name> version : ...etc. Later on, the normal textual version string
# returned, e.g. like: X.Org version: 6.8.2
# A failover mechanism is in place: if $version empty, release number parsed instead
- foreach (@xdpyinfo){
+ foreach (@$xdpyinfo){
@working = split(/:\s+/, $_);
next if (($graphics{'screens'} && $working[0] !~ /^(dimensions$|screen\s#)/) || !$working[0]);
# print "$_\n";
@@ -14936,18 +15303,18 @@ sub xrandr_data {
my ($diagonal,$diagonal_m,$dpi,$monitor_id,$pos_x,$pos_y,$primary);
my ($res_x,$res_x_max,$res_y,$res_y_max);
my ($screen_id,$set_as,$size_x,$size_x_i,$size_y,$size_y_i,$x_screen);
- my (@ids,%monitors,@xrandr_screens,@xrandr);
+ my (@ids,%monitors,@xrandr_screens,$xrandr);
if (!$fake{'xrandr'}){
- @xrandr = main::grabber("$program $display_opt 2>/dev/null",'','strip');
+ $xrandr = main::grabber("$program $display_opt 2>/dev/null",'','strip','ref');
}
else {
- # @xrandr = main::reader("$ENV{HOME}/bin/scripts/inxi/data/xrandr/xrandr-test-1.txt",'strip');
- @xrandr = main::reader("$ENV{HOME}/bin/scripts/inxi/data/xrandr/xrandr-test-2.txt",'strip');
+ # $xrandr = main::reader("$ENV{HOME}/bin/scripts/inxi/data/xrandr/xrandr-test-1.txt",'strip','ref');
+ $xrandr = main::reader("$ENV{HOME}/bin/scripts/inxi/data/xrandr/xrandr-test-2.txt",'strip','ref');
}
# $graphics{'dimensions'} = (\@dimensions);
# we get a bit more info from xrandr than xdpyinfo, but xrandr fails to handle
# multiple screens from different video cards
- foreach (@xrandr){
+ foreach (@$xrandr){
# note: no mm as with xdpyinfo
# Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 8192 x 8192
if (/^Screen ([0-9]+):/){
@@ -15091,7 +15458,7 @@ sub display_server_data {
# load the extra X paths, it's important that these are first, because
# later Xorg versions show error if run in console or ssh if the true path
# is not used.
- @paths = (qw(/usr/lib /usr/lib/xorg /usr/lib/xorg-server /usr/libexec /usr/X11R6/bin), @paths);
+ @paths = (qw(/usr/lib /usr/lib/xorg /usr/lib/xorg-server /usr/libexec), @paths);
my (@data,$server,$version);
if (!$graphics{'x-server'} || !$graphics{'x-server'}->[0][1]){
# IMPORTANT: both commands send version data to stderr!
@@ -15145,7 +15512,7 @@ sub display_server_data {
push(@{$graphics{'x-server'}},['Xwayland',$version]);
}
# remove extra X paths from global @paths
- @paths = grep { !/^\/usr\/lib|xorg|X11R6|libexec/ } @paths;
+ @paths = grep { !/^\/usr\/lib|xorg|libexec/ } @paths;
eval $end if $b_log;
}
sub display_protocol {
@@ -15199,7 +15566,8 @@ sub display_protocol {
sub gpu_drivers_sys {
eval $start if $b_log;
my ($id) = @_;
- my ($driver,@drivers);
+ my ($driver);
+ my $drivers = [];
# we only want list of drivers for cards with a connected monitor, and inactive
# ports are already removed by the 'all' stage.
foreach my $port (keys %{$monitor_ids}){
@@ -15211,20 +15579,21 @@ sub gpu_drivers_sys {
}
else {
foreach $driver (@{$monitor_ids->{$port}{'drivers'}}){
- push(@drivers,$driver);
+ push(@$drivers,$driver);
}
}
}
- if (@drivers){
- @drivers = sort(@drivers);
- main::uniq(\@drivers);
+ if (@$drivers){
+ @$drivers = sort(@$drivers);
+ main::uniq($drivers);
}
eval $end if $b_log;
- @drivers ? return \@drivers : return;
+ return $drivers;
}
sub display_drivers_x {
eval $start if $b_log;
- my ($driver,@driver_data,,%drivers);
+ my ($driver,%drivers);
+ my $driver_data = [];
my ($alternate,$failed,$loaded,$sep,$unloaded) = ('','','','','');
if (my $log = $system_files{'xorg-log'}){
if ($fake{'xorg-log'}){
@@ -15234,7 +15603,7 @@ sub display_drivers_x {
# $log = "$ENV{HOME}/bin/scripts/inxi/data/xorg-logs/Xorg.0-gm10.log";
# $log = "$ENV{HOME}/bin/scripts/inxi/data/xorg-logs/xorg-multi-driver-1.log";
}
- my @xorg = main::reader($log);
+ my $xorg = main::reader($log,'','ref');
# list is from sgfxi plus non-free drivers, plus ARM drivers.
# Don't use ati. It's just a wrapper for: r128, mach64, radeon
my $list = join('|', qw(amdgpu apm ark armsoc atimisc
@@ -15245,21 +15614,22 @@ sub display_drivers_x {
s3virge s3 savage siliconmotion sisimedia sisusb sis
sunbw2 suncg14 suncg3 suncg6 sunffb sunleo suntcx tdfx tga trident tseng
unichrome v4l vboxvideo vesa vga via vmware vmwgfx voodoo));
+ $list = qr/$list/; # i only added perl 5.14, don't use
# it's much cheaper to grab the simple pattern match then do the expensive one
# in the main loop.
# @xorg = grep {/Failed|Unload|Loading/} @xorg;
- foreach (@xorg){
+ foreach (@$xorg){
next if !/Failed|Unload|Loading/;
# print "$_\n";
# note that in file names, driver is always lower case
- if (/\sLoading.*($list)_drv.so$/i){
+ if (/\sLoading.*($list)_drv\.so$/i){
$driver=lc($1);
# we get all the actually loaded drivers first, we will use this to compare the
# failed/unloaded, which have not always actually been truly loaded
$drivers{$driver}='loaded';
}
# openbsd uses UnloadModule:
- elsif (/(Unloading\s|UnloadModule).*\"?($list)(_drv.so)?\"?$/i){
+ elsif (/(Unloading\s|UnloadModule).*\"?($list)(_drv\.so)?\"?$/i){
$driver=lc($2);
# we get all the actually loaded drivers first, we will use this to compare the
# failed/unloaded, which have not always actually been truly loaded
@@ -15315,56 +15685,422 @@ sub display_drivers_x {
}
}
if ($loaded || $unloaded || $failed || $alternate){
- @driver_data = ($loaded,$unloaded,$failed,$alternate);
+ @$driver_data = ($loaded,$unloaded,$failed,$alternate);
}
}
eval $end if $b_log;
- @driver_data ? return \@driver_data : return;
+ return $driver_data;
+}
+
+## GPU DATA ##
+sub set_amd_data {
+ $gpu_amd = [
+ # no ids
+ {'arch' => 'Wonder',
+ 'ids' => '',
+ 'code' => 'Wonder',
+ 'process' => 'NEC 800nm',
+ 'years' => '1986-92',
+ },
+ {'arch' => 'Mach',
+ 'ids' => '4158|4354|4358|4554|4654|4754|4755|4758|4c42|4c49|4c50|4c54|5354|' .
+ '5654|5655|5656',
+ 'code' => 'Mach64',
+ 'process' => 'TSMC 500-600nm',
+ 'years' => '1992-97',
+ },
+ {'arch' => 'Rage 2',
+ 'ids' => '4756|4757|4759|475a|4c47',
+ 'code' => 'Rage 2',
+ 'process' => 'TSMC 500nm',
+ 'years' => '1996',
+ },
+ {'arch' => 'Rage 3',
+ 'ids' => '4742|4744|4749|474d|474f|4750|4752',
+ 'code' => 'Rage 3',
+ 'process' => 'TSMC 350nm',
+ 'years' => '1997-99',
+ },
+ {'arch' => 'Rage 4',
+ 'ids' => '474e|4753|4c46|4c4d|4c52|4d46|5044|5046|5050|5052|5245|5246|524b|' .
+ '524c|534d|5446|5452',
+ 'code' => 'Rage 4',
+ 'process' => 'TSMC 250-350nm',
+ 'years' => '1998-99',
+ },
+ # vendor 1014 IBM, subvendor: 1092
+ # 0172|0173|0174|0184
+ # {'arch' => 'IBM',
+ # 'code' => 'Fire GL',
+ # 'process' => 'IBM 156-250nm',
+ # 'years' => '1999-2001',
+ # },
+ # rage 5 was game cube flipper chip
+ {'arch' => 'Rage 6',
+ 'ids' => '4137|4337|4437|4c59|5144|5159|515e',
+ 'code' => 'R100',
+ 'process' => 'TSMC 180nm',
+ 'years' => '2000-07',
+ },
+ {'arch' => 'Rage 7',
+ 'ids' => '4136|4150|4152|4170|4172|4242|4336|4966|496e|4c57|4c58|4c66|4c6e|' .
+ '4e51|4f72|4f73|5148|514c|514d|5157|5834|5835|5940|5941|5944|5960|5961|5962|' .
+ '5964|5965|5b63|5b72|5b73|5c61|5c63|5d44|5d45|7100|7101|7102|7109|710a|710b|' .
+ '7120|7129|7140|7142|7143|7145|7146|7147|7149|714a|715f|7162|7163|7166|7167|' .
+ '7181|7183|7186|7187|718b|718c|718d|7193|7196|719f|71a0|71a1|71a3|71a7|71c0|' .
+ '71c1|71c2|71c3|71c5|71c6|71c7|71ce|71d5|71d6|71de|71e0|71e1|71e2|71e6|71e7|' .
+ '7240|7244|7248|7249|724b|7269|726b|7280|7288|7291|7293|72a0|72a8|72b1|72b3|' .
+ '7834|7835|791e',
+ 'code' => 'R200',
+ 'process' => 'TSMC 150nm',
+ 'years' => '2001-06',
+ },
+ {'arch' => 'Rage 8',
+ 'ids' => '4144|4146|4147|4148|4151|4153|4154|4155|4157|4164|4165|4166|4168|' .
+ '4171|4173|4e44|4e45|4e46|4e47|4e48|4e49|4e4b|4e50|4e52|4e54|4e64|4e65|4e66|' .
+ '4e67|4e68|4e69|4e6a|4e71|5a41|5a42|5a61|5a62',
+ 'code' => 'R300',
+ 'process' => 'TSMC 130nm',
+ 'years' => '2002-07',
+ },
+ {'arch' => 'Rage 9',
+ 'ids' => '3150|3151|3152|3154|3155|3171|3e50|3e54|3e70|4e4a|4e56|5460|5461|' .
+ '5462|5464|5657|5854|5874|5954|5955|5974|5975|5b60|5b62|5b64|5b65|5b66|5b70|' .
+ '5b74|5b75',
+ 'code' => 'R360-R400',
+ 'process' => 'TSMC 110nm',
+ 'years' => '2003-08',
+ },
+ {'arch' => 'R400',
+ 'ids' => '4a49|4a4a|4a4b|4a4d|4a4e|4a4f|4a50|4a54|4a69|4a6a|4a6b|4a70|4a74|' .
+ '4b49|4b4b|4b4c|4b69|4b6b|4b6c|5549|554a|554b|554d|554e|554f|5550|5551|5569|' .
+ '556b|556d|556f|5571|564b|564f|5652|5653|5d48|5d49|5d4a|5d4d|5d4e|5d4f|5d50|' .
+ '5d52|5d57|5d6d|5d6f|5d72|5d77|5e48|5e49|5e4a|5e4b|5e4c|5e4d|5e4f|5e6b|5e6d|' .
+ '5f57|791f|793f|7941|7942|796e',
+ 'code' => 'R400',
+ 'process' => 'TSMC 55-130nm',
+ 'years' => '2004-08',
+ },
+ {'arch' => 'R500',
+ 'ids' => '7104|710e|710f|7124|712e|712f|7152|7153|7172|7173|7188|718a|719b|' .
+ '71bb|71c4|71d2|71d4|71f2|7210|7211|724e|726e|940f|94c8|94c9|9511|9581|9583|' .
+ '958b|958d',
+ 'code' => 'R500',
+ 'process' => 'TSMC 90nm',
+ 'years' => '2005-07',
+ },
+ {'arch' => 'TeraScale',
+ 'ids' => '4346|4630|4631|9400|9401|9403|9405|940a|940b|9440|9441|9442|9443|' .
+ '9444|9446|944a|944b|944c|944e|9450|9452|9456|945a|9460|9462|946a|9480|9488|' .
+ '9489|9490|9491|9495|9498|949c|949e|949f|94a0|94a1|94a3|94b3|94b4|94c1|94c3|' .
+ '94c4|94c5|94c7|94cb|94cc|9500|9501|9504|9505|9506|9507|9508|9509|950f|9513|' .
+ '9515|9519|9540|954f|9552|9553|9555|9557|955f|9580|9586|9587|9588|9589|958a|' .
+ '958c|9591|9593|9595|9596|9597|9598|9599|95c0|95c2|95c4|95c5|95c6|95c9|95cc|' .
+ '95cd|95cf|9610|9611|9612|9613|9614|9615|9616|9710|9712|9713|9714|9715',
+ 'code' => '',
+ 'process' => 'TSMC 55-65nm',
+ 'years' => '2005-13',
+ },
+ {'arch' => 'TeraScale 2',
+ 'ids' => '6720|6738|6739|673e|6740|6741|6742|6743|6749|674a|6750|6751|6758|' .
+ '6759|675b|675d|675f|6760|6761|6763|6764|6765|6766|6767|6768|6770|6771|6772|' .
+ '6778|6779|677b|6840|6841|6842|6843|6880|6888|6889|688a|688c|688d|6898|6899|' .
+ '689b|689c|689d|689e|68a0|68a1|68a8|68a9|68b8|68b9|68ba|68be|68bf|68c0|68c1|' .
+ '68c7|68c8|68c9|68d8|68d9|68da|68de|68e0|68e1|68e4|68e5|68e8|68e9|68f1|68f2|' .
+ '68f8|68f9|68fa|68fe|9640|9641|9642|9643|9644|9645|9647|9648|9649|964a|964b|' .
+ '964c|964e|964f|9802|9803|9804|9805|9806|9807|9808|9809|980a',
+ 'code' => 'Evergreen',
+ 'process' => 'TSMC 32-40nm',
+ 'years' => '2009-15',
+ },
+ {'arch' => 'TeraScale 3',
+ 'ids' => '6704|6707|6718|6719|671c|671d|671f|9900|9901|9903|9904|9905|9906|' .
+ '9907|9908|9909|990a|990b|990c|990d|990e|990f|9910|9913|9917|9918|9919|9990|' .
+ '9991|9992|9993|9994|9995|9996|9997|9998|9999|999a|999b|999c|999d|99a0|99a2|' .
+ '99a4',
+ 'code' => 'Northern Islands',
+ 'process' => 'TSMC 32nm',
+ 'years' => '2010-13',
+ },
+ {'arch' => 'GCN 1',
+ 'ids' => '154c|6600|6601|6604|6605|6606|6607|6608|6609|6610|6611|6613|6631|' .
+ '6660|6663|6664|6665|6667|666f|6780|6784|6788|678a|6798|679a|679b|679e|679f|' .
+ '6800|6801|6802|6806|6808|6809|6810|6811|6816|6817|6818|6819|6820|6821|6822|' .
+ '6823|6825|6826|6827|6828|6829|682a|682b|682c|682d|682f|6835|6837|683d|683f',
+ 'code' => 'Southern Islands',
+ 'process' => 'TSMC 28nm',
+ 'years' => '2011-20',
+ },
+ {'arch' => 'GCN 2',
+ 'ids' => '1304|1305|1306|1307|1309|130a|130b|130c|130d|130e|130f|1310|1311|' .
+ '1312|1313|1315|1316|1317|1318|131b|131c|131d|6640|6641|6646|6647|6649|664d|' .
+ '6650|6651|6658|665c|665d|665f|67a0|67a1|67a2|67a8|67a9|67aa|67b0|67b1|67b8|' .
+ '67b9|67be|9830|9831|9832|9833|9834|9835|9836|9837|9838|9839|983d|9850|9851|' .
+ '9852|9853|9854|9855|9856|9857|9858|9859|985a|985b|985c|985d|985e|985f|98e4|' .
+ '9920',
+ 'code' => 'Sea Islands',
+ 'process' => 'GF/TSMC 16-28nm', # both TSMC and GlobalFoundries
+ 'years' => '2013-17',
+ },
+ {'arch' => 'GCN 3',
+ 'ids' => '6900|6901|6907|6920|6921|6929|692b|6938|6939|693b|7300|9874',
+ 'code' => 'Volcanic Islands',
+ 'process' => 'TSMC 28nm',
+ 'years' => '2014-19',
+ },
+ {'arch' => 'GCN 4',
+ 'ids' => '154e|1551|1552|1561|67c0|67c2|67c4|67c7|67ca|67cc|67cf|67d0|67d4|' .
+ '67d7|67df|67e0|67e1|67e3|67e8|67e9|67eb|67ef|67ff|694c|694e|694f|6980|6981|' .
+ '6985|6986|6987|698f|6995|699f|6fdf|9924|9925',
+ 'code' => 'Arctic Islands',
+ 'process' => 'GF 14nm',
+ 'years' => '2016-20',
+ },
+ {'arch' => 'GCN 5.1',
+ 'ids' => '15df|1636|1638|164c|66a0|66a1|66a2|66a3|66a7|66af|69af',
+ 'code' => 'Vega 2',
+ 'process' => 'TSMC n7 (7nm)',
+ 'years' => '2018-21',
+ },
+ {'arch' => 'GCN 5',
+ 'ids' => '15d8|15dd|15ff|6860|6861|6862|6863|6864|6867|6868|6869|686a|686b|' .
+ '686c|686d|686e|687f|69a0|69a1|69a2|69a3',
+ 'code' => 'Vega',
+ 'process' => 'GF 14nm',
+ 'years' => '2017-20',
+ },
+ {'arch' => 'RDNA 1',
+ 'ids' => '13e9|13fe|1478|1479|1607|7310|7312|731f|7340|7341|7347|734f|7360|' .
+ '7362',
+ 'code' => 'Navi',
+ 'process' => 'TSMC n7 (7nm)',
+ 'years' => '2019-20',
+ },
+ {'arch' => 'RDNA 2',
+ 'ids' => '1506|15e7|163f|164d|1681|73a1|73a2|73a3|73a5|73ab|73ae|73af|73bf|' .
+ '73c3|73ce|73df|73e0|73e1|73e3|73ef|73ff|7421|7422|7423|7424|743f',
+ 'code' => 'Navi 2x',
+ 'process' => 'TSMC n7 (7nm)',
+ 'years' => '2020-22',
+ },
+ {'arch' => 'RDNA 3',
+ 'ids' => '15bf|164f',
+ 'code' => 'Navi 3x',
+ 'process' => 'TSMC n5 (5nm)',
+ 'years' => '2022+',
+ },
+ {'arch' => 'CDNA 1',
+ 'ids' => '7388|738c|738e',
+ 'code' => 'Instinct MI1xx',
+ 'process' => 'TSMC n7 (7nm)',
+ 'years' => '2020',
+ },
+ {'arch' => 'CDNA 2',
+ 'ids' => '7408|740c|740f',
+ 'code' => 'Instinct MI2xx',
+ 'process' => 'TSMC n6 (7nm)',
+ 'years' => '2021-22+',
+ },
+ ];
}
-sub set_nvidia_data {
- my ($status_eol);
+sub set_intel_data {
+ $gpu_intel = [
+ {'arch' => 'Gen1',
+ 'ids' => '1132|7120|7121|7122|7123|7124|7125|7126|7128|712a',
+ 'code' => '',
+ 'process' => 'Intel 150nm',
+ 'years' => '1998-2002',
+ },
+ # ill-fated standalone gfx card
+ {'arch' => 'i740',
+ 'ids' => '7800',
+ 'code' => '',
+ 'process' => 'Intel 150nm',
+ 'years' => '1998',
+ },
+ {'arch' => 'Gen2',
+ 'ids' => '2562|2572|3577|3582|358e',
+ 'code' => '',
+ 'process' => 'Intel 130nm',
+ 'years' => '2002-03',
+ },
+ {'arch' => 'Gen3',
+ 'ids' => '2582|2592|2780|2782|2792',
+ 'code' => 'Intel 130nm',
+ 'process' => '',
+ 'years' => '2004-05',
+ },
+ {'arch' => 'Gen3.5',
+ 'ids' => '2772|2776|27a2|27a6|27ae|2972|2973',
+ 'code' => '',
+ 'process' => 'Intel 90nm',
+ 'years' => '2005-06',
+ },
+ {'arch' => 'Gen4',
+ 'ids' => '2982|2983|2992|2993|29a2|29a3|29b2|29b3|29c2|29c3|29d2|29d3|2a02|' .
+ '2a03|2a12|2a13',
+ 'code' => '',
+ 'process' => 'Intel 65n',
+ 'years' => '2006-07',
+ },
+ {'arch' => 'PowerVR SGX535',
+ 'ids' => '8108|8109|a001|a002|a011|a012',
+ 'code' => '',
+ 'process' => 'Intel 45-130nm',
+ 'year' => '2008-10',
+ },
+ {'arch' => 'Gen5',
+ 'ids' => '2a41|2a42|2a43|2e02|2e03|2e12|2e13|2e22|2e23|2e32|2e33|2e42|2e43|' .
+ '2e92|2e93',
+ 'code' => '',
+ 'process' => 'Intel 45nm',
+ 'years' => '2008',
+ },
+ {'arch' => 'PowerVR SGX545',
+ 'ids' => '0be0|0be1|0be2|0be3|0be4|0be5|0be6|0be7|0be8|0be9|0bea|0beb|0bec|' .
+ '0bed|0bee|0bef',
+ 'code' => '',
+ 'process' => 'Intel 65nm',
+ 'years' => '2008-10',
+ },
+ {'arch' => 'Gen5.75',
+ 'ids' => '0042|0046|004a|0402|0412|0416',
+ 'code' => '',
+ 'process' => 'Intel 45nm',
+ 'years' => '2010',
+ },
+ {'arch' => 'Knights',
+ 'ids' => '',
+ 'code' => '',
+ 'process' => 'Intel 22nm',
+ 'years' => '2012-13',
+ },
+ {'arch' => 'Gen6',
+ 'ids' => '0102|0106|010b|010e|0112|0116|0122|0126|08cf',
+ 'code' => '',
+ 'process' => 'Intel 32nm',
+ 'years' => '2011',
+ },
+ {'arch' => 'Gen7',
+ 'ids' => '0152|0156|015a|015e|0162|0166|016a|0172|0176',
+ 'code' => '',
+ 'process' => 'Intel 22nm',
+ 'years' => '2012-13',
+ },
+ {'arch' => 'Gen7.5',
+ 'ids' => '0406|041e|0a06|0a16|0a22|0a26|0a2a|0a2e',
+ 'code' => '',
+ 'process' => 'Intel 22nm',
+ 'years' => '2013',
+ },
+ {'arch' => 'Gen8',
+ 'ids' => '1602|160a|160b|160d|160e|1612|1616|161a|161b|161d|161e|1622|1626|' .
+ '162a|162b|162d|162e|1632|1636|163a|163b|163d|163e|22b0|22b1',
+ 'code' => '',
+ 'process' => 'Intel 14nm',
+ 'years' => '2014-15',
+ },
+ {'arch' => 'Gen9',
+ 'ids' => '1902|1906|1912|1916|191b|191d|191e|1921|1926|1927|192b|192d|1932|' .
+ '193a|193b|193d|5a84|5a85',
+ 'code' => '',
+ 'process' => 'Intel 14n',
+ 'years' => '2015-16',
+ },
+ {'arch' => 'Gen9.5',
+ 'ids' => '3184|3185|3e90|3e91|3e92|3e93|3e96|3e98|3e9b|3ea0|3ea5|5902|5912|' .
+ '5916|5917|591b|591c|591d|591e|5923|5926|5927|87c0|9b41|9ba8|9bc4|9bc5|9bc8|' .
+ '9bca',
+ 'code' => '',
+ 'process' => 'Intel 14nm',
+ 'years' => '2016-20',
+ },
+ # gen10 was cancelled.,
+ {'arch' => 'Gen11',
+ 'ids' => '0d16|0d26|0d36|4e55|4e61|4e71|8a51|8a52|8a53|8a56|8a5a|8a5c',
+ 'code' => '',
+ 'process' => 'Intel 10nm',
+ 'years' => '2019-21',
+ },
+ {'arch' => 'Gen12.1',
+ 'ids' => '4905|4908|4c8a|4c8b|4c90|4c9a|9a49|9a60|9a68',
+ 'code' => '',
+ 'process' => 'Intel 10nm',
+ 'years' => '2020-21',
+ },
+ {'arch' => 'Gen12.2',
+ 'ids' => '4626|46a3|46a6',
+ 'code' => '',
+ 'process' => 'Intel 10nm',
+ 'years' => '2021-22+',
+ },
+ {'arch' => '12.5',
+ 'ids' => '',
+ 'code' => 'Arctic Sound',
+ 'pattern' => 'Arctic',
+ 'process' => 'Intel 10nm',
+ 'years' => '2021-22+',
+ },
+ # Jupiter Sound cancelled?
+ {'arch' => 'Gen12.7',
+ 'ids' => '',
+ 'code' => 'Alchemist',
+ 'pattern' => 'Alchemist|DG2|Arc A\d{3}M?',
+ 'process' => 'TSMC n6 (7nm)',
+ 'years' => '2022+',
+ },
+ ];
+}
+sub set_nv_data {
# this is vendor id: 12d2, nv1/riva/tnt type cards
# 0008|0009|0010|0018|0019
# and these are vendor id: 10de for 73.14
# 0020|0028|0029|002c|002d|00a0|0100|0101|0103|0150|0151|0152|0153
- if (($show{'nvidia'})){
- $status_eol = main::message('nv-legacy-eol');
- }
- else {
- $status_eol = main::message('nv-legacy-eol-try');
- }
+ my $try = ($show{'gpu-data'}) ? '' : '-try';
+ my $status_eol = main::message('nv-legacy-eol' . $try);
+ my $date = $self_date;
+ $date =~ s/-\d+$//;
+ my $status_current = main::message('nv-current',$date);
# load legacy data, note, if there are 2 or more arch in 1 legacy, it has 1
# item per arch. kernel/last/xorg support either from nvidia or sgfxi
- $nv_legacy = [
- {'arch' => 'Fahrenhei',
+ ## Legacy 71.86.xx
+ $gpu_nv = [
+ {'arch' => 'Fahrenheit',
'ids' => '0008|0009|0010|0018|0019|0020|0028|0029|002c|002d|00a0',
'code' => 'NVx',
'kernel' => '2.6.38',
+ 'legacy' => 1,
'process' => 'TSMC 220-350nm',
'release' => '71.86.15',
'series' => '71.86.xx',
'status' => $status_eol,
'xorg' => '1.7',
+ 'years' => '1998-2000',
},
{'arch' => 'Celsius',
'ids' => '0100|0101|0103|0150|0151|0152|0153',
'code' => 'NV1x',
'kernel' => '2.6.38',
+ 'legacy' => 1,
'process' => 'TSMC 150-220nm',
'release' => '71.86.15',
'series' => '71.86.xx',
'status' => $status_eol,
'xorg' => '1.7',
+ 'years' => '1999-2005',
},
+ ## Legacy 96.43.xx
{'arch' => 'Celsius',
'ids' => '0110|0111|0112|0113|01a0',
'code' => 'NV1x',
'kernel' => '3.6',
+ 'legacy' => 1,
'process' => 'TSMC 150-220nm',
'release' => '96.43.23',
'series' => '96.43.xx',
'status' => $status_eol,
'xorg' => '1.12',
+ 'years' => '1999-2005',
},
{'arch' => 'Kelvin',
'ids' => '0170|0171|0172|0173|0174|0175|0176|0177|0178|0179|017a|017c|017d|' .
@@ -15372,24 +16108,30 @@ sub set_nvidia_data {
'0253|0258|0259|025b|0280|0281|0282|0286|0288|0289|028c',
'code' => 'NV[12]x',
'kernel' => '3.6',
+ 'legacy' => 1,
'process' => 'TSMC 150nm',
'release' => '96.43.23',
'series' => '96.43.xx',
'status' => $status_eol,
'xorg' => '1.12',
+ 'years' => '2001-03',
},
+ ## Legacy 173.14.xx
{'arch' => 'Rankine',
'ids' => '00fa|00fb|00fc|00fd|00fe|0301|0302|0308|0309|0311|0312|0314|031a|' .
'031b|031c|0320|0321|0322|0323|0324|0325|0326|0327|0328|032a|032b|032c|032d|' .
'0330|0331|0332|0333|0334|0338|033f|0341|0342|0343|0344|0347|0348|034c|034e',
'code' => 'NV3x',
'kernel' => '3.12',
+ 'legacy' => 1,
'process' => '130-150nm', # IBM 130, TSMC 130-150
'release' => '173.14.39',
'series' => '173.14.xx',
'status' => $status_eol,
'xorg' => '1.15',
+ 'years' => '2003-05',
},
+ ## Legacy 304.xx
{'arch' => 'Curie',
'ids' => '0040|0041|0042|0043|0044|0045|0046|0047|0048|004e|0090|0091|0092|' .
'0093|0095|0098|0099|009d|00c0|00c1|00c2|00c3|00c8|00c9|00cc|00cd|00ce|00f1|' .
@@ -15402,12 +16144,15 @@ sub set_nvidia_data {
'03d0|03d1|03d2|03d5|03d6|0531|0533|053a|053b|053e|07e0|07e1|07e2|07e3|07e5',
'code' => '', # hard to get these, roughly MCP[567]x/NV4x/G7x
'kernel' => '4.13',
+ 'legacy' => 1,
'process' => '90-130nm', # IBM 130, TSMC 90-110
'release' => '304.137',
'series' => '304.xx',
'status' => $status_eol,
'xorg' => '1.19',
+ 'years' => '2003-13',
},
+ # Legacy 340.xx
# these are both Tesla and Tesla 2.0
{'arch' => 'Tesla',
'ids' => '0191|0193|0194|0197|019d|019e|0400|0401|0402|0403|0404|0405|0406|' .
@@ -15429,22 +16174,27 @@ sub set_nvidia_data {
'0cb1|0cbc|10c0|10c3|10c5|10d8',
'code' => '', # not clear, 8800/GT2xx/maybe G7x
'kernel' => '5.4',
+ 'legacy' => 1,
'process' => '40-80nm',
'release' => '340.108',
'series' => '340.xx',
'status' => $status_eol,
'xorg' => '1.20',
+ 'years' => '2006-13',
},
+ ## Legacy 367.xx
{'arch' => 'Kepler',
'ids' => '0fef|0ff2|11bf',
'code' => 'GKxxx',
'kernel' => '',
+ 'legacy' => 1,
'process' => 'TSMC 28nm',
'release' => '',
'series' => '367.xx',
'status' => main::message('nv-legacy-active','late 2022'),
- 'xorg' => '',
+ 'xorg' => '2012-18',
},
+ ## Legacy 390.xx
# this is Fermi, Fermi 2.0
{'arch' => 'Fermi',
'ids' => '06c0|06c4|06ca|06cd|06d1|06d2|06d8|06d9|06da|06dc|06dd|06de|06df|' .
@@ -15458,21 +16208,26 @@ sub set_nvidia_data {
'124d|1251',
'code' => 'GF1xx',
'kernel' => '',
+ 'legacy' => 1,
'process' => '40/28nm',
'release' => '',
'series' => '390.xx+',
'status' => main::message('nv-legacy-active','late 2022'),
'xorg' => '',
+ 'years' => '2010-16',
},
+ ## Legacy 470.xx
{'arch' => 'Fermi 2',
'ids' => '0fec|1281|1289|128b|1295|1298',
'code' => 'GF119/GK208',
'kernel' => '',
+ 'legacy' => 1,
'process' => 'TSMC 28nm',
'release' => '',
'series' => '470.xx+',
- 'status' => main::message('nv-legacy-active','~2023/24'),
+ 'status' => main::message('nv-legacy-active','2023/24'),
'xorg' => '',
+ 'years' => '2010-16',
},
{'arch' => 'Kepler',
'ids' => '0fc6|0fc8|0fc9|0fcd|0fce|0fd1|0fd2|0fd3|0fd4|0fd5|0fd8|0fd9|0fdf|' .
@@ -15485,17 +16240,17 @@ sub set_nvidia_data {
'1291|1292|1293|1295|1296|1299|129a|12b9|12ba',
'code' => 'GKxxx',
'kernel' => '',
+ 'legacy' => 1,
'process' => 'TSMC 28nm',
'release' => '',
'series' => '470.xx+',
- 'status' => main::message('nv-legacy-active','~2023/24'),
+ 'status' => main::message('nv-legacy-active','2023/24'),
'xorg' => '',
+ 'years' => '2012-18',
},
- ];
-
+ ## Current Active Series
# load microarch data, as stuff goes legacy, these will form new legacy items.
- $nv_arch = {
- 'Maxwell' => {
+ {'arch' => 'Maxwell',
'ids' => '1340|1341|1344|1346|1347|1348|1349|134b|134d|134e|134f|137a|137b|' .
'1380|1381|1382|1390|1391|1392|1393|1398|1399|139a|139b|139c|139d|13b0|13b1|' .
'13b2|13b3|13b4|13b6|13b9|13ba|13bb|13bc|13c0|13c2|13d7|13d8|13d9|13da|13f0|' .
@@ -15505,8 +16260,10 @@ sub set_nvidia_data {
'code' => 'GMxxx',
'process' => 'TSMC 28nm',
'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2014-19',
},
- 'Pascal' => {
+ {'arch' => 'Pascal',
'ids' => '15f0|15f7|15f8|15f9|17c2|1b00|1b02|1b06|1b30|1b38|1b80|1b81|1b82|' .
'1b83|1b84|1b87|1ba0|1ba1|1ba2|1bb0|1bb1|1bb4|1bb5|1bb6|1bb7|1bb8|1bb9|1bbb|' .
'1bc7|1be0|1be1|1c02|1c03|1c04|1c06|1c07|1c09|1c20|1c21|1c22|1c23|1c30|1c31|' .
@@ -15516,15 +16273,19 @@ sub set_nvidia_data {
'code' => 'GP10x',
'process' => 'TSMC 16nm',
'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2016-21',
},
- 'Volta' => {
+ {'arch' => 'Volta',
'ids' => '1d81|1db1|1db3|1db4|1db5|1db6|1db7|1db8|1dba|1df0|1df2|1df6|1fb0|' .
'20b0|20b3|20b6',
'code' => 'GV1xx',
'process' => 'TSMC 12nm',
'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2017-20',
},
- 'Turing' => {
+ {'arch' => 'Turing',
'ids' => '1e02|1e04|1e07|1e09|1e30|1e36|1e78|1e81|1e82|1e84|1e87|1e89|1e90|' .
'1e91|1e93|1eb0|1eb1|1eb5|1eb6|1ec2|1ec7|1ed0|1ed1|1ed3|1ef5|1f02|1f03|1f06|' .
'1f07|1f08|1f0a|1f0b|1f10|1f11|1f12|1f14|1f15|1f36|1f42|1f47|1f50|1f51|1f54|' .
@@ -15534,82 +16295,96 @@ sub set_nvidia_data {
'code' => 'TUxxx',
'process' => 'TSMC 12nm',
'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2018-22',
},
- 'Ampere' => {
+ {'arch' => 'Ampere',
'ids' => '20b0|20b2|20b5|20b7|20f1|2203|2204|2206|2208|220a|220d|2216|2230|' .
'2231|2232|2233|2235|2236|2237|2238|2414|2420|2438|2460|2482|2484|2486|2487|' .
'2488|2489|248a|249c|249d|24a0|24b0|24b1|24b6|24b7|24b8|24b9|24ba|24bb|24dc|' .
'24dd|24e0|24fa|2503|2504|2507|2508|2520|2523|2531|2560|2563|2571|25a0|25a2|' .
'25a5|25b6|25b8|25b9|25ba|25bb|25e0|25e2|25e5|25f9|25fa',
'code' => 'GAxxx',
- 'process' => 'TSMC 7nm',
+ 'process' => 'TSMC n7 (7nm)',
'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2020-22',
},
# no ids yet
- # 'Hopper' => {
- # 'ids' => '',
- # 'code' => 'GH1xx',
- # 'process' => 'TSMC n4',
- # },
- # 'Lovelace' => {
- # 'ids' => '',
- # 'code' => '',
- # 'process' => '',
- # },
- };
+ {'arch' => 'Hopper',
+ 'ids' => '',
+ 'code' => 'GH1xx',
+ 'pattern' => 'G?H[12]\d{2}',
+ 'process' => 'TSMC n4 (5nm)',
+ 'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2022+',
+ },
+ {'arch' => 'Lovelace',
+ 'ids' => '',
+ 'code' => 'AD1xx',
+ 'pattern' => 'G?L\d{1,4}|RTX 40\d{2}',
+ 'process' => 'TSMC n5 (5nm)',
+ 'series' => '515.xx+',
+ 'status' => $status_current,
+ 'years' => '2022-23+',
+ },
+ ];
}
-sub nvidia_data {
+sub gpu_data {
eval $start if $b_log;
- my ($product_id) = @_;
- my (%info);
- set_nvidia_data() if !$nv_legacy;
- my $date = $self_date;
- $date =~ s/-\d+$//;
- # Test for current active first, those will be most common, these will be
- # run in random order, which is fine since user ids will also be random
- foreach my $key (keys %$nv_arch){
- if ($product_id =~ /^($nv_arch->{$key}{'ids'})$/){
- %info = (
- 'arch' => $key,
- 'code' => $nv_arch->{$key}{'code'},
- 'kernel' => '',
- 'process' => $nv_arch->{$key}{'process'},
- 'release' => '',
- 'series' => $nv_arch->{$key}{'series'},
- 'status' => main::message('nv-current',$date),
- 'xorg' => '',
- );
- last;
- }
+ my ($v_id,$p_id,$name) = @_;
+ my ($gpu,$gpu_data,$b_nv);
+ if ($v_id eq '1002'){
+ set_amd_data() if !$gpu_amd;
+ $gpu = $gpu_amd;
}
- # then check for legacy
- if (!%info){
- # we reverse here since newer is more likely than older
- foreach my $item (reverse @$nv_legacy){
- if ($product_id =~ /^($item->{'ids'})$/){
- %info = (
- 'arch' => $item->{'arch'},
- 'code' => $item->{'code'},
- 'kernel' => $item->{'kernel'},
- 'process' => $item->{'process'},
- 'release' => $item->{'release'},
- 'series' => $item->{'series'},
- 'status' => $item->{'status'},
- 'xorg' => $item->{'xorg'},
- );
- last;
- }
- }
- if (%info){
- $info{'legacy'} = 1;
+ elsif ($v_id eq '8086'){
+ set_intel_data() if !$gpu_intel;
+ $gpu = $gpu_intel;
+ }
+ else {
+ set_nv_data() if !$gpu_nv;
+ $gpu = $gpu_nv;
+ $b_nv = 1;
+ }
+ $gpu_data = get_gpu_data($gpu,$p_id,$name);
+ eval $end if $b_log;
+ return ($gpu_data,$b_nv);
+}
+sub get_gpu_data {
+ eval $start if $b_log;
+ my ($gpu,$p_id,$name) = @_;
+ my ($info);
+ # Reverse, newer will be more common geneerally than older, so save some cpu!
+ # This means for amd/intel/nvidia current, the regex name search runs FIRST!
+ foreach my $item (reverse @$gpu){
+ next if !$item->{'ids'} && (!$item->{'pattern'} || !$name);
+ if (($item->{'ids'} && $p_id =~ /^($item->{'ids'})$/) ||
+ (!$item->{'ids'} && $item->{'pattern'} &&
+ $name =~ /\b($item->{'pattern'})\b/)){
+ $info = {
+ 'arch' => $item->{'arch'},
+ 'code' => $item->{'code'},
+ 'kernel' => $item->{'kernel'},
+ 'legacy' => $item->{'legacy'},
+ 'process' => $item->{'process'},
+ 'release' => $item->{'release'},
+ 'series' => $item->{'series'},
+ 'status' => $item->{'status'},
+ 'xorg' => $item->{'xorg'},
+ 'years' => $item->{'years'},
+ };
+ last;
}
}
- if (!%info){
- $info{'status'} = main::message('nv-unknown');
+ if (!$info){
+ $info->{'status'} = main::message('unknown-device-id');
}
- main::log_data('dump','%info',\%info) if $b_log;
+ main::log_data('dump','%info',$info) if $b_log;
+ print "Raw \$info data: ", Data::Dumper::Dumper $info if $dbg[49];
eval $end if $b_log;
- return \%info;
+ return $info;
}
## MONITOR DATA ##
@@ -15992,7 +16767,8 @@ sub flip_size_x_y {
## COMPOSITOR DATA ##
sub set_compositor_data {
eval $start if $b_log;
- if (my $compositors = get_compositors()){
+ my $compositors = get_compositors();
+ if (@$compositors){
my @data;
foreach my $compositor (@$compositors){
# gnome-shell is incredibly slow to return version
@@ -16011,7 +16787,7 @@ sub set_compositor_data {
}
sub get_compositors {
eval $start if $b_log;
- my @found;
+ my $found = [];
main::set_ps_gui() if !$loaded{'ps-gui'};
if (@ps_gui){
# ORDER MATTES!
@@ -16026,13 +16802,13 @@ sub get_compositors {
my $matches = join('|',@compositors) . $wl_compositors;
foreach my $psg (@ps_gui){
if ($psg =~ /^($matches)$/){
- push(@found,$1);
+ push(@$found,$1);
}
}
}
- main::log_data('dump','compositors:', \@found) if $b_log;
+ main::log_data('dump','$found compositors:', $found) if $b_log;
eval $end if $b_log;
- (@found) ? return \@found : return;
+ return $found;
}
## UTILITIES ##
@@ -16068,12 +16844,13 @@ package LogicalItem;
sub get {
eval $start if $b_log;
- my (@rows,$key1,$val1);
+ my ($key1,$val1);
+ my $rows = [];
my $num = 0;
if ($bsd_type){
$key1 = 'Message';
$val1 = main::message('logical-data-bsd',$uname[0]);
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1});
}
else {
LsblkData::set() if !$loaded{'lsblk'};
@@ -16083,117 +16860,113 @@ sub get {
my $key = 'Message';
# note: arch linux has a bug where lvs returns 0 if non root start
my $message = ($use{'logical-lvm'}) ? main::message('tool-permissions','lvs') : main::message('logical-data','');
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,$key) => $message,
- },);
+ });
}
else {
- my %processed = process_lvm_data();
- @rows = lvm_output(\%processed);
+ lvm_output($rows,process_lvm_data());
}
}
elsif ($use{'logical-lvm'} && $alerts{'lvs'}->{'action'} eq 'permissions'){
my $key = 'Message';
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,$key) => $alerts{'lvs'}->{'message'},
- },);
+ });
}
elsif (@lsblk && !$use{'logical-lvm'} && ($alerts{'lvs'}->{'action'} eq 'permissions' ||
$alerts{'lvs'}->{'action'} eq 'missing')){
my $key = 'Message';
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,$key) => main::message('logical-data',''),
- },);
+ });
}
elsif ($alerts{'lvs'}->{'action'} ne 'use'){
$key1 = $alerts{'lvs'}->{'action'};
$val1 = $alerts{'lvs'}->{'message'};
$key1 = ucfirst($key1);
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows, {main::key($num++,0,1,$key1) => $val1});
}
if ($use{'logical-general'}){
- my @general_data = general_data();
- push(@rows,general_output(\@general_data)) if @general_data;
+ my $general_data = general_data();
+ general_output($rows,$general_data) if @$general_data;
}
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub general_output {
eval $start if $b_log;
- my ($general_data) = @_;
- my ($size,@rows);
+ my ($rows,$general_data) = @_;
+ my ($size);
my ($j,$num) = (0,0);
# cryptsetup status luks-a00baac5-44ff-4b48-b303-3bedb1f623ce
foreach my $item (sort {$a->{'type'} cmp $b->{'type'}} @$general_data){
- $j = scalar @rows;
+ $j = scalar @$rows;
$size = ($item->{'size'}) ? main::get_size($item->{'size'}, 'string') : 'N/A';
- push(@rows,{
+ push(@$rows,{
main::key($num++,1,1,'Device') => $item->{'name'},
});
if ($b_admin){
$item->{'name'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'maj-min')} = $item->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,2,'maj-min')} = $item->{'maj-min'};
}
- $rows[$j]->{main::key($num++,0,2,'type')} = $item->{'type'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $item->{'type'};
if ($extra > 0 && $item->{'dm'}){
- $rows[$j]->{main::key($num++,0,2,'dm')} = $item->{'dm'};
+ $rows->[$j]{main::key($num++,0,2,'dm')} = $item->{'dm'};
}
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
my $b_fake;
- components_output('general',\$j,\$num,\@rows,\@{$item->{'components'}},\$b_fake);
+ components_output('general',\$j,\$num,$rows,\@{$item->{'components'}},\$b_fake);
}
eval $end if $b_log;
- return @rows;
}
sub lvm_output {
eval $start if $b_log;
- my ($lvm_data) = @_;
- my (@rows);
+ my ($rows,$lvm_data) = @_;
my ($size);
my ($j,$num) = (0,0);
foreach my $vg (sort keys %$lvm_data){
- $j = scalar @rows;
+ $j = scalar @$rows;
# print Data::Dumper::Dumper $lvm_data->{$vg};
$size = main::get_size($lvm_data->{$vg}{'vg-size'},'string','N/A');
- push(@rows,{
+ push(@$rows,{
main::key($num++,1,1,'Device') => '',
main::key($num++,0,2,'VG') => $vg,
main::key($num++,0,2,'type') => uc($lvm_data->{$vg}{'vg-format'}),
main::key($num++,0,2,'size') => $size,
},);
$size = main::get_size($lvm_data->{$vg}{'vg-free'},'string','N/A');
- $rows[$j]->{main::key($num++,0,2,'free')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'free')} = $size;
foreach my $lv (sort keys %{$lvm_data->{$vg}{'lvs'}}){
next if $extra < 2 && $lv =~ /^\[/; # it's an internal vg lv, raid meta/image
- $j = scalar @rows;
+ $j = scalar @$rows;
my $b_raid;
$size = main::get_size($lvm_data->{$vg}{'lvs'}{$lv}{'lv-size'},'string','N/A');
- $rows[$j]->{main::key($num++,1,2,'LV')} = $lv;
+ $rows->[$j]{main::key($num++,1,2,'LV')} = $lv;
if ($b_admin && $lvm_data->{$vg}{'lvs'}{$lv}{'maj-min'}){
- $rows[$j]->{main::key($num++,0,3,'maj-min')} = $lvm_data->{$vg}{'lvs'}{$lv}{'maj-min'};
+ $rows->[$j]{main::key($num++,0,3,'maj-min')} = $lvm_data->{$vg}{'lvs'}{$lv}{'maj-min'};
}
- $rows[$j]->{main::key($num++,0,3,'type')} = $lvm_data->{$vg}{'lvs'}{$lv}{'lv-type'};
+ $rows->[$j]{main::key($num++,0,3,'type')} = $lvm_data->{$vg}{'lvs'}{$lv}{'lv-type'};
if ($extra > 0 && $lvm_data->{$vg}{'lvs'}{$lv}{'dm'}){
- $rows[$j]->{main::key($num++,0,3,'dm')} = $lvm_data->{$vg}{'lvs'}{$lv}{'dm'};
+ $rows->[$j]{main::key($num++,0,3,'dm')} = $lvm_data->{$vg}{'lvs'}{$lv}{'dm'};
}
- $rows[$j]->{main::key($num++,0,3,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,3,'size')} = $size;
if ($extra > 1 && !($show{'raid'} || $show{'raid-basic'}) && $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}){
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,3,'RAID')} = '';
- $rows[$j]->{main::key($num++,0,4,'stripes')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'stripes'};
- $rows[$j]->{main::key($num++,0,4,'sync')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'sync'};
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,3,'RAID')} = '';
+ $rows->[$j]{main::key($num++,0,4,'stripes')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'stripes'};
+ $rows->[$j]{main::key($num++,0,4,'sync')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'sync'};
my $copied = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'copied'};
$copied = (defined $copied) ? ($copied + 0) . '%': 'N/A';
- $rows[$j]->{main::key($num++,0,4,'copied')} = $copied;
- $rows[$j]->{main::key($num++,0,4,'mismatches')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'mismatches'};
+ $rows->[$j]{main::key($num++,0,4,'copied')} = $copied;
+ $rows->[$j]{main::key($num++,0,4,'mismatches')} = $lvm_data->{$vg}{'lvs'}{$lv}{'raid'}{'mismatches'};
$b_raid = 1;
}
- components_output('lvm',\$j,\$num,\@rows,\@{$lvm_data->{$vg}{'lvs'}{$lv}{'components'}},\$b_raid);
+ components_output('lvm',\$j,\$num,$rows,\@{$lvm_data->{$vg}{'lvs'}{$lv}{'components'}},\$b_raid);
}
}
eval $end if $b_log;
- return @rows;
}
sub components_output {
@@ -16208,7 +16981,7 @@ sub components_output {
($l1) = (3);
}
my $status = (!@$components) ? 'N/A': '';
- $$rows[$$j]->{main::key($$num++,1,$l1,'Components')} = $status;
+ $rows->[$$j]{main::key($$num++,1,$l1,'Components')} = $status;
components_recursive_output($type,$j,$num,$rows,$components,0,'c','p');
}
sub components_recursive_output {
@@ -16234,14 +17007,14 @@ sub components_recursive_output {
$id = $p . '-' . $l;
$l++;
}
- $$rows[$$j]->{main::key($$num++,1,$l2,$id)} = $component->[0];
+ $rows->[$$j]{main::key($$num++,1,$l2,$id)} = $component->[0];
if ($extra > 1){
if ($b_admin){
$component->[1] ||= 'N/A';
- $$rows[$$j]->{main::key($$num++,0,$l3,'maj-min')} = $component->[1];
- $$rows[$$j]->{main::key($$num++,0,$l3,'mapped')} = $component->[3] if $component->[3];
+ $rows->[$$j]{main::key($$num++,0,$l3,'maj-min')} = $component->[1];
+ $rows->[$$j]{main::key($$num++,0,$l3,'mapped')} = $component->[3] if $component->[3];
$size = main::get_size($component->[2],'string','N/A');
- $$rows[$$j]->{main::key($$num++,0,$l3,'size')} = $size;
+ $rows->[$$j]{main::key($$num++,0,$l3,'size')} = $size;
}
#next if !$component->[$i][4];
for (my $i = 4; $i < scalar @$component; $i++){
@@ -16254,23 +17027,24 @@ sub components_recursive_output {
# note: type dm is seen in only one dataset, but it's a start
sub general_data {
eval $start if $b_log;
- my (@found,@general_data,%parent,$parent_fs);
+ my (@found,$parent,$parent_fs);
+ my $general_data = [];
PartitionData::set('proc') if !$loaded{'partition-data'};
main::set_mapper() if !$loaded{'mapper'};
foreach my $row (@lsblk){
# bcache doesn't have mapped name: !$mapper{$row->{'name'}} ||
next if !$row->{'parent'};
- %parent = LsblkData::get($row->{'parent'});
- next if !$parent{'fs'};
+ $parent = LsblkData::get($row->{'parent'});
+ next if !$parent->{'fs'};
if ($row->{'type'} && (($row->{'type'} eq 'crypt' ||
$row->{'type'} eq 'mpath' || $row->{'type'} eq 'multipath') ||
($row->{'type'} eq 'dm' && $row->{'name'} =~ /veracrypt/i) ||
- ($parent{'fs'} eq 'bcache'))){
+ ($parent->{'fs'} eq 'bcache'))){
my (@full_components,$mapped,$type);
$mapped = $mapper{$row->{'name'}} if %mapper;
next if grep(/^$row->{'name'}$/, @found);
push(@found,$row->{'name'});
- if ($parent{'fs'} eq 'crypto_LUKS'){
+ if ($parent->{'fs'} eq 'crypto_LUKS'){
$type = 'LUKS';
}
# note, testing name is random user string, and there is no other
@@ -16281,7 +17055,7 @@ sub general_data {
elsif ($row->{'type'} eq 'crypt'){
$type = 'Crypto';
}
- elsif ($parent{'fs'} eq 'bcache'){
+ elsif ($parent->{'fs'} eq 'bcache'){
$type = 'bcache';
}
# probably only seen on older Redhat servers, LVM probably replaces
@@ -16294,7 +17068,7 @@ sub general_data {
# my $name = ($use{'filter-uuid'}) ? "luks-$filter_string" : $row->{'name'};
component_data($row->{'maj-min'},\@full_components);
# print "$row->{'name'}\n", Data::Dumper::Dumper \@full_components;
- push(@general_data, {
+ push(@$general_data, {
'components' => \@full_components,
'dm' => $mapped,
'maj-min' => $row->{'maj-min'},
@@ -16304,10 +17078,10 @@ sub general_data {
});
}
}
- main::log_data('dump','luks @general_data', \@general_data);
- print Data::Dumper::Dumper \@general_data if $dbg[23];
+ main::log_data('dump','luks @$general_data', $general_data);
+ print Data::Dumper::Dumper $general_data if $dbg[23];
eval $end if $b_log;
- return @general_data;
+ return $general_data;
}
# note: called for disk totals, raid, and logical
@@ -16323,7 +17097,7 @@ sub lvm_data {
PartitionData::set() if !$loaded{'partition-data'};
main::set_mapper() if !$loaded{'mapper'};
if ($fake{'logical'}){
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lvm/lvs-test-1.txt";
+ # my $file = "$fake_data_dir/lvm/lvs-test-1.txt";
# @data = main::reader($file,'strip');
}
else {
@@ -16360,40 +17134,40 @@ sub lvm_data {
}
sub process_lvm_data {
eval $start if $b_log;
- my (%processed);
+ my $processed = {};
foreach my $item (@lvm){
my (@components,@devices,$dm,$dm_tmp,$dm_mm,@full_components,$maj_min,%raid,@temp);
- if (!$processed{$item->{'vg_name'}}){
- $processed{$item->{'vg_name'}}->{'vg-size'} = $item->{'vg_size'};
- $processed{$item->{'vg_name'}}->{'vg-free'} = $item->{'vg_free'};
- $processed{$item->{'vg_name'}}->{'vg-format'} = $item->{'vg_fmt'};
- }
- if (!$processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}){
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'lv-size'} = $item->{'lv_size'};
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'lv-type'} = $item->{'segtype'};
+ if (!$processed->{$item->{'vg_name'}}){
+ $processed->{$item->{'vg_name'}}->{'vg-size'} = $item->{'vg_size'};
+ $processed->{$item->{'vg_name'}}->{'vg-free'} = $item->{'vg_free'};
+ $processed->{$item->{'vg_name'}}->{'vg-format'} = $item->{'vg_fmt'};
+ }
+ if (!$processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}){
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'lv-size'} = $item->{'lv_size'};
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'lv-type'} = $item->{'segtype'};
$maj_min = $item->{'lv_kernel_major'} . ':' . $item->{'lv_kernel_minor'};
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'maj-min'} = $maj_min;
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'maj-min'} = $maj_min;
$dm_tmp = $item->{'vg_name'} . '-' . $item->{'lv_name'};
$dm_tmp =~ s/\[|\]$//g;
$dm = $mapper{$dm_tmp} if %mapper;
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'dm'} = $dm;
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'dm'} = $dm;
if ($item->{'segtype'} && $item->{'segtype'} ne 'linear' && $item->{'segtype'} =~ /^raid/){
$raid{'copied'} = $item->{'copy_percent'};
$raid{'mismatches'} = $item->{'raid_mismatch_count'};
$raid{'stripes'} = $item->{'stripes'};
$raid{'sync'} = $item->{'raid_sync_action'};
$raid{'type'} = $item->{'segtype'};
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'raid'} = \%raid;
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'raid'} = \%raid;
}
component_data($maj_min,\@full_components);
# print "$item->{'lv_name'}\n", Data::Dumper::Dumper \@full_components;
- $processed{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'components'} = \@full_components;
+ $processed->{$item->{'vg_name'}}->{'lvs'}{$item->{'lv_name'}}{'components'} = \@full_components;
}
}
- main::log_data('dump','lvm %processed', \%processed) if $b_log;
- print Data::Dumper::Dumper \%processed if $dbg[23];
+ main::log_data('dump','lvm %$processed', $processed) if $b_log;
+ print Data::Dumper::Dumper $processed if $dbg[23];
eval $end if $b_log;
- return %processed;
+ return $processed;
}
sub component_data {
my ($maj_min,$full_components) = @_;
@@ -16407,16 +17181,16 @@ sub component_recursive_data {
@devices = map {$_ =~ s|^/.*/||; $_;} @devices if @devices;
# return @devices if !$b_admin;
foreach my $device (@devices){
- my ($mapped,$mm2,@part);
- @part = PartitionData::get($device) if @proc_partitions;
- $mm2 = $part[0] . ':' . $part[1] if @part;
+ my ($mapped,$mm2,$part);
+ $part = PartitionData::get($device) if @proc_partitions;
+ $mm2 = $part->[0] . ':' . $part->[1] if @$part;
if ($device =~ /^(bcache|dm-|md)[0-9]+$/){
$mapped = $dmmapper{$device};
- $raw_logical[1] += $part[2] if $mapped && $mapped =~ /_(cdata|cmeta)$/;
- push(@components, [$device,$mm2,$part[2],$mapped,[component_recursive_data($mm2)]]);
+ $raw_logical[1] += $part->[2] if $mapped && $mapped =~ /_(cdata|cmeta)$/;
+ push(@components, [$device,$mm2,$part->[2],$mapped,[component_recursive_data($mm2)]]);
}
else {
- push(@components,[$device,$mm2,$part[2]]);
+ push(@components,[$device,$mm2,$part->[2]]);
}
}
eval $end if $b_log;
@@ -16430,12 +17204,13 @@ package MachineItem;
sub get {
eval $start if $b_log;
- my (%soc_machine,%data,@rows,$key1,$val1,$which);
+ my (%soc_machine,$data,@rows,$key1,$val1,$which);
+ my $rows = [];
my $num = 0;
if ($bsd_type && $sysctl{'machine'} && !$force{'dmidecode'}){
- %data = machine_data_sysctl();
- if (%data){
- @rows = machine_output(\%data);
+ $data = machine_data_sysctl();
+ if (%$data){
+ machine_output($rows,$data);
}
elsif (!$key1){
$key1 = 'Message';
@@ -16449,9 +17224,9 @@ sub get {
$key1 = ucfirst($key1);
}
else {
- %data = machine_data_dmi();
- if (%data){
- @rows = machine_output(\%data);
+ $data = machine_data_dmi();
+ if (%$data){
+ machine_output($rows,$data);
}
elsif (!$key1){
$key1 = 'Message';
@@ -16460,9 +17235,9 @@ sub get {
}
}
elsif (-d '/sys/class/dmi/id/'){
- %data = machine_data_sys();
- if (%data){
- @rows = machine_output(\%data);
+ $data = machine_data_sys();
+ if (%$data){
+ machine_output($rows,$data);
}
else {
$key1 = 'Message';
@@ -16476,33 +17251,33 @@ sub get {
}
elsif ($fake{'elbrus'} || $cpu_arch eq 'elbrus'){
if ($fake{'elbrus'} || (my $program = main::check_program('fruid_print'))){
- %data = machine_data_fruid($program);
- }
- if (%data){
- @rows = machine_output(\%data);
- }
- elsif (!$key1){
- $key1 = 'Message';
- $val1 = main::message('machine-data-fruid');
+ $data = machine_data_fruid($program);
+ if (%$data){
+ machine_output($rows,$data);
+ }
+ elsif (!$key1){
+ $key1 = 'Message';
+ $val1 = main::message('machine-data-fruid');
+ }
}
}
elsif (!$bsd_type){
# this uses /proc/cpuinfo so only GNU/Linux
if (%risc){
- %data = machine_data_soc();
- @rows = machine_soc_output(\%data) if %data;
+ $data = machine_data_soc();
+ machine_soc_output($rows,$data) if %$data;
}
- if (!%data){
+ if (!$data || !%$data){
$key1 = 'Message';
$val1 = main::message('machine-data-force-dmidecode','');
}
}
# if error case, null data, whatever
if ($key1){
- push(@rows,{main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1,});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
## keys for machine data are:
# 0-sys_vendor 1-product_name 2-product_version 3-product_serial 4-product_uuid
@@ -16513,8 +17288,7 @@ sub get {
## unused: 16-bios_rev 17-bios_romsize 18 - firmware type
sub machine_output {
eval $start if $b_log;
- my ($data) = @_;
- my (@rows);
+ my ($rows,$data) = @_;
my $firmware = 'BIOS';
my $num = 0;
my $j = 0;
@@ -16548,8 +17322,8 @@ sub machine_output {
}
}
$data->{'device'} ||= 'N/A';
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,0,1,'Type') => ucfirst($data->{'device'}),
},);
if (!$b_skip_system){
@@ -16558,10 +17332,10 @@ sub machine_output {
$product_name = ($data->{'product_name'}) ? $data->{'product_name'}:'N/A';
$product_version = ($data->{'product_version'}) ? $data->{'product_version'}:'N/A';
$product_serial = main::filter($data->{'product_serial'});
- $rows[$j]->{main::key($num++,1,1,'System')} = $system_vendor;
- $rows[$j]->{main::key($num++,1,2,'product')} = $product_name;
- $rows[$j]->{main::key($num++,0,3,'v')} = $product_version;
- $rows[$j]->{main::key($num++,0,3,'serial')} = $product_serial;
+ $rows->[$j]{main::key($num++,1,1,'System')} = $system_vendor;
+ $rows->[$j]{main::key($num++,1,2,'product')} = $product_name;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $product_version;
+ $rows->[$j]{main::key($num++,0,3,'serial')} = $product_serial;
# no point in showing chassis if system isn't there, it's very unlikely that
# would be correct
if ($extra > 1){
@@ -16584,14 +17358,14 @@ sub machine_output {
$chassis_serial = main::filter($data->{'chassis_serial'});
$chassis_vendor ||= '';
$chassis_type ||= '';
- $rows[$j]->{main::key($num++,1,1,'Chassis')} = $chassis_vendor;
+ $rows->[$j]{main::key($num++,1,1,'Chassis')} = $chassis_vendor;
if ($chassis_type){
- $rows[$j]->{main::key($num++,0,2,'type')} = $chassis_type;
+ $rows->[$j]{main::key($num++,0,2,'type')} = $chassis_type;
}
if ($chassis_version){
- $rows[$j]->{main::key($num++,0,2,'v')} = $chassis_version;
+ $rows->[$j]{main::key($num++,0,2,'v')} = $chassis_version;
}
- $rows[$j]->{main::key($num++,0,2,'serial')} = $chassis_serial;
+ $rows->[$j]{main::key($num++,0,2,'serial')} = $chassis_serial;
}
}
$j++; # start new row
@@ -16619,78 +17393,77 @@ sub machine_output {
if ($extra > 1 && $data->{'bios_romsize'}){
$bios_romsize = $data->{'bios_romsize'};
}
- $rows[$j]->{main::key($num++,1,1,'Mobo')} = $mobo_vendor;
- $rows[$j]->{main::key($num++,1,2,'model')} = $mobo_model;
+ $rows->[$j]{main::key($num++,1,1,'Mobo')} = $mobo_vendor;
+ $rows->[$j]{main::key($num++,1,2,'model')} = $mobo_model;
if ($mobo_version){
- $rows[$j]->{main::key($num++,0,3,'v')} = $mobo_version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $mobo_version;
}
- $rows[$j]->{main::key($num++,0,3,'serial')} = $mobo_serial;
+ $rows->[$j]{main::key($num++,0,3,'serial')} = $mobo_serial;
if ($extra > 2 && $data->{'board_uuid'}){
- $rows[$j]->{main::key($num++,0,3,'uuid')} = $data->{'board_uuid'};
+ $rows->[$j]{main::key($num++,0,3,'uuid')} = $data->{'board_uuid'};
}
if ($extra > 1 && $data->{'board_mfg_date'}){
- $rows[$j]->{main::key($num++,0,3,'mfg-date')} = $data->{'board_mfg_date'};
+ $rows->[$j]{main::key($num++,0,3,'mfg-date')} = $data->{'board_mfg_date'};
}
- $rows[$j]->{main::key($num++,1,1,$firmware)} = $bios_vendor;
- $rows[$j]->{main::key($num++,0,2,'v')} = $bios_version;
+ $rows->[$j]{main::key($num++,1,1,$firmware)} = $bios_vendor;
+ $rows->[$j]{main::key($num++,0,2,'v')} = $bios_version;
if ($bios_rev){
- $rows[$j]->{main::key($num++,0,2,'rev')} = $bios_rev;
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $bios_rev;
}
- $rows[$j]->{main::key($num++,0,2,'date')} = $bios_date;
+ $rows->[$j]{main::key($num++,0,2,'date')} = $bios_date;
if ($bios_romsize){
- $rows[$j]->{main::key($num++,0,2,'rom size')} = $bios_romsize;
+ $rows->[$j]{main::key($num++,0,2,'rom size')} = $bios_romsize;
}
eval $end if $b_log;
- return @rows;
}
sub machine_soc_output {
- my ($soc_machine) = @_;
- my ($key,@rows);
+ my ($rows,$soc_machine) = @_;
+ my ($key);
my ($cont_sys,$ind_sys,$j,$num) = (1,1,0,0);
# print Data::Dumper::Dumper \%soc_machine;
# this is sketchy, /proc/device-tree/model may be similar to Hardware value from /proc/cpuinfo
# raspi: Hardware : BCM2835 model: Raspberry Pi Model B Rev 2
if ($soc_machine->{'device'} || $soc_machine->{'model'}){
- $rows[$j]->{main::key($num++,0,1,'Type')} = uc($risc{'id'});
+ $rows->[$j]{main::key($num++,0,1,'Type')} = uc($risc{'id'});
my $system = 'System';
if (defined $soc_machine->{'model'}){
- $rows[$j]->{main::key($num++,1,1,'System')} = $soc_machine->{'model'};
+ $rows->[$j]{main::key($num++,1,1,'System')} = $soc_machine->{'model'};
$system = 'details';
($cont_sys,$ind_sys) = (0,2);
}
$soc_machine->{'device'} ||= 'N/A';
- $rows[$j]->{main::key($num++,$cont_sys,$ind_sys,$system)} = $soc_machine->{'device'};
+ $rows->[$j]{main::key($num++,$cont_sys,$ind_sys,$system)} = $soc_machine->{'device'};
}
if ($soc_machine->{'mobo'}){
- $rows[$j]->{main::key($num++,1,1,'mobo')} = $soc_machine->{'mobo'};
+ $rows->[$j]{main::key($num++,1,1,'mobo')} = $soc_machine->{'mobo'};
}
# we're going to print N/A for 0000 values sine the item was there.
if ($soc_machine->{'firmware'}){
# most samples I've seen are like: 0000
$soc_machine->{'firmware'} =~ s/^[0]+$//;
$soc_machine->{'firmware'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'rev')} = $soc_machine->{'firmware'};
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $soc_machine->{'firmware'};
}
# sometimes has value like: 0000
if (defined $soc_machine->{'serial'}){
# most samples I've seen are like: 0000
$soc_machine->{'serial'} =~ s/^[0]+$//;
- $rows[$j]->{main::key($num++,0,2,'serial')} = main::filter($soc_machine->{'serial'});
+ $rows->[$j]{main::key($num++,0,2,'serial')} = main::filter($soc_machine->{'serial'});
}
eval $end if $b_log;
- return @rows;
}
sub machine_data_fruid {
eval $start if $b_log;
my ($program) = @_;
- my ($b_start,%data,@fruid);
+ my ($b_start,@fruid);
+ my $data = {};
if (!$fake{'elbrus'}){
@fruid = main::grabber("$program 2>/dev/null",'','strip');
}
else {
# my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/fruid/fruid-e904-1_full.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/fruid/fruid-e804-1_full.txt";
+ # $file = "$fake_data_dir/fruid/fruid-e904-1_full.txt";
+ # $file = "$fake_data_dir/fruid/fruid-e804-1_full.txt";
# @fruid = main::reader($file,'strip');
}
# print Data::Dumper::Dumper \@fruid;
@@ -16699,32 +17472,33 @@ sub machine_data_fruid {
next if !$b_start;
my @split = split(/\s*:\s+/,$_,2);
if ($split[0] eq 'Mfg. Date/Time'){
- $data{'board_mfg_date'} = $split[1];
- $data{'board_mfg_date'} =~ s/^(\d+:\d+)\s//;
+ $data->{'board_mfg_date'} = $split[1];
+ $data->{'board_mfg_date'} =~ s/^(\d+:\d+)\s//;
}
elsif ($split[0] eq 'Board manufacturer'){
- $data{'board_vendor'} = $split[1];
+ $data->{'board_vendor'} = $split[1];
}
elsif ($split[0] eq 'Board part number'){
- $data{'board_part_nu'} = $split[1];
+ $data->{'board_part_nu'} = $split[1];
}
elsif ($split[0] eq 'Board product name'){
- $data{'board_name'} = $split[1];
+ $data->{'board_name'} = $split[1];
}
elsif ($split[0] eq 'Board serial number'){
- $data{'board_serial'} = $split[1];
+ $data->{'board_serial'} = $split[1];
}
elsif ($split[0] eq 'Board product version'){
- $data{'board_version'} = $split[1];
+ $data->{'board_version'} = $split[1];
}
}
- print Data::Dumper::Dumper \%data if $dbg[28];
- main::log_data('dump','%data',\%data) if $b_log;
- return %data;
+ print Data::Dumper::Dumper $data if $dbg[28];
+ main::log_data('dump','%data',$data) if $b_log;
+ return $data;
}
sub machine_data_sys {
eval $start if $b_log;
- my (%data,$path,$vm);
+ my ($path,$vm);
+ my $data = {};
my $sys_dir = '/sys/class/dmi/id/';
my $sys_dir_alt = '/sys/devices/virtual/dmi/id/';
my @sys_files = qw(bios_vendor bios_version bios_date
@@ -16734,7 +17508,7 @@ sub machine_data_sys {
if ($extra > 1){
splice(@sys_files, 0, 0, qw(chassis_serial chassis_vendor chassis_version));
}
- $data{'firmware'} = 'BIOS';
+ $data->{'firmware'} = 'BIOS';
# print Data::Dumper::Dumper \@sys_files;
if (!-d $sys_dir){
if (-d $sys_dir_alt){
@@ -16745,41 +17519,41 @@ sub machine_data_sys {
}
}
if (-d '/sys/firmware/efi'){
- $data{'firmware'} = 'UEFI';
+ $data->{'firmware'} = 'UEFI';
}
elsif (glob('/sys/firmware/acpi/tables/UEFI*')){
- $data{'firmware'} = 'UEFI-[Legacy]';
+ $data->{'firmware'} = 'UEFI-[Legacy]';
}
foreach (@sys_files){
$path = "$sys_dir$_";
if (-r $path){
- $data{$_} = main::reader($path,'',0);
- $data{$_} = ($data{$_}) ? main::clean_dmi($data{$_}) : '';
+ $data->{$_} = main::reader($path,'',0);
+ $data->{$_} = ($data->{$_}) ? main::clean_dmi($data->{$_}) : '';
}
elsif (!$b_root && -e $path && !-r $path){
- $data{$_} = main::message('root-required');
+ $data->{$_} = main::message('root-required');
}
else {
- $data{$_} = '';
+ $data->{$_} = '';
}
}
- if ($data{'chassis_type'}){
- if ($data{'chassis_type'} == 1){
- $data{'device'} = get_device_vm($data{'sys_vendor'},$data{'product_name'});
- $data{'device'} ||= 'other-vm?';
+ if ($data->{'chassis_type'}){
+ if ($data->{'chassis_type'} == 1){
+ $data->{'device'} = get_device_vm($data->{'sys_vendor'},$data->{'product_name'});
+ $data->{'device'} ||= 'other-vm?';
}
else {
- $data{'device'} = get_device_sys($data{'chassis_type'});
+ $data->{'device'} = get_device_sys($data->{'chassis_type'});
}
}
# print "sys:\n";
# foreach (keys %data){
- # print "$_: $data{$_}\n";
+ # print "$_: $data->{$_}\n";
# }
- print Data::Dumper::Dumper \%data if $dbg[28];
- main::log_data('dump','%data',\%data) if $b_log;
+ print Data::Dumper::Dumper $data if $dbg[28];
+ main::log_data('dump','%data',$data) if $b_log;
eval $end if $b_log;
- return %data;
+ return $data;
}
# this will create an alternate machine data source
# which will be used for alt ARM machine data in cases
@@ -16787,36 +17561,36 @@ sub machine_data_sys {
# certain actions for arm only.
sub machine_data_soc {
eval $end if $b_log;
- my (%data);
+ my $data = {};
if (my $file = $system_files{'proc-cpuinfo'}){
CpuItem::cpuinfo_data_grabber($file) if !$loaded{'cpuinfo'};
# grabber sets keys to lower case to avoid error here
if ($cpuinfo_machine{'hardware'} || $cpuinfo_machine{'machine'}){
- $data{'device'} = main::get_defined($cpuinfo_machine{'hardware'},
+ $data->{'device'} = main::get_defined($cpuinfo_machine{'hardware'},
$cpuinfo_machine{'machine'});
- $data{'device'} = main::clean_arm($data{'device'});
- $data{'device'} = main::clean_dmi($data{'device'});
- $data{'device'} = main::clean($data{'device'});
+ $data->{'device'} = main::clean_arm($data->{'device'});
+ $data->{'device'} = main::clean_dmi($data->{'device'});
+ $data->{'device'} = main::clean($data->{'device'});
}
if (defined $cpuinfo_machine{'system type'} || $cpuinfo_machine{'model'}){
- $data{'model'} = main::get_defined($cpuinfo_machine{'system type'},
+ $data->{'model'} = main::get_defined($cpuinfo_machine{'system type'},
$cpuinfo_machine{'model'});
- $data{'model'} = main::clean_dmi($data{'model'});
- $data{'model'} = main::clean($data{'model'});
+ $data->{'model'} = main::clean_dmi($data->{'model'});
+ $data->{'model'} = main::clean($data->{'model'});
}
# seen with PowerMac PPC
if (defined $cpuinfo_machine{'motherboard'}){
- $data{'mobo'} = $cpuinfo_machine{'motherboard'};
+ $data->{'mobo'} = $cpuinfo_machine{'motherboard'};
}
if (defined $cpuinfo_machine{'revision'}){
- $data{'firmware'} = $cpuinfo_machine{'revision'};
+ $data->{'firmware'} = $cpuinfo_machine{'revision'};
}
if (defined $cpuinfo_machine{'serial'}){
- $data{'serial'} = $cpuinfo_machine{'serial'};
+ $data->{'serial'} = $cpuinfo_machine{'serial'};
}
undef %cpuinfo_machine; # we're done with it, don't need it anymore
}
- if (!$data{'model'} && $b_android){
+ if (!$data->{'model'} && $b_android){
main::set_build_prop() if !$loaded{'build-prop'};
if ($build_prop{'product-manufacturer'} && $build_prop{'product-model'}){
my $brand = '';
@@ -16824,38 +17598,38 @@ sub machine_data_soc {
$build_prop{'product-brand'} ne $build_prop{'product-manufacturer'}){
$brand = $build_prop{'product-brand'} . ' ';
}
- $data{'model'} = $brand . $build_prop{'product-manufacturer'} . ' ' . $build_prop{'product-model'};
+ $data->{'model'} = $brand . $build_prop{'product-manufacturer'} . ' ' . $build_prop{'product-model'};
}
elsif ($build_prop{'product-device'}){
- $data{'model'} = $build_prop{'product-device'};
+ $data->{'model'} = $build_prop{'product-device'};
}
elsif ($build_prop{'product-name'}){
- $data{'model'} = $build_prop{'product-name'};
+ $data->{'model'} = $build_prop{'product-name'};
}
}
- if (!$data{'model'} && -r '/proc/device-tree/model'){
+ if (!$data->{'model'} && -r '/proc/device-tree/model'){
my $model = main::reader('/proc/device-tree/model','',0);
main::log_data('data',"device-tree-model: $model") if $b_log;
if ($model){
$model = main::clean_dmi($model);
$model = (split(/\x01|\x02|\x03|\x00/, $model))[0] if $model;
- my $device_temp = main::clean_regex($data{'device'});
- if (!$data{'device'} || ($model && $model !~ /\Q$device_temp\E/i)){
+ my $device_temp = main::clean_regex($data->{'device'});
+ if (!$data->{'device'} || ($model && $model !~ /\Q$device_temp\E/i)){
$model = main::clean_arm($model);
- $data{'model'} = $model;
+ $data->{'model'} = $model;
}
}
}
- if (!$data{'serial'} && -f '/proc/device-tree/serial-number'){
+ if (!$data->{'serial'} && -f '/proc/device-tree/serial-number'){
my $serial = main::reader('/proc/device-tree/serial-number','',0);
$serial = (split(/\x01|\x02|\x03|\x00/, $serial))[0] if $serial;
main::log_data('data',"device-tree-serial: $serial") if $b_log;
- $data{'serial'} = $serial if $serial;
+ $data->{'serial'} = $serial if $serial;
}
- print Data::Dumper::Dumper \%data if $dbg[28];
- main::log_data('dump','%data',\%data) if $b_log;
+ print Data::Dumper::Dumper $data if $dbg[28];
+ main::log_data('dump','%data',$data) if $b_log;
eval $end if $b_log;
- return %data;
+ return $data;
}
# bios_date: 09/07/2010
@@ -16880,9 +17654,10 @@ sub machine_data_soc {
# sys_vendor:
sub machine_data_dmi {
eval $start if $b_log;
- my (%data,$vm);
- return if ! @dmi;
- $data{'firmware'} = 'BIOS';
+ return if !@dmi;
+ my ($vm);
+ my $data = {};
+ $data->{'firmware'} = 'BIOS';
# dmi types:
# 0 bios; 1 system info; 2 board|base board info; 3 chassis info;
# 4 processor info, use to check for hypervisor
@@ -16894,19 +17669,19 @@ sub machine_data_dmi {
if ($item !~ /^~/){ # skip the indented rows
my @value = split(/:\s+/, $item);
if ($value[0] eq 'Release Date'){
- $data{'bios_date'} = main::clean_dmi($value[1]) }
+ $data->{'bios_date'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Vendor'){
- $data{'bios_vendor'} = main::clean_dmi($value[1]) }
+ $data->{'bios_vendor'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Version'){
- $data{'bios_version'} = main::clean_dmi($value[1]) }
+ $data->{'bios_version'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'ROM Size'){
- $data{'bios_romsize'} = main::clean_dmi($value[1]) }
+ $data->{'bios_romsize'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'BIOS Revision'){
- $data{'bios_rev'} = main::clean_dmi($value[1]) }
+ $data->{'bios_rev'} = main::clean_dmi($value[1]) }
}
else {
if ($item eq '~UEFI is supported'){
- $data{'firmware'} = 'UEFI';}
+ $data->{'firmware'} = 'UEFI';}
}
}
next;
@@ -16918,15 +17693,15 @@ sub machine_data_dmi {
if ($item !~ /^~/){ # skip the indented rows
my @value = split(/:\s+/, $item);
if ($value[0] eq 'Product Name'){
- $data{'product_name'} = main::clean_dmi($value[1]) }
+ $data->{'product_name'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Version'){
- $data{'product_version'} = main::clean_dmi($value[1]) }
+ $data->{'product_version'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Serial Number'){
- $data{'product_serial'} = main::clean_dmi($value[1]) }
+ $data->{'product_serial'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Manufacturer'){
- $data{'sys_vendor'} = main::clean_dmi($value[1]) }
+ $data->{'sys_vendor'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'UUID'){
- $data{'sys_uuid'} = main::clean_dmi($value[1]) }
+ $data->{'sys_uuid'} = main::clean_dmi($value[1]) }
}
}
next;
@@ -16938,13 +17713,13 @@ sub machine_data_dmi {
if ($item !~ /^~/){ # skip the indented rows
my @value = split(/:\s+/, $item);
if ($value[0] eq 'Product Name'){
- $data{'board_name'} = main::clean_dmi($value[1]) }
+ $data->{'board_name'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Serial Number'){
- $data{'board_serial'} = main::clean_dmi($value[1]) }
+ $data->{'board_serial'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Manufacturer'){
- $data{'board_vendor'} = main::clean_dmi($value[1]) }
+ $data->{'board_vendor'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Version'){
- $data{'board_version'} = main::clean_dmi($value[1]) }
+ $data->{'board_version'} = main::clean_dmi($value[1]) }
}
}
next;
@@ -16956,17 +17731,17 @@ sub machine_data_dmi {
if ($item !~ /^~/){ # skip the indented rows
my @value = split(/:\s+/, $item);
if ($value[0] eq 'Serial Number'){
- $data{'chassis_serial'} = main::clean_dmi($value[1]) }
+ $data->{'chassis_serial'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Type'){
- $data{'chassis_type'} = main::clean_dmi($value[1]) }
+ $data->{'chassis_type'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Manufacturer'){
- $data{'chassis_vendor'} = main::clean_dmi($value[1]) }
+ $data->{'chassis_vendor'} = main::clean_dmi($value[1]) }
elsif ($value[0] eq 'Version'){
- $data{'chassis_version'} = main::clean_dmi($value[1]) }
+ $data->{'chassis_version'} = main::clean_dmi($value[1]) }
}
}
- if ($data{'chassis_type'} && $data{'chassis_type'} ne 'Other'){
- $data{'device'} = $data{'chassis_type'};
+ if ($data->{'chassis_type'} && $data->{'chassis_type'} ne 'Other'){
+ $data->{'device'} = $data->{'chassis_type'};
}
next;
}
@@ -16974,9 +17749,9 @@ sub machine_data_dmi {
# processor information: check for hypervisor
elsif ($row->[0] == 4){
# skip first three row, we don't need that data
- if (!$data{'device'}){
+ if (!$data->{'device'}){
if (grep {/hypervisor/i} @$row){
- $data{'device'} = 'virtual-machine';
+ $data->{'device'} = 'virtual-machine';
}
}
last;
@@ -16985,98 +17760,99 @@ sub machine_data_dmi {
last;
}
}
- if (!$data{'device'}){
- $data{'device'} = get_device_vm($data{'sys_vendor'},$data{'product_name'});
- $data{'device'} ||= 'other-vm?';
+ if (!$data->{'device'}){
+ $data->{'device'} = get_device_vm($data->{'sys_vendor'},$data->{'product_name'});
+ $data->{'device'} ||= 'other-vm?';
}
# print "dmi:\n";
# foreach (keys %data){
-# print "$_: $data{$_}\n";
+# print "$_: $data->{$_}\n";
# }
- print Data::Dumper::Dumper \%data if $dbg[28];
- main::log_data('dump','%data',\%data) if $b_log;
+ print Data::Dumper::Dumper $data if $dbg[28];
+ main::log_data('dump','%data',$data) if $b_log;
eval $end if $b_log;
- return %data;
+ return $data;
}
# As far as I know, only OpenBSD supports this method.
# it uses hw. info from sysctl -a and bios info from dmesg.boot
sub machine_data_sysctl {
eval $start if $b_log;
- my (%data,$product,$vendor,$vm);
+ my ($product,$vendor,$vm);
+ my $data = {};
# ^hw\.(vendor|product|version|serialno|uuid)
foreach (@{$sysctl{'machine'}}){
next if !$_;
my @item = split(':', $_);
next if !$item[1];
if ($item[0] eq 'hw.vendor' || $item[0] eq 'machdep.dmi.board-vendor'){
- $data{'board_vendor'} = main::clean_dmi($item[1]);
+ $data->{'board_vendor'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'hw.product' || $item[0] eq 'machdep.dmi.board-product'){
- $data{'board_name'} = main::clean_dmi($item[1]);
+ $data->{'board_name'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'hw.version' || $item[0] eq 'machdep.dmi.board-version'){
- $data{'board_version'} = main::clean_dmi($item[1]);
+ $data->{'board_version'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'hw.serialno' || $item[0] eq 'machdep.dmi.board-serial'){
- $data{'board_serial'} = main::clean_dmi($item[1]);
+ $data->{'board_serial'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'hw.serial'){
- $data{'board_serial'} = main::clean_dmi($item[1]);
+ $data->{'board_serial'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'hw.uuid'){
- $data{'board_uuid'} = main::clean_dmi($item[1]);
+ $data->{'board_uuid'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.system-vendor'){
- $data{'sys_vendor'} = main::clean_dmi($item[1]);
+ $data->{'sys_vendor'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.system-product'){
- $data{'product_name'} = main::clean_dmi($item[1]);
+ $data->{'product_name'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.system-version'){
- $data{'product_version'} = main::clean_dmi($item[1]);
+ $data->{'product_version'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.system-serial'){
- $data{'product_serial'} = main::clean_dmi($item[1]);
+ $data->{'product_serial'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.system-uuid'){
- $data{'sys_uuid'} = main::clean_dmi($item[1]);
+ $data->{'sys_uuid'} = main::clean_dmi($item[1]);
}
# bios0:at mainbus0: AT/286+ BIOS, date 06/30/06, BIOS32 rev. 0 @ 0xf2030, SMBIOS rev. 2.4 @ 0xf0000 (47 entries)
# bios0:vendor Phoenix Technologies, LTD version "3.00" date 06/30/2006
elsif ($item[0] =~ /^bios[0-9]/){
if ($_ =~ /^^bios[0-9]:at\s.*?\srev\.\s([\S]+)\s@.*/){
- $data{'bios_rev'} = $1;
- $data{'firmware'} = 'BIOS' if $_ =~ /BIOS/;
+ $data->{'bios_rev'} = $1;
+ $data->{'firmware'} = 'BIOS' if $_ =~ /BIOS/;
}
elsif ($item[1] =~ /^vendor\s(.*?)\sversion\s(.*?)\sdate\s([\S]+)/){
- $data{'bios_vendor'} = $1;
- $data{'bios_version'} = $2;
- $data{'bios_date'} = $3;
- $data{'bios_version'} =~ s/^v//i if $data{'bios_version'} && $data{'bios_version'} !~ /vi/i;
+ $data->{'bios_vendor'} = $1;
+ $data->{'bios_version'} = $2;
+ $data->{'bios_date'} = $3;
+ $data->{'bios_version'} =~ s/^v//i if $data->{'bios_version'} && $data->{'bios_version'} !~ /vi/i;
}
}
elsif ($item[0] eq 'machdep.dmi.bios-vendor'){
- $data{'bios_vendor'} = main::clean_dmi($item[1]);
+ $data->{'bios_vendor'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.bios-version'){
- $data{'bios_version'} = main::clean_dmi($item[1]);
+ $data->{'bios_version'} = main::clean_dmi($item[1]);
}
elsif ($item[0] eq 'machdep.dmi.bios-date'){
- $data{'bios_date'} = main::clean_dmi($item[1]);
+ $data->{'bios_date'} = main::clean_dmi($item[1]);
}
}
- if ($data{'board_vendor'} || $data{'sys_vendor'} || $data{'board_name'} || $data{'product_name'}){
- $vendor = $data{'sys_vendor'};
- $vendor = $data{'board_vendor'} if !$vendor;
- $product = $data{'product_name'};
- $product = $data{'board_name'} if !$product;
+ if ($data->{'board_vendor'} || $data->{'sys_vendor'} || $data->{'board_name'} || $data->{'product_name'}){
+ $vendor = $data->{'sys_vendor'};
+ $vendor = $data->{'board_vendor'} if !$vendor;
+ $product = $data->{'product_name'};
+ $product = $data->{'board_name'} if !$product;
}
# detections can be from other sources.
- $data{'device'} = get_device_vm($vendor,$product);
- print Data::Dumper::Dumper \%data if $dbg[28];
- main::log_data('dump','%data',\%data) if $b_log;
+ $data->{'device'} = get_device_vm($vendor,$product);
+ print Data::Dumper::Dumper $data if $dbg[28];
+ main::log_data('dump','%data',$data) if $b_log;
eval $end if $b_log;
- return %data;
+ return $data;
}
sub get_device_sys {
@@ -17229,23 +18005,22 @@ package NetworkItem;
my ($b_ip_run,@ifs_found);
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
if (%risc && !$use{'soc-network'} && !$use{'pci-tool'}){
# do nothing, but keep the test conditions to force
# the non arm case to always run
}
else {
- push(@rows,device_output());
+ device_output($rows);
}
- push(@rows,usb_output());
# note: raspberry pi uses usb networking only
- if (!@rows){
+ if (!@$rows){
if (%risc){
my $key = 'Message';
- push(@rows, {
- main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'}),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message('risc-pci',$risc{'id'})
+ });
}
else {
my $key = 'Message';
@@ -17253,39 +18028,41 @@ sub get {
if ($pci_tool && $alerts{$pci_tool}->{'action'} eq 'permissions'){
$type = 'pci-card-data-root';
}
- push(@rows,{
- main::key($num++,0,1,$key) => main::message($type,''),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message($type,'')
+ });
}
}
+ usb_output($rows);
if ($show{'network-advanced'}){
# @ifs_found = ();
# shift @ifs_found;
# pop @ifs_found;
if (!$bsd_type){
- push(@rows,advanced_data_sys('check','',0,'','',''));
+ advanced_data_sys($rows,'check','',0,'','','');
}
else {
- push(@rows,advanced_data_bsd('check'));
+ advanced_data_bsd($rows,'check');
}
}
if ($show{'ip'}){
- push(@rows,wan_ip());
+ wan_ip($rows);
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub device_output {
eval $start if $b_log;
return if !$devices{'network'};
- my ($b_wifi,@rows,%holder);
+ my $rows = $_[0];
+ my ($b_wifi,%holder);
my ($j,$num) = (0,1);
foreach my $row (@{$devices{'network'}}){
$num = 1;
# print "$row->[0] $row->[3]\n";
# print "$row->[0] $row->[3]\n";
- $j = scalar @rows;
+ $j = scalar @$rows;
my $driver = $row->[9];
my $chip_id = main::get_chip_id($row->[5],$row->[6]);
# working around a virtuo bug same chip id is used on two nics
@@ -17301,17 +18078,17 @@ sub device_output {
$device = ($device) ? main::clean_pci($device,'output') : 'N/A';
#$device ||= 'N/A';
$driver ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $device,
},);
if ($extra > 0 && $use{'pci-tool'} && $row->[12]){
my $item = main::get_pci_vendor($row->[4],$row->[12]);
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $item if $item;
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $item if $item;
}
if ($row->[1] eq '0680'){
- $rows[$j]->{main::key($num++,0,2,'type')} = 'network bridge';
+ $rows->[$j]{main::key($num++,0,2,'type')} = 'network bridge';
}
- $rows[$j]->{main::key($num++,1,2,'driver')} = $driver;
+ $rows->[$j]{main::key($num++,1,2,'driver')} = $driver;
my $bus_id = 'N/A';
# note: for arm/mips we want to see the single item bus id, why not?
# note: we can have bus id: 0002 / 0 which is valid, but 0 / 0 is invalid
@@ -17322,57 +18099,58 @@ sub device_output {
if ($row->[9] && !$bsd_type){
my $version = main::get_module_version($row->[9]);
$version ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'v')} = $version;
+ $rows->[$j]{main::key($num++,0,3,'v')} = $version;
}
if ($b_admin && $row->[10]){
$row->[10] = main::get_driver_modules($row->[9],$row->[10]);
- $rows[$j]->{main::key($num++,0,3,'modules')} = $row->[10] if $row->[10];
+ $rows->[$j]{main::key($num++,0,3,'modules')} = $row->[10] if $row->[10];
}
$row->[8] ||= 'N/A';
if ($extra > 1 && $bus_id ne 'N/A'){
- main::get_pcie_data($bus_id,$j,\@rows,\$num);
+ main::get_pcie_data($bus_id,$j,$rows,\$num);
}
# as far as I know, wifi has no port, but in case it does in future, use it
- $rows[$j]->{main::key($num++,0,2,'port')} = $row->[8] if (!$b_wifi || ($b_wifi && $row->[8] ne 'N/A'));
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'port')} = $row->[8] if (!$b_wifi || ($b_wifi && $row->[8] ne 'N/A'));
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $chip_id;
}
if ($extra > 2 && $row->[1]){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = $row->[1];
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = $row->[1];
}
if ($show{'network-advanced'}){
my @data;
if (!$bsd_type){
- @data = advanced_data_sys($row->[5],$row->[6],$holder{$chip_id},$b_wifi,'',$bus_id);
+ advanced_data_sys($rows,$row->[5],$row->[6],$holder{$chip_id},$b_wifi,'',$bus_id);
}
else {
- @data = advanced_data_bsd("$row->[9]$row->[11]",$b_wifi) if defined $row->[9] && defined $row->[11];
+ if (defined $row->[9] && defined $row->[11]){
+ advanced_data_bsd($rows,"$row->[9]$row->[11]",$b_wifi);
+ }
}
- push(@rows,@data) if @data;
}
# print "$row->[0]\n";
}
# @rows = ();
# we want to handle ARM errors in main get
- if (!@rows && !%risc){
+ if (!@$rows && !%risc){
my $key = 'Message';
my $type = 'pci-card-data';
if ($pci_tool && $alerts{$pci_tool}->{'action'} eq 'permissions'){
$type = 'pci-card-data-root';
}
- push(@rows, {
- main::key($num++,0,1,$key) => main::message($type,''),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message($type,'')
+ });
}
eval $end if $b_log;
- return @rows;
}
sub usb_output {
eval $start if $b_log;
return if !$usb{'network'};
- my (@rows,@temp2,$b_wifi,$driver,$path,$path_id,$product,$type);
+ my $rows = $_[0];
+ my (@temp2,$b_wifi,$driver,$path,$path_id,$product,$type);
my ($j,$num) = (0,1);
foreach my $row (@{$usb{'network'}}){
$num = 1;
@@ -17383,52 +18161,49 @@ sub usb_output {
$path_id = $row->[2] if $row->[2];
$type = $row->[14] if $row->[14];
$driver ||= 'N/A';
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'Device') => $product,
main::key($num++,0,2,'type') => 'USB',
main::key($num++,0,2,'driver') => $driver,
},);
$b_wifi = check_wifi($product);
if ($extra > 0){
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = "$path_id:$row->[1]";
}
if ($extra > 1){
$row->[7] ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $row->[7];
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $row->[7];
}
if ($extra > 2 && defined $row->[5] && $row->[5] ne ''){
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = "$row->[4]$row->[5]";
}
if ($extra > 2 && $row->[16]){
- $rows[$j]->{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
+ $rows->[$j]{main::key($num++,0,2,'serial')} = main::filter($row->[16]);
}
if ($show{'network-advanced'}){
- my @data;
if (!$bsd_type){
my (@temp,$vendor,$chip);
@temp = split(':', $row->[7]) if $row->[7];
($vendor,$chip) = ($temp[0],$temp[1]) if @temp;
- @data = advanced_data_sys($vendor,$chip,0,$b_wifi,$path,'');
+ advanced_data_sys($rows,$vendor,$chip,0,$b_wifi,$path,'');
}
# NOTE: we need the driver + driver nu, like wlp0 to get a match,
else {
$driver .= $row->[21] if defined $row->[21];
- @data = advanced_data_bsd($driver,$b_wifi);
+ advanced_data_bsd($rows,$driver,$b_wifi);
}
- push(@rows,@data) if @data;
}
- $j = scalar @rows;
}
eval $end if $b_log;
- return @rows;
}
sub advanced_data_sys {
eval $start if $b_log;
return if ! -d '/sys/class/net';
- my ($vendor,$chip,$count,$b_wifi,$path_usb,$bus_id) = @_;
- my ($cont_if,$ind_if,$num) = (2,3,0);
+ my ($rows,$vendor,$chip,$count,$b_wifi,$path_usb,$bus_id) = @_;
+ my ($cont_if,$ind_if,$j,$num) = (2,3,0,0);
my $key = 'IF';
- my ($b_check,$b_usb,$if,$path,@paths,@row,@rows);
+ my ($b_check,$b_usb,$if,$path,@paths);
# ntoe: we've already gotten the base path, now we
# we just need to get the IF path, which is one level in:
# usb1/1-1/1-1:1.0/net/enp0s20f0u1/
@@ -17451,6 +18226,7 @@ sub advanced_data_sys {
# print join('; ', @paths), $count, "\n";
foreach (@paths){
my ($data1,$data2,$duplex,$mac,$speed,$state);
+ $j = scalar @$rows;
# for usb, we already know where we are
if (!$b_usb){
# pi mmcnr has pcitool and also these vendor/device paths.
@@ -17493,10 +18269,10 @@ sub advanced_data_sys {
$state = main::reader($path,'',0) if -r $path;
$state ||= 'N/A';
# print "$speed \n";
- @row = ({
+ push(@$rows,{
main::key($num++,1,$cont_if,$key) => $if,
- main::key($num++,0,$ind_if,'state') => $state,
- },);
+ main::key($num++,0,$ind_if,'state') => $state
+ });
# my $j = scalar @row - 1;
push(@ifs_found, $if) if (!$b_check && (! grep {/$if/} @ifs_found));
# print "push: if: $if ifs: @ifs_found\n";
@@ -17508,90 +18284,86 @@ sub advanced_data_sys {
if (!$b_wifi && $state ne 'down' && $state ne 'no'){
# make sure the value is strictly numeric before appending Mbps
$speed = (main::is_int($speed)) ? "$speed Mbps" : $speed;
- $row[0]->{main::key($num++,0,$ind_if,'speed')} = $speed;
- $row[0]->{main::key($num++,0,$ind_if,'duplex')} = $duplex;
- }
- $row[0]->{main::key($num++,0,$ind_if,'mac')} = $mac;
- if ($b_check){
- push(@rows,@row);
- }
- else {
- @rows = @row;
- }
+ $rows->[$j]{main::key($num++,0,$ind_if,'speed')} = $speed;
+ $rows->[$j]{main::key($num++,0,$ind_if,'duplex')} = $duplex;
+ }
+ $rows->[$j]{main::key($num++,0,$ind_if,'mac')} = $mac;
+ # if ($b_check){
+ # push(@rows,@row);
+ # }
+ # else {
+ # @rows = @row;
+ # }
if ($show{'ip'}){
- @row = if_ip($key,$if);
- push(@rows, @row);
+ if_ip($rows,$key,$if);
}
last if !$b_check;
}
}
eval $end if $b_log;
- return @rows;
}
sub advanced_data_bsd {
eval $start if $b_log;
return if ! @ifs_bsd;
- my ($if,$b_wifi) = @_;
- my (@data,@row,@rows,$working_if);
+ my ($rows,$if,$b_wifi) = @_;
+ my ($data,$working_if);
my ($b_check,$state,$speed,$duplex,$mac);
- my ($cont_if,$ind_if,$num) = (2,3,0);
+ my ($cont_if,$ind_if,$j,$num) = (2,3,0,0);
my $key = 'IF';
- my $j = 0;
if ($if eq 'check'){
$b_check = 1;
$key = 'IF-ID';
($cont_if,$ind_if) = (1,2);
}
foreach my $item (@ifs_bsd){
+
if (ref $item ne 'ARRAY'){
$working_if = $item;
# print "$working_if\n";
next;
}
else {
- @data = @$item;
+ $data = $item;
}
if ($b_check || $working_if eq $if){
$if = $working_if if $b_check;
- # print "top: if: $if ifs: @ifs_found\n";
+ # print "top1: if: $if ifs: wif: $working_if @ifs_found\n";
next if ($b_check && grep {/$if/} @ifs_found);
- foreach my $line (@data){
- # ($state,$speed,$duplex,$mac)
- $duplex = $data[2];
- $duplex ||= 'N/A';
- $mac = main::filter($data[3]);
- $speed = $data[1];
- $speed ||= 'N/A';
- $state = $data[0];
- $state ||= 'N/A';
- # print "$speed \n";
- @row = ({
- main::key($num++,1,$cont_if,$key) => $if,
- main::key($num++,0,$ind_if,'state') => $state,
- },);
- push(@ifs_found, $if) if (!$b_check && (!grep {/$if/} @ifs_found));
- # print "push: if: $if ifs: @ifs_found\n";
- # no print out for wifi since it doesn't have duplex/speed data available
- # note that some cards show 'unknown' for state, so only testing explicitly
- # for 'down' string in that to skip showing speed/duplex
- if (!$b_wifi && $state ne 'down' && $state ne 'no network'){
- # make sure the value is strictly numeric before appending Mbps
- $speed = (main::is_int($speed)) ? "$speed Mbps" : $speed;
- $row[0]->{main::key($num++,0,$ind_if,'speed')} = $speed;
- $row[0]->{main::key($num++,0,$ind_if,'duplex')} = $duplex;
- }
- $row[0]->{main::key($num++,0,$ind_if,'mac')} = $mac;
- }
- push(@rows, @row);
+ # print "top2: if: $if wif: $working_if ifs: @ifs_found\n";
+ # print Data::Dumper::Dumper $data;
+ # ($state,$speed,$duplex,$mac)
+ $duplex = $data->[2];
+ $duplex ||= 'N/A';
+ $mac = main::filter($data->[3]);
+ $speed = $data->[1];
+ $speed ||= 'N/A';
+ $state = $data->[0];
+ $state ||= 'N/A';
+ $j = scalar @$rows;
+ # print "$speed \n";
+ push(@$rows, {
+ main::key($num++,1,$cont_if,$key) => $if,
+ main::key($num++,0,$ind_if,'state') => $state,
+ });
+ push(@ifs_found, $if) if (!$b_check && (!grep {/$if/} @ifs_found));
+ # print "push: if: $if ifs: @ifs_found\n";
+ # no print out for wifi since it doesn't have duplex/speed data available
+ # note that some cards show 'unknown' for state, so only testing explicitly
+ # for 'down' string in that to skip showing speed/duplex
+ if (!$b_wifi && $state ne 'down' && $state ne 'no network'){
+ # make sure the value is strictly numeric before appending Mbps
+ $speed = (main::is_int($speed)) ? "$speed Mbps" : $speed;
+ $rows->[$j]{main::key($num++,0,$ind_if,'speed')} = $speed;
+ $rows->[$j]{main::key($num++,0,$ind_if,'duplex')} = $duplex;
+ }
+ $rows->[$j]{main::key($num++,0,$ind_if,'mac')} = $mac;
if ($show{'ip'} && $if){
- @row = if_ip($key,$if);
- push(@rows,@row) if @row;
+ if_ip($rows,$key,$if);
}
}
}
eval $end if $b_log;
- return @rows;
}
## values:
# 0 - ipv
@@ -17601,8 +18373,8 @@ sub advanced_data_bsd {
# 4 - scope if, if different from if
sub if_ip {
eval $start if $b_log;
- my ($type,$if) = @_;
- my (@data,@rows,$working_if);
+ my ($rows,$type,$if) = @_;
+ my ($working_if);
my ($cont_ip,$ind_ip) = (3,4);
my $num = 0;
my $j = 0;
@@ -17617,18 +18389,15 @@ sub if_ip {
# print "if:$if wif:$working_if\n";
next;
}
- else {
- @data = @$item;
- # print "ref:$item\n";
- }
if ($working_if eq $if){
- foreach my $data2 (@data){
- $j = scalar @rows;
+ # print "if $if item:\n", Data::Dumper::Dumper $item;
+ foreach my $data2 (@$item){
+ $j = scalar @$rows;
$num = 1;
if ($limit > 0 && $j >= $limit){
- push(@rows, {
- main::key($num++,0,$cont_ip,'Message') => main::message('output-limit',scalar @data),
- },);
+ push(@$rows, {
+ main::key($num++,0,$cont_ip,'Message') => main::message('output-limit',scalar @$item),
+ });
last OUTER;
}
# print "$data2->[0] $data2->[1]\n";
@@ -17651,35 +18420,34 @@ sub if_ip {
# trim off if at end of multi word string if found
$data2->[4] =~ s/\s$if$// if $data2->[4] =~ /[^\s]+\s$if$/;
my $key = ($data2->[4] =~ /deprecated|dynamic|temporary|noprefixroute/) ? 'type' : 'virtual';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,$cont_ip,"IP v$ipv") => $ip,
main::key($num++,0,$ind_ip,$key) => $data2->[4],
main::key($num++,0,$ind_ip,'scope') => $scope,
- },);
+ });
}
else {
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,$cont_ip,"IP v$ipv") => $ip,
main::key($num++,0,$ind_ip,'scope') => $scope,
- },);
+ });
}
}
else {
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,($cont_ip - 1),'IF') => $if,
main::key($num++,1,$cont_ip,"IP v$ipv") => $ip,
main::key($num++,0,$ind_ip,'scope') => $scope,
- },);
+ });
}
if ($extra > 1 && $data2->[2]){
$broadcast = main::filter($data2->[2]);
- $rows[$j]->{main::key($num++,0,$ind_ip,'broadcast')} = $broadcast;
+ $rows->[$j]{main::key($num++,0,$ind_ip,'broadcast')} = $broadcast;
}
}
}
}
eval $end if $b_log;
- return @rows;
}
# get ip using downloader 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
@@ -17692,7 +18460,8 @@ sub if_ip {
# dig +short +time=1 +tries=1 myip.opendns.com. A @208.67.222.222
sub wan_ip {
eval $start if $b_log;
- my (@data,$b_dig,$b_html,$ip,$ua);
+ my $rows = $_[0];
+ my ($b_dig,$b_html,$ip,$ua);
my $num = 0;
# time: 0.06 - 0.07 seconds
# cisco opendns.com may be terminating supporting this one, sometimes works, sometimes not:
@@ -17748,11 +18517,10 @@ sub wan_ip {
$ip = main::message('IP', 'WAN IP');
}
}
- @data = ({
+ push(@$rows, {
main::key($num++,0,1,'WAN IP') => $ip,
- },);
+ });
eval $end if $b_log;
- return @data;
}
sub check_bus_id {
eval $start if $b_log;
@@ -17782,15 +18550,15 @@ sub check_wifi {
package OpticalItem;
sub get {
eval $start if $b_log;
- my (%data,@rows,$key1,$val1);
+ my $rows = $_[0];
+ my $start = scalar @$rows;
+ my ($data,$val1);
my $num = 0;
if ($bsd_type){
- $key1 = 'Optical Report';
$val1 = main::message('optical-data-bsd');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
if ($dboot{'optical'}){
- %data = drive_data_bsd();
- @rows = drive_output(\%data) if %data;
+ $data = drive_data_bsd();
+ drive_output($rows,$data) if %$data;
}
else{
my $file = $system_files{'dmesg-boot'};
@@ -17800,48 +18568,42 @@ sub get {
elsif (!$file){
$val1 = main::message('dmesg-boot-missing');
}
- else {
- $val1 = main::message('optical-data-bsd');
- }
- $key1 = 'Optical Report';
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
}
}
else {
- %data = drive_data_linux();
- @rows = drive_output(\%data) if %data;
- }
- if (!@rows){
- $key1 = 'Message';
$val1 = main::message('optical-data');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ $data = drive_data_linux();
+ drive_output($rows,$data) if %$data;
+ }
+ # if none of the above increased the row count, show the error message
+ if ($start == scalar @$rows){
+ push(@$rows,{main::key($num++,0,1,'Message') => $val1});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub drive_output {
eval $start if $b_log;
- my ($drives) = @_;
- my (@rows);
+ my ($rows,$drives) = @_;
my $num = 0;
my $j = 0;
# build floppy if any
foreach my $key (sort keys %$drives){
if ($drives->{$key}{'type'} eq 'floppy'){
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,ucfirst($drives->{$key}{'type'})) => "/dev/$key",
});
delete $drives->{$key};
}
}
foreach my $key (sort keys %$drives){
- $j = scalar @rows;
+ $j = scalar @$rows;
$num = 1;
my $vendor = $drives->{$key}{'vendor'};
$vendor ||= 'N/A';
my $model = $drives->{$key}{'model'};
$model ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,ucfirst($drives->{$key}{'type'})) => "/dev/$key",
main::key($num++,0,2,'vendor') => $vendor,
main::key($num++,0,2,'model') => $model,
@@ -17849,15 +18611,15 @@ sub drive_output {
if ($extra > 0){
my $rev = $drives->{$key}{'rev'};
$rev ||= 'N/A';
- $rows[$j]->{ main::key($num++,0,2,'rev')} = $rev;
+ $rows->[$j]{ main::key($num++,0,2,'rev')} = $rev;
}
if ($extra > 1 && $drives->{$key}{'serial'}){
- $rows[$j]->{ main::key($num++,0,2,'serial')} = main::filter($drives->{$key}{'serial'});
+ $rows->[$j]{ main::key($num++,0,2,'serial')} = main::filter($drives->{$key}{'serial'});
}
my $links = (@{$drives->{$key}{'links'}}) ? join(',', sort @{$drives->{$key}{'links'}}) : 'N/A' ;
- $rows[$j]->{ main::key($num++,0,2,'dev-links')} = $links;
+ $rows->[$j]{ main::key($num++,0,2,'dev-links')} = $links;
if ($show{'optical'}){
- $j = scalar @rows;
+ $j = scalar @$rows;
my $speed = $drives->{$key}{'speed'};
$speed ||= 'N/A';
my ($audio,$multisession) = ('','');
@@ -17887,7 +18649,7 @@ sub drive_output {
push(@rw, 'dvd-ram');
}
$rws = (@rw) ? join(',', @rw) : 'none' ;
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,2,'Features') => '',
main::key($num++,0,3,'speed') => $speed,
main::key($num++,0,3,'multisession') => $multisession,
@@ -17898,17 +18660,17 @@ sub drive_output {
if ($extra > 0){
my $state = $drives->{$key}{'state'};
$state ||= 'N/A';
- $rows[$j]->{ main::key($num++,0,3,'state')} = $state;
+ $rows->[$j]{ main::key($num++,0,3,'state')} = $state;
}
}
}
- # print Data::Dumper::Dumper \%drives;
+ # print Data::Dumper::Dumper $drives;
eval $end if $b_log;
- return @rows;
}
sub drive_data_bsd {
eval $start if $b_log;
- my (%drives,@rows,@temp);
+ my (@rows,@temp);
+ my $drives = {};
my ($count,$i,$working) = (0,0,'');
foreach (@{$dboot{'optical'}}){
$_ =~ s/(cd[0-9]+)\(([^:]+):([0-9]+):([0-9]+)\):/$1:$2-$3.$4,/;
@@ -17919,78 +18681,78 @@ sub drive_data_bsd {
$working = $row[0];
}
# no dots, note: ada2: 2861588MB BUT: ada2: 600.000MB/s
- if (!exists $drives{$working}){
- $drives{$working}->{'links'} = [];
- $drives{$working}->{'model'} = '';
- $drives{$working}->{'rev'} = '';
- $drives{$working}->{'state'} = '';
- $drives{$working}->{'vendor'} = '';
- $drives{$working}->{'temp'} = '';
- $drives{$working}->{'type'} = ($working =~ /^cd/) ? 'optical' : 'unknown';
+ if (!exists $drives->{$working}){
+ $drives->{$working}{'links'} = [];
+ $drives->{$working}{'model'} = '';
+ $drives->{$working}{'rev'} = '';
+ $drives->{$working}{'state'} = '';
+ $drives->{$working}{'vendor'} = '';
+ $drives->{$working}{'temp'} = '';
+ $drives->{$working}{'type'} = ($working =~ /^cd/) ? 'optical' : 'unknown';
}
# print "$_\n";
if ($bsd_type !~ /^(net|open)bsd$/){
if ($row[1] && $row[1] =~ /^<([^>]+)>/){
- $drives{$working}->{'model'} = $1;
- $count = ($drives{$working}->{'model'} =~ tr/ //);
+ $drives->{$working}{'model'} = $1;
+ $count = ($drives->{$working}{'model'} =~ tr/ //);
if ($count && $count > 1){
- @temp = split(/\s+/, $drives{$working}->{'model'});
- $drives{$working}->{'vendor'} = $temp[0];
+ @temp = split(/\s+/, $drives->{$working}{'model'});
+ $drives->{$working}{'vendor'} = $temp[0];
my $index = ($#temp > 2) ? ($#temp - 1): $#temp;
- $drives{$working}->{'model'} = join(' ', @temp[1..$index]);
- $drives{$working}->{'rev'} = $temp[-1] if $count > 2;
+ $drives->{$working}{'model'} = join(' ', @temp[1..$index]);
+ $drives->{$working}{'rev'} = $temp[-1] if $count > 2;
}
if ($show{'optical'}){
if (/\bDVD\b/){
- $drives{$working}->{'dvd'} = 1;
+ $drives->{$working}{'dvd'} = 1;
}
if (/\bRW\b/){
- $drives{$working}->{'cdrw'} = 1;
- $drives{$working}->{'dvdr'} = 1 if $drives{$working}->{'dvd'};
+ $drives->{$working}{'cdrw'} = 1;
+ $drives->{$working}{'dvdr'} = 1 if $drives->{$working}{'dvd'};
}
}
}
if ($row[1] && $row[1] =~ /^Serial/){
@temp = split(/\s+/,$row[1]);
- $drives{$working}->{'serial'} = $temp[-1];
+ $drives->{$working}{'serial'} = $temp[-1];
}
if ($show{'optical'}){
if ($row[1] =~ /^([0-9\.]+[MGTP][B]?\/s)/){
- $drives{$working}->{'speed'} = $1;
- $drives{$working}->{'speed'} =~ s/\.[0-9]+//;
+ $drives->{$working}{'speed'} = $1;
+ $drives->{$working}{'speed'} =~ s/\.[0-9]+//;
}
if (/\bDVD[-]?RAM\b/){
- $drives{$working}->{'cdr'} = 1;
- $drives{$working}->{'dvdram'} = 1;
+ $drives->{$working}{'cdr'} = 1;
+ $drives->{$working}{'dvdram'} = 1;
}
if ($row[2] && $row[2] =~ /,\s(.*)$/){
- $drives{$working}->{'state'} = $1;
- $drives{$working}->{'state'} =~ s/\s+-\s+/, /;
+ $drives->{$working}{'state'} = $1;
+ $drives->{$working}{'state'} =~ s/\s+-\s+/, /;
}
}
}
else {
if ($row[2] && $row[2] =~ /<([^>]+)>/){
- $drives{$working}->{'model'} = $1;
- $count = ($drives{$working}->{'model'} =~ tr/,//);
+ $drives->{$working}{'model'} = $1;
+ $count = ($drives->{$working}{'model'} =~ tr/,//);
# print "c: $count $row[2]\n";
if ($count && $count > 1){
- @temp = split(/,\s*/, $drives{$working}->{'model'});
- $drives{$working}->{'vendor'} = $temp[0];
- $drives{$working}->{'model'} = $temp[1];
- $drives{$working}->{'rev'} = $temp[2];
+ @temp = split(/,\s*/, $drives->{$working}{'model'});
+ $drives->{$working}{'vendor'} = $temp[0];
+ $drives->{$working}{'model'} = $temp[1];
+ $drives->{$working}{'rev'} = $temp[2];
}
if ($show{'optical'}){
if (/\bDVD\b/){
- $drives{$working}->{'dvd'} = 1;
+ $drives->{$working}{'dvd'} = 1;
}
if (/\bRW\b/){
- $drives{$working}->{'cdrw'} = 1;
- $drives{$working}->{'dvdr'} = 1 if $drives{$working}->{'dvd'};
+ $drives->{$working}{'cdrw'} = 1;
+ $drives->{$working}{'dvdr'} = 1 if $drives->{$working}{'dvd'};
}
if (/\bDVD[-]?RAM\b/){
- $drives{$working}->{'cdr'} = 1;
- $drives{$working}->{'dvdram'} = 1;
+ $drives->{$working}{'cdr'} = 1;
+ $drives->{$working}{'dvdram'} = 1;
}
}
}
@@ -17998,21 +18760,20 @@ sub drive_data_bsd {
# print "$row[1]\n";
if (($row[1] =~ tr/,//) > 1){
@temp = split(/,\s*/, $row[1]);
- $drives{$working}->{'speed'} = $temp[2];
+ $drives->{$working}{'speed'} = $temp[2];
}
-
}
}
}
-
- main::log_data('dump','%drives',\%drives) if $b_log;
- # print Data::Dumper::Dumper \%drives;
+ main::log_data('dump','%$drives',$drives) if $b_log;
+ # print Data::Dumper::Dumper $drives;
eval $end if $b_log;
- return %drives;
+ return $drives;
}
sub drive_data_linux {
eval $start if $b_log;
- my (@data,%drives,@info,@rows);
+ my (@data,@info,@rows);
+ my $drives = {};
@data = main::globber('/dev/dvd* /dev/cdr* /dev/scd* /dev/sr* /dev/fd[0-9]');
# Newer kernel is NOT linking all optical drives. Some, but not all.
# Get the actual disk dev location, first try default which is easier to run,
@@ -18024,13 +18785,13 @@ sub drive_data_linux {
# possible fix: puppy has these in /mnt not /dev they say
$working =~ s/\/(dev|media|mnt)\///;
$_ =~ s/\/(dev|media|mnt)\///;
- if (!defined $drives{$working}){
+ if (!defined $drives->{$working}){
my @temp = ($_ ne $working) ? ($_) : ();
- $drives{$working}->{'links'} = \@temp;
- $drives{$working}->{'type'} = ($working =~ /^fd/) ? 'floppy' : 'optical' ;
+ $drives->{$working}{'links'} = \@temp;
+ $drives->{$working}{'type'} = ($working =~ /^fd/) ? 'floppy' : 'optical' ;
}
else {
- push(@{$drives{$working}->{'links'}}, $_) if $_ ne $working;
+ push(@{$drives->{$working}{'links'}}, $_) if $_ ne $working;
}
# print "$working\n";
}
@@ -18038,22 +18799,22 @@ sub drive_data_linux {
@info = main::reader('/proc/sys/dev/cdrom/info','strip');
}
# print join('; ', @data), "\n";
- foreach my $key (keys %drives){
- next if $drives{$key}->{'type'} eq 'floppy';
+ foreach my $key (keys %$drives){
+ next if $drives->{$key}{'type'} eq 'floppy';
my $device = "/sys/block/$key/device";
if (-d $device){
if (-r "$device/vendor"){
- $drives{$key}->{'vendor'} = main::reader("$device/vendor",'',0);
- $drives{$key}->{'vendor'} = main::clean($drives{$key}->{'vendor'});
- $drives{$key}->{'state'} = main::reader("$device/state",'',0);
- $drives{$key}->{'model'} = main::reader("$device/model",'',0);
- $drives{$key}->{'model'} = main::clean($drives{$key}->{'model'});
- $drives{$key}->{'rev'} = main::reader("$device/rev",'',0);
+ $drives->{$key}{'vendor'} = main::reader("$device/vendor",'',0);
+ $drives->{$key}{'vendor'} = main::clean($drives->{$key}{'vendor'});
+ $drives->{$key}{'state'} = main::reader("$device/state",'',0);
+ $drives->{$key}{'model'} = main::reader("$device/model",'',0);
+ $drives->{$key}{'model'} = main::clean($drives->{$key}{'model'});
+ $drives->{$key}{'rev'} = main::reader("$device/rev",'',0);
}
}
elsif (-r "/proc/ide/$key/model"){
- $drives{$key}->{'vendor'} = main::reader("/proc/ide/$key/model",'',0);
- $drives{$key}->{'vendor'} = main::clean($drives{$key}->{'vendor'});
+ $drives->{$key}{'vendor'} = main::reader("/proc/ide/$key/model",'',0);
+ $drives->{$key}{'vendor'} = main::clean($drives->{$key}{'vendor'});
}
if ($show{'optical'} && @info){
my $index = 0;
@@ -18068,41 +18829,40 @@ sub drive_data_linux {
last if !$index; # index will be > 0 if it was found
}
elsif ($item =~/^drive speed:/){
- $drives{$key}->{'speed'} = $split[$index];
+ $drives->{$key}{'speed'} = $split[$index];
}
elsif ($item =~/^Can read multisession:/){
- $drives{$key}->{'multisession'}=$split[$index+1];
+ $drives->{$key}{'multisession'}=$split[$index+1];
}
elsif ($item =~/^Can read MCN:/){
- $drives{$key}->{'mcn'}=$split[$index+1];
+ $drives->{$key}{'mcn'}=$split[$index+1];
}
elsif ($item =~/^Can play audio:/){
- $drives{$key}->{'audio'}=$split[$index+1];
+ $drives->{$key}{'audio'}=$split[$index+1];
}
elsif ($item =~/^Can write CD-R:/){
- $drives{$key}->{'cdr'}=$split[$index+1];
+ $drives->{$key}{'cdr'}=$split[$index+1];
}
elsif ($item =~/^Can write CD-RW:/){
- $drives{$key}->{'cdrw'}=$split[$index+1];
+ $drives->{$key}{'cdrw'}=$split[$index+1];
}
elsif ($item =~/^Can read DVD:/){
- $drives{$key}->{'dvd'}=$split[$index+1];
+ $drives->{$key}{'dvd'}=$split[$index+1];
}
elsif ($item =~/^Can write DVD-R:/){
- $drives{$key}->{'dvdr'}=$split[$index+1];
+ $drives->{$key}{'dvdr'}=$split[$index+1];
}
elsif ($item =~/^Can write DVD-RAM:/){
- $drives{$key}->{'dvdram'}=$split[$index+1];
+ $drives->{$key}{'dvdram'}=$split[$index+1];
}
}
}
}
- main::log_data('dump','%drives',\%drives) if $b_log;
- # print Data::Dumper::Dumper \%drives;
+ main::log_data('dump','%$drives',$drives) if $b_log;
+ # print Data::Dumper::Dumper $drives;
eval $end if $b_log;
- return %drives;
+ return $drives;
}
-
}
## PartitionItem
@@ -18111,7 +18871,8 @@ package PartitionItem;
sub get {
eval $start if $b_log;
- my (@rows,$key1,$val1);
+ my ($key1,$val1);
+ my $rows = [];
my $num = 0;
set_partitions() if !$loaded{'set-partitions'};
# fails in corner case with zram but no other mounted filesystems
@@ -18120,19 +18881,20 @@ sub get {
#$val1 = ($bsd_type && $bsd_type eq 'darwin') ?
# main::message('darwin-feature') : main::message('partition-data');
$val1 = main::message('partition-data');
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1,});
}
else {
- @rows = create_output();
+ create_output($rows);
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub create_output {
eval $start if $b_log;
+ my $rows = $_[0];
my $num = 0;
my $j = 0;
- my (@rows,$dev,$dev_type,$fs,$percent,$raw_size,$size,$used);
+ my ($dev,$dev_type,$fs,$percent,$raw_size,$size,$used);
# alpha sort for non numerics
if ($show{'partition-sort'} !~ /^(percent-used|size|used)$/){
@partitions = sort { $a->{$show{'partition-sort'}} cmp $b->{$show{'partition-sort'}} } @partitions;
@@ -18160,41 +18922,41 @@ sub create_output {
$row->{'dev-base'} = '/dev/' . $row->{'dev-base'} if $dev_type eq 'dev' && $row->{'dev-base'};
$dev = ($row->{'dev-base'}) ? $row->{'dev-base'} : 'N/A';
$row->{'id'} =~ s|/home/[^/]+/(.*)|/home/$filter_string/$1| if $use{'filter'};
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'ID') => $row->{'id'},
});
if (($b_admin || $row->{'hidden'}) && $row->{'raw-size'}){
# It's an error! permissions or missing tool
$raw_size = ($row->{'raw-size'}) ? main::get_size($row->{'raw-size'},'string') : 'N/A';
- $rows[$j]->{main::key($num++,0,2,'raw-size')} = $raw_size;
+ $rows->[$j]{main::key($num++,0,2,'raw-size')} = $raw_size;
}
if ($b_admin && $row->{'raw-available'} && $size ne 'N/A'){
$size .= ' (' . $row->{'raw-available'} . '%)';
}
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
- $rows[$j]->{main::key($num++,0,2,'used')} = $used . $percent;
- $rows[$j]->{main::key($num++,0,2,'fs')} = $fs;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'used')} = $used . $percent;
+ $rows->[$j]{main::key($num++,0,2,'fs')} = $fs;
if ($b_admin && $fs eq 'swap' && defined $row->{'swappiness'}){
- $rows[$j]->{main::key($num++,0,2,'swappiness')} = $row->{'swappiness'};
+ $rows->[$j]{main::key($num++,0,2,'swappiness')} = $row->{'swappiness'};
}
if ($b_admin && $fs eq 'swap' && defined $row->{'cache-pressure'}){
- $rows[$j]->{main::key($num++,0,2,'cache-pressure')} = $row->{'cache-pressure'};
+ $rows->[$j]{main::key($num++,0,2,'cache-pressure')} = $row->{'cache-pressure'};
}
if ($extra > 1 && $fs eq 'swap' && defined $row->{'priority'}){
- $rows[$j]->{main::key($num++,0,2,'priority')} = $row->{'priority'};
+ $rows->[$j]{main::key($num++,0,2,'priority')} = $row->{'priority'};
}
if ($b_admin && $row->{'block-size'}){
- $rows[$j]->{main::key($num++,0,2,'block-size')} = $row->{'block-size'} . ' B';;
- #$rows[$j]->{main::key($num++,0,2,'physical')} = $row->{'block-size'} . ' B';
- #$rows[$j]->{main::key($num++,0,2,'logical')} = $row->{'block-logical'} . ' B';
+ $rows->[$j]{main::key($num++,0,2,'block-size')} = $row->{'block-size'} . ' B';;
+ #$rows->[$j]{main::key($num++,0,2,'physical')} = $row->{'block-size'} . ' B';
+ #$rows->[$j]{main::key($num++,0,2,'logical')} = $row->{'block-logical'} . ' B';
}
- $rows[$j]->{main::key($num++,1,2,$dev_type)} = $dev;
+ $rows->[$j]{main::key($num++,1,2,$dev_type)} = $dev;
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,3,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,3,'maj-min')} = $row->{'maj-min'};
}
if ($extra > 0 && $row->{'dev-mapped'}){
- $rows[$j]->{main::key($num++,0,3,'mapped')} = $row->{'dev-mapped'};
+ $rows->[$j]{main::key($num++,0,3,'mapped')} = $row->{'dev-mapped'};
}
# add fs known to not use label/uuid here
if (($show{'label'} || $show{'uuid'}) && $dev_type eq 'dev' &&
@@ -18204,29 +18966,28 @@ sub create_output {
$row->{'label'} = main::filter_partition('part', $row->{'label'}, '');
}
$row->{'label'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'};
+ $rows->[$j]{main::key($num++,0,2,'label')} = $row->{'label'};
}
if ($show{'uuid'}){
if ($use{'filter-uuid'}){
$row->{'uuid'} = main::filter_partition('part', $row->{'uuid'}, '');
}
$row->{'uuid'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
+ $rows->[$j]{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
}
}
}
# corner case, no partitions, but zram swap
- if (!@rows){
- @rows = ({main::key($num++,0,1,'Message') => main::message('partition-data')});
+ if (!@$rows){
+ @$rows = ({main::key($num++,0,1,'Message') => main::message('partition-data')});
}
eval $end if $b_log;
- return @rows;
}
sub set_partitions {
eval $start if $b_log;
#return if $bsd_type && $bsd_type eq 'darwin'; # darwin has muated output, of course
- my (@data,@rows,@mount,@partitions_working,%part,@working);
+ my (@data,@rows,@mount,@partitions_working,$part,@working);
my ($back_size,$back_used,$b_fs,$cols) = (4,3,1,6);
my ($b_dfp,$b_fake_map,$b_load,$b_logical,$b_space,);
my ($block_size,$blockdev,$dev_base,$dev_mapped,$dev_type,$fs,$id,$label,
@@ -18272,8 +19033,8 @@ sub set_partitions {
}
else {
my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/df/df-kTP-cygwin-1.txt";
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/df/df-kT-wrapped-1.txt";
+ # $file = "$fake_data_dir/df/df-kTP-cygwin-1.txt";
+ $file = "$fake_data_dir/df/df-kT-wrapped-1.txt";
@partitions_working = main::reader($file);
}
# print Data::Dumper::Dumper \@partitions_working;
@@ -18331,7 +19092,7 @@ sub set_partitions {
$maj_min,$type,$uuid) = ('','','','','','','','','');
($b_load,$b_space,$block_size,$percent_used,$raw_size,$size_available,
$size,$used) = (0,0,0,0,0,0,0,0);
- undef %part;
+ undef $part;
# apple crap, maybe also freebsd?
$_ =~ s/^map\s+([\S]+)/map:\/$1/ if $b_fake_map;
# handle spaces in remote filesystem names
@@ -18377,7 +19138,7 @@ sub set_partitions {
}
$dev_base = $row[0];
$dev_base =~ s|^/.*/||;
- %part = LsblkData::get($dev_base) if @lsblk;
+ $part = LsblkData::get($dev_base) if @lsblk;
$maj_min = get_maj_min($dev_base) if @proc_partitions;
}
# this handles zfs type devices/partitions, which do not start with / but contain /
@@ -18406,22 +19167,22 @@ sub set_partitions {
if ($b_load){
if (!$bsd_type){
if ($b_fs){
- $fs = ($part{'fs'}) ? $part{'fs'} : $row[1];
+ $fs = ($part->{'fs'}) ? $part->{'fs'} : $row[1];
}
else {
$fs = get_mounts_fs($row[0],\@mount);
}
if ($show{'label'}){
- if ($part{'label'}){
- $label = $part{'label'};
+ if ($part->{'label'}){
+ $label = $part->{'label'};
}
elsif (@labels){
$label = get_label($row[0]);
}
}
if ($show{'uuid'}){
- if ($part{'uuid'}){
- $uuid = $part{'uuid'};
+ if ($part->{'uuid'}){
+ $uuid = $part->{'uuid'};
}
elsif (@uuids){
$uuid = get_uuid($row[0]);
@@ -18476,10 +19237,10 @@ sub set_partitions {
}
if ($bsd_type && $dev_type eq 'dev' && $row[0] &&
($b_admin || $show{'label'} || $show{'uuid'})){
- my %temp = DiskDataBSD::get($row[0]);
- $block_size = $temp{'logical-block-size'};
- $label = $temp{'label'};
- $uuid = $temp{'uuid'};
+ my $temp = DiskDataBSD::get($row[0]);
+ $block_size = $temp->{'logical-block-size'};
+ $label = $temp->{'label'};
+ $uuid = $temp->{'uuid'};
}
$used = $row[$cols - $back_used];
$percent_used = sprintf("%.1f", ($used/$size)*100) if ($size && main::is_numeric($size));
@@ -18583,10 +19344,10 @@ sub swap_data {
}
else {
if ($show{'label'} || $show{'uuid'}){
- my %temp = DiskDataBSD::get($data[0]);
- $block_size = $temp{'logical-block-size'};
- $label = $temp{'label'};
- $uuid = $temp{'uuid'};
+ my $temp = DiskDataBSD::get($data[0]);
+ $block_size = $temp->{'logical-block-size'};
+ $label = $temp->{'label'};
+ $uuid = $temp->{'uuid'};
}
}
$dev_type = 'dev';
@@ -18880,88 +19641,86 @@ package ProcessItem;
sub get {
eval $start if $b_log;
my $num = 0;
- my (@rows);
+ my $rows = [];
if (@ps_aux){
if ($show{'ps-cpu'}){
- push(@rows,cpu_processes());
+ cpu_processes($rows);
}
if ($show{'ps-mem'}){
- push(@rows,mem_processes());
+ mem_processes($rows);
}
}
else {
my $key = 'Message';
- push(@rows, ({
- main::key($num++,0,1,$key) => main::message('ps-data-null',''),
- },));
+ push(@$rows, {
+ main::key($num++,0,1,$key) => main::message('ps-data-null','')
+ });
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub cpu_processes {
eval $start if $b_log;
+ my $rows = $_[0];
my ($j,$num,$cpu,$cpu_mem,$mem,$pid) = (0,0,'','','','');
- my ($pid_col,@processes,@rows);
+ my ($pid_col,@ps_rows);
my $count = ($b_irc)? 5: $ps_count;
if ($ps_cols >= 10){
- @rows = sort {
+ @ps_rows = sort {
my @a = split(/\s+/, $a);
my @b = split(/\s+/, $b);
$b[2] <=> $a[2] } @ps_aux;
$pid_col = 1;
}
else {
- @rows = @ps_aux;
+ @ps_rows = @ps_aux;
$pid_col = 0 if $ps_cols == 2;
}
# if there's a count limit, for irc, etc, only use that much of the data
- @rows = splice(@rows,0,$count);
-
- $j = scalar @rows;
+ @ps_rows = splice(@ps_rows,0,$count);
+ $j = scalar @ps_rows;
# $cpu_mem = ' - Memory: MiB / % used' if $extra > 0;
my $throttled = throttled($ps_count,$count,$j);
# my $header = "CPU % used - Command - pid$cpu_mem - top";
# my $header = "Top $count by CPU";
- my @data = ({
- main::key($num++,1,1,'CPU top') => "$count$throttled" . ' of ' . scalar @ps_aux,
- },);
- push(@processes,@data);
+ push(@$rows,{
+ main::key($num++,1,1,'CPU top') => "$count$throttled" . ' of ' . scalar @ps_aux
+ });
my $i = 1;
- foreach (@rows){
+ foreach (@ps_rows){
$num = 1;
- $j = scalar @processes;
+ $j = scalar @$rows;
my @row = split(/\s+/, $_);
- my @command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]);
+ my $command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]);
$cpu = ($ps_cols >= 10) ? $row[2] . '%': 'N/A';
- @data = ({
+ push(@$rows,{
main::key($num++,1,2,$i++) => '',
main::key($num++,0,3,'cpu') => $cpu,
- main::key($num++,1,3,'command') => $command[0],
- },);
- push(@processes,@data);
- if ($command[1]){
- $processes[$j]->{main::key($num++,0,4,'started by')} = $command[1];
+ main::key($num++,1,3,'command') => $command->[0],
+ });
+ if ($command->[1]){
+ $rows->[$j]{main::key($num++,0,4,'started by')} = $command->[1];
}
$pid = (defined $pid_col)? $row[$pid_col] : 'N/A';
- $processes[$j]->{main::key($num++,0,3,'pid')} = $pid;
+ $rows->[$j]{main::key($num++,0,3,'pid')} = $pid;
if ($extra > 0 && $ps_cols >= 10){
my $decimals = ($row[5]/1024 > 10) ? 1 : 2;
$mem = (defined $row[5]) ? sprintf("%.${decimals}f", $row[5]/1024) . ' MiB' : 'N/A';
$mem .= ' (' . $row[3] . '%)';
- $processes[$j]->{main::key($num++,0,3,'mem')} = $mem;
+ $rows->[$j]{main::key($num++,0,3,'mem')} = $mem;
}
# print Data::Dumper::Dumper \@processes, "i: $i; j: $j ";
}
eval $end if $b_log;
- return @processes;
}
sub mem_processes {
eval $start if $b_log;
+ my $rows = $_[0];
my ($j,$num,$cpu,$cpu_mem,$mem,$pid) = (0,0,'','','','');
- my (@data,$pid_col,@processes,$memory,@rows);
+ my (@data,$pid_col,$memory,@ps_rows);
my $count = ($b_irc)? 5: $ps_count;
if ($ps_cols >= 10){
- @rows = sort {
+ @ps_rows = sort {
my @a = split(/\s+/, $a);
my @b = split(/\s+/, $b);
$b[5] <=> $a[5] } @ps_aux; # 5
@@ -18969,25 +19728,24 @@ sub mem_processes {
$pid_col = 1;
}
else {
- @rows = @ps_aux;
+ @ps_rows = @ps_aux;
$pid_col = 0 if $ps_cols == 2;
}
- @rows = splice(@rows,0,$count);
+ @ps_rows = splice(@ps_rows,0,$count);
# print Data::Dumper::Dumper \@rows;
- @processes = main::MemoryData::full('process') if !$loaded{'memory'};
- $j = scalar @rows;
+ push(@$rows,main::MemoryData::full('process')) if !$loaded{'memory'};
+ $j = scalar @$rows;
my $throttled = throttled($ps_count,$count,$j);
#$cpu_mem = ' - CPU: % used' if $extra > 0;
# my $header = "Memory MiB/% used - Command - pid$cpu_mem - top";
# my $header = "Top $count by Memory";
- @data = ({
- main::key($num++,1,1,'Memory top') => "$count$throttled" . ' of ' . scalar @ps_aux,
- },);
- push(@processes,@data);
+ push(@$rows, {
+ main::key($num++,1,1,'Memory top') => "$count$throttled" . ' of ' . scalar @ps_aux
+ });
my $i = 1;
- foreach (@rows){
+ foreach (@ps_rows){
$num = 1;
- $j = scalar @processes;
+ $j = scalar @$rows;
my @row = split(/\s+/, $_);
if ($ps_cols >= 10){
my $decimals = ($row[5]/1024 > 10) ? 1 : 2;
@@ -18997,43 +19755,41 @@ sub mem_processes {
else {
$mem = 'N/A';
}
- my @command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]);
- @data = ({
+ my $command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]);
+ push(@$rows,{
main::key($num++,1,2,$i++) => '',
main::key($num++,0,3,'mem') => $mem,
- main::key($num++,1,3,'command') => $command[0],
- },);
- push(@processes,@data);
- if ($command[1]){
- $processes[$j]->{main::key($num++,0,4,'started by')} = $command[1];
+ main::key($num++,1,3,'command') => $command->[0],
+ });
+ if ($command->[1]){
+ $rows->[$j]{main::key($num++,0,4,'started by')} = $command->[1];
}
$pid = (defined $pid_col)? $row[$pid_col] : 'N/A';
- $processes[$j]->{main::key($num++,0,3,'pid')} = $pid;
+ $rows->[$j]{main::key($num++,0,3,'pid')} = $pid;
if ($extra > 0 && $ps_cols >= 10){
$cpu = $row[2] . '%';
- $processes[$j]->{main::key($num++,0,3,'cpu')} = $cpu;
+ $rows->[$j]{main::key($num++,0,3,'cpu')} = $cpu;
}
# print Data::Dumper::Dumper \@processes, "i: $i; j: $j ";
}
eval $end if $b_log;
- return @processes;
}
sub process_starter {
my ($count, $row10, $row11) = @_;
- my (@return);
+ my $return = [];
# note: [migration/0] would clear with a simple basename
if ($count > ($ps_cols + 1) && $row11 =~ /^\// && $row11 !~ /^\/(tmp|temp)/){
$row11 =~ s/^\/.*\///;
- $return[0] = $row11;
+ $return->[0] = $row11;
$row10 =~ s/^\/.*\///;
- $return[1] = $row10;
+ $return->[1] = $row10;
}
else {
$row10 =~ s/^\/.*\///;
- $return[0] = $row10;
- $return[1] = '';
+ $return->[0] = $row10;
+ $return->[1] = '';
}
- return @return;
+ return $return;
}
sub throttled {
my ($ps_count,$count,$j) = @_;
@@ -19054,144 +19810,143 @@ package RaidItem;
sub get {
eval $start if $b_log;
- my (@hardware_raid,@rows,$key1,$val1);
+ my ($hardware_raid,$key1,$val1);
my $num = 0;
- @hardware_raid = hw_data() if $use{'hardware-raid'} || $fake{'raid-hw'};
+ my $rows = [];
+ $hardware_raid = hw_data() if $use{'hardware-raid'} || $fake{'raid-hw'};
raid_data() if !$loaded{'raid'};
# print 'get btrfs: ', Data::Dumper::Dumper \@btrfs_raid;
# print 'get lvm: ', Data::Dumper::Dumper \@lvm_raid;
# print 'get md: ', Data::Dumper::Dumper \@md_raid;
# print 'get zfs: ', Data::Dumper::Dumper \@zfs_raid;
if (!@btrfs_raid && !@lvm_raid && !@md_raid && !@zfs_raid && !@soft_raid &&
- !@hardware_raid){
+ !$hardware_raid){
if ($show{'raid-forced'}){
$key1 = 'Message';
$val1 = main::message('raid-data');
}
}
else {
- if (@hardware_raid){
- push(@rows,hw_output(\@hardware_raid));
+ if ($hardware_raid){
+ hw_output($rows,$hardware_raid);
}
if (@btrfs_raid){
- push(@rows,btrfs_output());
+ btrfs_output($rows);
}
if (@lvm_raid){
- push(@rows,lvm_output());
+ lvm_output($rows);
}
if (@md_raid){
- push(@rows,md_output());
+ md_output($rows);
}
if (@soft_raid){
- push(@rows,soft_output());
+ soft_output($rows);
}
if (@zfs_raid){
- push(@rows,zfs_output());
+ zfs_output($rows);
}
}
- if (!@rows && $key1){
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ if (!@$rows && $key1){
+ @$rows = ({main::key($num++,0,1,$key1) => $val1,});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub hw_output {
eval $start if $b_log;
- my ($hardware_raid) = @_;
- my (@rows);
+ my ($rows,$hardware_raid) = @_;
my ($j,$num) = (0,0);
foreach my $row (@$hardware_raid){
$num = 1;
my $device = ($row->{'device'}) ? $row->{'device'}: 'N/A';
my $driver = ($row->{'driver'}) ? $row->{'driver'}: 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Hardware') => $device,
});
- $j = scalar @rows - 1;
- $rows[$j]->{main::key($num++,0,2,'vendor')} = $row->{'vendor'} if $row->{'vendor'};
- $rows[$j]->{main::key($num++,1,2,'driver')} = $driver;
+ $j = scalar @$rows - 1;
+ $rows->[$j]{main::key($num++,0,2,'vendor')} = $row->{'vendor'} if $row->{'vendor'};
+ $rows->[$j]{main::key($num++,1,2,'driver')} = $driver;
if ($extra > 0){
$row->{'driver-version'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'v')} = $row->{'driver-version'};
+ $rows->[$j]{main::key($num++,0,3,'v')} = $row->{'driver-version'};
if ($extra > 2){
my $port= ($row->{'port'}) ? $row->{'port'}: 'N/A' ;
- $rows[$j]->{main::key($num++,0,2,'port')} = $port;
+ $rows->[$j]{main::key($num++,0,2,'port')} = $port;
}
my $bus_id = (defined $row->{'bus-id'} && defined $row->{'sub-id'}) ? "$row->{'bus-id'}.$row->{'sub-id'}": 'N/A' ;
- $rows[$j]->{main::key($num++,0,2,'bus-ID')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,2,'bus-ID')} = $bus_id;
}
if ($extra > 1){
my $chip_id = main::get_chip_id($row->{'vendor-id'},$row->{'chip-id'});
- $rows[$j]->{main::key($num++,0,2,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,2,'chip-ID')} = $chip_id;
}
if ($extra > 2){
$row->{'rev'} = 'N/A' if !defined $row->{'rev'}; # could be 0
- $rows[$j]->{main::key($num++,0,2,'rev')} = $row->{'rev'};
- $rows[$j]->{main::key($num++,0,2,'class-ID')} = $row->{'class-id'} if $row->{'class-id'};
+ $rows->[$j]{main::key($num++,0,2,'rev')} = $row->{'rev'};
+ $rows->[$j]{main::key($num++,0,2,'class-ID')} = $row->{'class-id'} if $row->{'class-id'};
}
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
sub btrfs_output {
eval $start if $b_log;
- my (@components,@good,@rows);
+ my $rows = $_[0];
+ my (@components,@good);
my ($size);
my ($j,$num) = (0,0);
foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @btrfs_raid){
-
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,2,'Components')} = '';
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,2,'Components')} = '';
my $b_bump;
- components_output('lvm','Online',\@rows,\@good,\$j,\$num,\$b_bump);
- components_output('lvm','Meta',\@rows,\@components,\$j,\$num,\$b_bump);
+ components_output('lvm','Online',$rows,\@good,\$j,\$num,\$b_bump);
+ components_output('lvm','Meta',$rows,\@components,\$j,\$num,\$b_bump);
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
sub lvm_output {
eval $start if $b_log;
- my (@components,@good,@components_meta,@rows);
+ my $rows = $_[0];
+ my (@components,@good,@components_meta);
my ($size);
my ($j,$num) = (0,0);
foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @lvm_raid){
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'Device') => $row->{'id'},
});
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
}
- $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'type'};
- $rows[$j]->{main::key($num++,0,2,'level')} = $row->{'level'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $row->{'type'};
+ $rows->[$j]{main::key($num++,0,2,'level')} = $row->{'level'};
$size = ($row->{'size'}) ? main::get_size($row->{'size'},'string'): 'N/A';
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
if ($row->{'raid-sync'}){
- $rows[$j]->{main::key($num++,0,2,'sync')} = $row->{'raid-sync'};
+ $rows->[$j]{main::key($num++,0,2,'sync')} = $row->{'raid-sync'};
}
if ($extra > 0){
- $j = scalar @rows;
+ $j = scalar @$rows;
$num = 1;
- $rows[$j]->{main::key($num++,1,2,'Info')} = '';
+ $rows->[$j]{main::key($num++,1,2,'Info')} = '';
if (defined $row->{'stripes'}){
- $rows[$j]->{main::key($num++,0,3,'stripes')} = $row->{'stripes'};
+ $rows->[$j]{main::key($num++,0,3,'stripes')} = $row->{'stripes'};
}
if (defined $row->{'raid-mismatches'} && ($extra > 1 || $row->{'raid-mismatches'} > 0)){
- $rows[$j]->{main::key($num++,0,3,'mismatches')} = $row->{'raid-mismatches'};
+ $rows->[$j]{main::key($num++,0,3,'mismatches')} = $row->{'raid-mismatches'};
}
if (defined $row->{'copy-percent'} && ($extra > 1 || $row->{'copy-percent'} < 100)){
- $rows[$j]->{main::key($num++,0,3,'copied')} = ($row->{'copy-percent'} + 0) . '%';
+ $rows->[$j]{main::key($num++,0,3,'copied')} = ($row->{'copy-percent'} + 0) . '%';
}
if ($row->{'vg'}){
- $rows[$j]->{main::key($num++,1,3,'v-group')} = $row->{'vg'};
+ $rows->[$j]{main::key($num++,1,3,'v-group')} = $row->{'vg'};
}
$size = ($row->{'vg-size'}) ? main::get_size($row->{'vg-size'},'string') : 'N/A';
- $rows[$j]->{main::key($num++,0,4,'vg-size')} = $size;
+ $rows->[$j]{main::key($num++,0,4,'vg-size')} = $size;
$size = ($row->{'vg-free'}) ? main::get_size($row->{'vg-free'},'string') : 'N/A';
- $rows[$j]->{main::key($num++,0,4,'vg-free')} = $size;
+ $rows->[$j]{main::key($num++,0,4,'vg-free')} = $size;
}
@components = (ref $row->{'components'} eq 'ARRAY') ? @{$row->{'components'}} : ();
@good = ();
@@ -19204,43 +19959,43 @@ sub lvm_output {
push(@good, $item);
}
}
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,2,'Components')} = '';
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,2,'Components')} = '';
my $b_bump;
- components_output('lvm','Online',\@rows,\@good,\$j,\$num,\$b_bump);
- components_output('lvm','Meta',\@rows,\@components_meta,\$j,\$num,\$b_bump);
+ components_output('lvm','Online',$rows,\@good,\$j,\$num,\$b_bump);
+ components_output('lvm','Meta',$rows,\@components_meta,\$j,\$num,\$b_bump);
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
sub md_output {
eval $start if $b_log;
- my (@components,@good,@failed,@inactive,@rows,@spare,@temp);
+ my $rows = $_[0];
+ my (@components,@good,@failed,@inactive,@spare,@temp);
my ($blocks,$chunk,$level,$report,$size,$status);
my ($j,$num) = (0,0);
# print Data::Dumper::Dumper \@md_raid;
if ($extra > 2 && $md_raid[0]->{'supported-levels'}){
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,'Supported mdraid levels') => $md_raid[0]->{'supported-levels'},
});
}
foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @md_raid){
- $j = scalar @rows;
+ $j = scalar @$rows;
next if !%$row;
$num = 1;
$level = (defined $row->{'level'}) ? $row->{'level'} : 'linear';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $row->{'id'},
});
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
}
- $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'type'};
- $rows[$j]->{main::key($num++,0,2,'level')} = $level;
- $rows[$j]->{main::key($num++,0,2,'status')} = $row->{'status'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $row->{'type'};
+ $rows->[$j]{main::key($num++,0,2,'level')} = $level;
+ $rows->[$j]{main::key($num++,0,2,'status')} = $row->{'status'};
if ($row->{'details'}{'state'}){
- $rows[$j]->{main::key($num++,0,2,'state')} = $row->{'details'}{'state'};
+ $rows->[$j]{main::key($num++,0,2,'state')} = $row->{'details'}{'state'};
}
if ($row->{'size'}){
$size = main::get_size($row->{'size'},'string');
@@ -19248,33 +20003,33 @@ sub md_output {
else {
$size = (!$b_root && !@lsblk) ? main::message('root-required'): 'N/A';
}
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
$report = ($row->{'report'}) ? $row->{'report'}: '';
$report .= " $row->{'u-data'}" if $report;
$report ||= 'N/A';
if ($extra == 0){
# print "here 0\n";
- $rows[$j]->{main::key($num++,0,2,'report')} = $report;
+ $rows->[$j]{main::key($num++,0,2,'report')} = $report;
}
if ($extra > 0){
- $j = scalar @rows;
+ $j = scalar @$rows;
$num = 1;
- $rows[$j]->{main::key($num++,1,2,'Info')} = '';
- #$rows[$j]->{main::key($num++,0,3,'raid')} = $raid;
- $rows[$j]->{main::key($num++,0,3,'report')} = $report;
+ $rows->[$j]{main::key($num++,1,2,'Info')} = '';
+ #$rows->[$j]{main::key($num++,0,3,'raid')} = $raid;
+ $rows->[$j]{main::key($num++,0,3,'report')} = $report;
$blocks = ($row->{'blocks'}) ? $row->{'blocks'} : 'N/A';
- $rows[$j]->{main::key($num++,0,3,'blocks')} = $blocks;
+ $rows->[$j]{main::key($num++,0,3,'blocks')} = $blocks;
$chunk = ($row->{'chunk-size'}) ? $row->{'chunk-size'} : 'N/A';
- $rows[$j]->{main::key($num++,0,3,'chunk-size')} = $chunk;
+ $rows->[$j]{main::key($num++,0,3,'chunk-size')} = $chunk;
if ($extra > 1){
if ($row->{'bitmap'}){
- $rows[$j]->{main::key($num++,0,3,'bitmap')} = $row->{'bitmap'};
+ $rows->[$j]{main::key($num++,0,3,'bitmap')} = $row->{'bitmap'};
}
if ($row->{'super-block'}){
- $rows[$j]->{main::key($num++,0,3,'super-blocks')} = $row->{'super-block'};
+ $rows->[$j]{main::key($num++,0,3,'super-blocks')} = $row->{'super-block'};
}
if ($row->{'algorithm'}){
- $rows[$j]->{main::key($num++,0,3,'algorithm')} = $row->{'algorithm'};
+ $rows->[$j]{main::key($num++,0,3,'algorithm')} = $row->{'algorithm'};
}
}
}
@@ -19299,68 +20054,68 @@ sub md_output {
push(@good,$item);
}
}
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,2,'Components')} = '';
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,2,'Components')} = '';
my $b_bump;
- components_output('mdraid','Online',\@rows,\@good,\$j,\$num,\$b_bump);
- components_output('mdraid','Failed',\@rows,\@failed,\$j,\$num,\$b_bump);
- components_output('mdraid','Inactive',\@rows,\@inactive,\$j,\$num,\$b_bump);
- components_output('mdraid','Spare',\@rows,\@spare,\$j,\$num,\$b_bump);
+ components_output('mdraid','Online',$rows,\@good,\$j,\$num,\$b_bump);
+ components_output('mdraid','Failed',$rows,\@failed,\$j,\$num,\$b_bump);
+ components_output('mdraid','Inactive',$rows,\@inactive,\$j,\$num,\$b_bump);
+ components_output('mdraid','Spare',$rows,\@spare,\$j,\$num,\$b_bump);
if ($row->{'recovery-percent'}){
- $j = scalar @rows;
+ $j = scalar @$rows;
$num = 1;
my $percent = $row->{'recovery-percent'};
if ($extra > 1 && $row->{'progress-bar'}){
$percent .= " $row->{'progress-bar'}"
}
- $rows[$j]->{main::key($num++,1,2,'Recovering')} = $percent;
+ $rows->[$j]{main::key($num++,1,2,'Recovering')} = $percent;
my $finish = ($row->{'recovery-finish'})?$row->{'recovery-finish'} : 'N/A';
- $rows[$j]->{main::key($num++,0,3,'time-remaining')} = $finish;
+ $rows->[$j]{main::key($num++,0,3,'time-remaining')} = $finish;
if ($extra > 0){
if ($row->{'sectors-recovered'}){
- $rows[$j]->{main::key($num++,0,3,'sectors')} = $row->{'sectors-recovered'};
+ $rows->[$j]{main::key($num++,0,3,'sectors')} = $row->{'sectors-recovered'};
}
}
if ($extra > 1 && $row->{'recovery-speed'}){
- $rows[$j]->{main::key($num++,0,3,'speed')} = $row->{'recovery-speed'};
+ $rows->[$j]{main::key($num++,0,3,'speed')} = $row->{'recovery-speed'};
}
}
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
sub soft_output {
eval $start if $b_log;
- my (@components,@good,@failed,@rows,@offline,@rebuild,@temp);
+ my $rows = $_[0];
+ my (@components,@good,@failed,@offline,@rebuild,@temp);
my ($size);
my ($j,$num) = (0,0);
if (@soft_raid && $alerts{'bioctl'}->{'action'} eq 'permissions'){
- push(@rows,{
+ push(@$rows,{
main::key($num++,1,1,'Message') => main::message('root-item-incomplete','softraid'),
});
}
# print Data::Dumper::Dumper \@soft_raid;
foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @soft_raid){
- $j = scalar @rows;
+ $j = scalar @$rows;
next if !%$row;
$num = 1;
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $row->{'id'},
});
$row->{'level'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'type'};
- $rows[$j]->{main::key($num++,0,2,'level')} = $row->{'level'};
- $rows[$j]->{main::key($num++,0,2,'status')} = $row->{'status'};
+ $rows->[$j]{main::key($num++,0,2,'type')} = $row->{'type'};
+ $rows->[$j]{main::key($num++,0,2,'level')} = $row->{'level'};
+ $rows->[$j]{main::key($num++,0,2,'status')} = $row->{'status'};
if ($row->{'state'}){
- $rows[$j]->{main::key($num++,0,2,'state')} = $row->{'state'};
+ $rows->[$j]{main::key($num++,0,2,'state')} = $row->{'state'};
}
if ($row->{'size'}){
$size = main::get_size($row->{'size'},'string');
}
$size ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
@components = (ref $row->{'components'} eq 'ARRAY') ? @{$row->{'components'}} : ();
@good = ();
@failed = ();
@@ -19380,32 +20135,32 @@ sub soft_output {
push(@good,$item);
}
}
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,2,'Components')} = '';
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,2,'Components')} = '';
my $b_bump;
- components_output('softraid','Online',\@rows,\@good,\$j,\$num,\$b_bump);
- components_output('softraid','Failed',\@rows,\@failed,\$j,\$num,\$b_bump);
- components_output('softraid','Rebuild',\@rows,\@rebuild,\$j,\$num,\$b_bump);
- components_output('softraid','Offline',\@rows,\@offline,\$j,\$num,\$b_bump);
+ components_output('softraid','Online',$rows,\@good,\$j,\$num,\$b_bump);
+ components_output('softraid','Failed',$rows,\@failed,\$j,\$num,\$b_bump);
+ components_output('softraid','Rebuild',$rows,\@rebuild,\$j,\$num,\$b_bump);
+ components_output('softraid','Offline',$rows,\@offline,\$j,\$num,\$b_bump);
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
sub zfs_output {
eval $start if $b_log;
- my (@arrays,@arrays_holder,@components,@good,@failed,@rows,@spare);
+ my $rows = $_[0];
+ my (@arrays,@arrays_holder,@components,@good,@failed,@spare);
my ($allocated,$available,$level,$size,$status);
my ($b_row_1_sizes);
my ($j,$num) = (0,0);
# print Data::Dumper::Dumper \@zfs_raid;
foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @zfs_raid){
- $j = scalar @rows;
+ $j = scalar @$rows;
$b_row_1_sizes = 0;
next if !%$row;
$num = 1;
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Device') => $row->{'id'},
main::key($num++,0,2,'type') => $row->{'type'},
main::key($num++,0,2,'status') => $row->{'status'},
@@ -19421,43 +20176,43 @@ sub zfs_output {
my $count = scalar @arrays;
if (!defined $arrays[0]->{'level'}){
$level = 'linear';
- $rows[$j]->{main::key($num++,0,2,'level')} = $level;
+ $rows->[$j]{main::key($num++,0,2,'level')} = $level;
}
elsif ($count < 2 && $arrays[0]->{'level'}){
- $rows[$j]->{main::key($num++,0,2,'level')} = $arrays[0]->{'level'};
+ $rows->[$j]{main::key($num++,0,2,'level')} = $arrays[0]->{'level'};
}
if ($size || $available || $allocated){
- $rows[$j]->{main::key($num++,1,2,'raw')} = '';
+ $rows->[$j]{main::key($num++,1,2,'raw')} = '';
if ($size){
# print "here 0\n";
- $rows[$j]->{main::key($num++,0,3,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,3,'size')} = $size;
$size = '';
$b_row_1_sizes = 1;
}
if ($available){
- $rows[$j]->{main::key($num++,0,3,'free')} = $available;
+ $rows->[$j]{main::key($num++,0,3,'free')} = $available;
$available = '';
$b_row_1_sizes = 1;
}
if ($allocated){
- $rows[$j]->{main::key($num++,0,3,'allocated')} = $allocated;
+ $rows->[$j]{main::key($num++,0,3,'allocated')} = $allocated;
$allocated = '';
}
}
if ($row->{'zfs-size'}){
- $rows[$j]->{main::key($num++,1,2,'zfs-fs')} = '';
- $rows[$j]->{main::key($num++,0,3,'size')} = main::get_size($row->{'zfs-size'},'string');
- $rows[$j]->{main::key($num++,0,3,'free')} = main::get_size($row->{'zfs-free'},'string');
+ $rows->[$j]{main::key($num++,1,2,'zfs-fs')} = '';
+ $rows->[$j]{main::key($num++,0,3,'size')} = main::get_size($row->{'zfs-size'},'string');
+ $rows->[$j]{main::key($num++,0,3,'free')} = main::get_size($row->{'zfs-free'},'string');
}
foreach my $row2 (@arrays){
if ($count > 1){
- $j = scalar @rows;
+ $j = scalar @$rows;
$num = 1;
$size = ($row2->{'raw-size'}) ? main::get_size($row2->{'raw-size'},'string') : 'N/A';
$available = ($row2->{'raw-free'}) ? main::get_size($row2->{'raw-free'},'string') : 'N/A';
$level = (defined $row2->{'level'}) ? $row2->{'level'}: 'linear';
$status = ($row2->{'status'}) ? $row2->{'status'}: 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,2,'Array') => $level,
main::key($num++,0,3,'status') => $status,
main::key($num++,1,3,'raw') => '',
@@ -19470,13 +20225,13 @@ sub zfs_output {
# print "here $count\n";
$size = ($row2->{'raw-size'}) ? main::get_size($row2->{'raw-size'},'string') : 'N/A';
$available = ($row2->{'raw-free'}) ? main::get_size($row2->{'raw-free'},'string') : 'N/A';
- $rows[$j]->{main::key($num++,1,2,'raw')} = '';
- $rows[$j]->{main::key($num++,0,3,'size')} = $size;
- $rows[$j]->{main::key($num++,0,3,'free')} = $available;
+ $rows->[$j]{main::key($num++,1,2,'raw')} = '';
+ $rows->[$j]{main::key($num++,0,3,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,3,'free')} = $available;
if ($extra > 2){
$allocated = ($row->{'raw-allocated'}) ? main::get_size($row2->{'allocated'},'string') : '';
if ($allocated){
- $rows[$j]->{main::key($num++,0,3,'allocated')} = $allocated;
+ $rows->[$j]{main::key($num++,0,3,'allocated')} = $allocated;
}
}
}
@@ -19498,24 +20253,23 @@ sub zfs_output {
push(@good, $item);
}
}
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,3,'Components')} = '';
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,3,'Components')} = '';
my $b_bump;
- components_output('zfs','Online',\@rows,\@good,\$j,\$num,\$b_bump);
- components_output('zfs','Failed',\@rows,\@failed,\$j,\$num,\$b_bump);
- components_output('zfs','Available',\@rows,\@spare,\$j,\$num,\$b_bump);
+ components_output('zfs','Online',$rows,\@good,\$j,\$num,\$b_bump);
+ components_output('zfs','Failed',$rows,\@failed,\$j,\$num,\$b_bump);
+ components_output('zfs','Available',$rows,\@spare,\$j,\$num,\$b_bump);
}
}
eval $end if $b_log;
- # print Data::Dumper::Dumper \@rows;
- return @rows;
+ # print Data::Dumper::Dumper $rows;
}
## Most key stuff passed by ref, and is changed on the fly
sub components_output {
eval $start if $b_log;
- my ($type,$item,$rows_ref,$array_ref,$j_ref,$num_ref,$b_bump_ref) = @_;
- return if !@$array_ref && $item ne 'Online';
+ my ($type,$item,$rows,$array,$j,$num,$b_bump) = @_;
+ return if !@$array && $item ne 'Online';
my ($extra1,$extra2,$f1,$f2,$f3,$f4,$f5,$k,$k1,$key1,$l1,$l2,$l3);
if ($type eq 'btrfs'){
@@ -19541,37 +20295,37 @@ sub components_output {
$k = 1;
}
# print "item: $item\n";
- $$j_ref++ if $$b_bump_ref;
- $$b_bump_ref = 0;
- my $good = ($item eq 'Online' && !@$array_ref) ? 'N/A' : '';
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,1,$l1,$item)} = $good;
- #$$j_ref++ if $b_admin;
- # print Data::Dumper::Dumper $array_ref;
- foreach my $device (@$array_ref){
+ $$j++ if $$b_bump;
+ $$b_bump = 0;
+ my $good = ($item eq 'Online' && !@$array) ? 'N/A' : '';
+ $rows->[$$j]{main::key($$num++,1,$l1,$item)} = $good;
+ #$$j++ if $b_admin;
+ # print Data::Dumper::Dumper $array;
+ foreach my $device (@$array){
next if ref $device ne 'ARRAY';
# if ($b_admin && $device->[$f1] && $device->[$f2]){
if ($b_admin){
- $$j_ref++;
- $$b_bump_ref = 1;
- $$num_ref = 1;
+ $$j++;
+ $$b_bump = 1;
+ $$num = 1;
}
$key1 = (defined $k1 && defined $device->[$k1]) ? $device->[$k1] : $k++;
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,1,$l2,$key1)} = $device->[0];
+ $rows->[$$j]{main::key($$num++,1,$l2,$key1)} = $device->[0];
if ($b_admin && $device->[$f2]){
- $$rows_ref[$$j_ref]{main::key($$num_ref++,0,$l3,'maj-min')} = $device->[$f2];
+ $rows->[$$j]{main::key($$num++,0,$l3,'maj-min')} = $device->[$f2];
}
if ($b_admin && $device->[$f1]){
my $size = main::get_size($device->[$f1],'string');
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,'size')} = $size;
+ $rows->[$$j]{main::key($$num++,0,$l3,'size')} = $size;
}
if ($b_admin && $device->[$f3]){
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,'state')} = $device->[$f3];
+ $rows->[$$j]{main::key($$num++,0,$l3,'state')} = $device->[$f3];
}
if ($b_admin && $extra1 && $device->[$f4]){
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,$extra1)} = $device->[$f4];
+ $rows->[$$j]{main::key($$num++,0,$l3,$extra1)} = $device->[$f4];
}
if ($b_admin && $extra2 && $device->[$f5]){
- $$rows_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,$extra2)} = $device->[$f5];
+ $rows->[$$j]{main::key($$num++,0,$l3,$extra2)} = $device->[$f5];
}
}
eval $end if $b_log;
@@ -19619,7 +20373,7 @@ sub raid_data {
sub hw_data {
eval $start if $b_log;
return if !$devices{'hwraid'};
- my ($driver,$vendor,@hardware_raid);
+ my ($driver,$vendor,$hardware_raid);
foreach my $working (@{$devices{'hwraid'}}){
$driver = ($working->[9]) ? lc($working->[9]): '';
$driver =~ s/-/_/g if $driver;
@@ -19627,7 +20381,7 @@ sub hw_data {
if ($extra > 2 && $use{'pci-tool'} && $working->[11]){
$vendor = main::get_pci_vendor($working->[4],$working->[11]);
}
- push(@hardware_raid, {
+ push(@$hardware_raid, {
'class-id' => $working->[1],
'bus-id' => $working->[2],
'chip-id' => $working->[6],
@@ -19641,10 +20395,10 @@ sub hw_data {
'vendor' => $vendor,
});
}
- # print Data::Dumper::Dumper \@hardware_raid;
- main::log_data('dump','@hardware_raid',\@hardware_raid) if $b_log;
+ # print Data::Dumper::Dumper $hardware_raid;
+ main::log_data('dump','@$hardware_raid',$hardware_raid) if $b_log;
eval $end if $b_log;
- return @hardware_raid;
+ return $hardware_raid;
}
sub btrfs_data {
eval $start if $b_log;
@@ -19680,13 +20434,13 @@ sub lvm_data {
@working = main::globber("/sys/dev/block/$maj_min/slaves/*") if $maj_min;
@working = map {$_ =~ s|^/.*/||; $_;} @working if @working;
foreach my $part (@working){
- my (@data,$dev,$maj_min,$mapped,$size);
+ my ($dev,$maj_min,$mapped,$size);
if (@proc_partitions){
- @data = PartitionData::get($part);
- $maj_min = $data[0] . ':' . $data[1] if defined $data[1];
- $size = $data[2];
+ my $info = PartitionData::get($part);
+ $maj_min = $info->[0] . ':' . $info->[1] if defined $info->[1];
+ $size = $info->[2];
$raw_logical[1] += $size if $part =~ /^dm-/ && $size;
- @data = main::globber("/sys/dev/block/$maj_min/slaves/*") if $maj_min;
+ my @data = main::globber("/sys/dev/block/$maj_min/slaves/*") if $maj_min;
@data = map {$_ =~ s|^/.*/||; $_;} @data if @data;
$dev = join(',', @data) if @data;
}
@@ -19724,14 +20478,14 @@ sub md_data {
my ($mdstat) = @_;
my $j = 0;
if ($fake{'raid-md'}){
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-4-device-1.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-rebuild-1.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-2-mirror-fserver2-1.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-2-raid10-abucodonosor.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-2-raid10-ant.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-inactive-weird-syntax.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-inactive-active-syntax.txt";
- #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-inactive-active-spare-syntax.txt";
+ #$mdstat = "$fake_data_dir/raid/md-4-device-1.txt";
+ #$mdstat = "$fake_data_dir/raid/md-rebuild-1.txt";
+ #$mdstat = "$fake_data_dir/raid/md-2-mirror-fserver2-1.txt";
+ #$mdstat = "$fake_data_dir/raid/md-2-raid10-abucodonosor.txt";
+ #$mdstat = "$fake_data_dir/raid/md-2-raid10-ant.txt";
+ #$mdstat = "$fake_data_dir/raid/md-inactive-weird-syntax.txt";
+ #$mdstat = "$fake_data_dir/raid/md-inactive-active-syntax.txt";
+ #$mdstat = "$fake_data_dir/raid/md-inactive-active-spare-syntax.txt";
}
my @working = main::reader($mdstat,'strip');
# print Data::Dumper::Dumper \@working;
@@ -19756,8 +20510,8 @@ sub md_data {
# md1 : inactive sda1[0] sdd1[3] sdc1[2] sdb1[1]
# if (/^(md[0-9]+)\s*:\s*([^\s]+)(\s\([^)]+\))?\s([^\s]+)\s(.*)/){
if (/^(md[0-9]+)\s*:\s*([\S]+)(\s\([^)]+\))?/){
- my ($component_string,$id,$level,$maj_min,@part,$size,$status);
- my (@components,%details,%device);
+ my ($component_string,$details,$device,$id,$level,$maj_min,$part,$size,$status);
+ my (@components);
$id = $1;
$status = $2;
if (/^(md[0-9]+)\s*:\s*([\S]+)(\s\([^)]+\))?\s((faulty|linear|multipath|raid)[\S]*)\s(.*)/){
@@ -19774,20 +20528,20 @@ sub md_data {
@temp = ();
# cascade of tests, light to cpu intense
if ((!$maj_min || !$size) && @proc_partitions){
- @part = PartitionData::get($id);
- if (@part){
- $maj_min = $part[0] . ':' . $part[1];
- $size = $part[2];
+ $part = PartitionData::get($id);
+ if (@$part){
+ $maj_min = $part->[0] . ':' . $part->[1];
+ $size = $part->[2];
}
}
if ((!$maj_min || !$size) && @lsblk){
- %device = LsblkData::get($id) if @lsblk;
- $maj_min = $device{'maj-min'} if $device{'maj-min'};
- $size = $device{'size'} if $device{'size'};
+ $device = LsblkData::get($id) if @lsblk;
+ $maj_min = $device->{'maj-min'} if $device->{'maj-min'};
+ $size = $device->{'size'} if $device->{'size'};
}
if ((!$size || $b_admin) && $alerts{'mdadm'}->{'action'} eq 'use'){
- %details = md_details($id);
- $size = $details{'size'} if $details{'size'};
+ $details = md_details($id);
+ $size = $details->{'size'} if $details->{'size'};
}
$raw_logical[0] += $size if $size;
# remember, these include the [x] id, so remove that for disk/unmounted
@@ -19800,15 +20554,15 @@ sub md_data {
$name = $1;
}
next if !$name;
- if ($details{'devices'} && ref $details{'devices'} eq 'HASH'){
- $maj_min = $details{'devices'}->{$name}{'maj-min'};
- $state = $details{'devices'}->{$name}{'state'};
+ if ($details->{'devices'} && ref $details->{'devices'} eq 'HASH'){
+ $maj_min = $details->{'devices'}{$name}{'maj-min'};
+ $state = $details->{'devices'}{$name}{'state'};
}
if ((!$maj_min || !$part_size) && @proc_partitions){
- @part = PartitionData::get($name);
- if (@part){
- $maj_min = $part[0] . ':' . $part[1] if !$maj_min;
- $part_size = $part[2] if !$part_size;
+ $part = PartitionData::get($name);
+ if (@$part){
+ $maj_min = $part->[0] . ':' . $part->[1] if !$maj_min;
+ $part_size = $part->[2] if !$part_size;
}
}
if ((!$maj_min || !$part_size) && @lsblk){
@@ -19824,9 +20578,9 @@ sub md_data {
# print "$component_string\n";
$j = scalar @mdraid;
push(@mdraid, {
- 'chunk-size' => $details{'chunk-size'}, # if we got it, great, if not, further down
+ 'chunk-size' => $details->{'chunk-size'}, # if we got it, great, if not, further down
'components' => \@components,
- 'details' => \%details,
+ 'details' => $details,
'id' => $id,
'level' => $level,
'maj-min' => $maj_min,
@@ -19877,7 +20631,8 @@ sub md_data {
sub md_details {
eval $start if $b_log;
my ($id) = @_;
- my (%details,@working);
+ my (@working);
+ my $details = {};
my $cmd = $alerts{'mdadm'}->{'path'} . " --detail /dev/$id 2>/dev/null";
my @data = main::grabber($cmd,'','strip');
main::log_data('dump',"$id raw: \@data",\@data) if $b_log;
@@ -19885,37 +20640,37 @@ sub md_details {
@working = split(/\s*:\s*/, $_, 2);
if (scalar @working == 2){
if ($working[0] eq 'Array Size' && $working[1] =~ /^([0-9]+)\s\(/){
- $details{'size'} = $1;
+ $details->{'size'} = $1;
}
elsif ($working[0] eq 'Active Devices'){
- $details{'c-active'} = $working[1];
+ $details->{'c-active'} = $working[1];
}
elsif ($working[0] eq 'Chunk Size'){
- $details{'chunk-size'} = $working[1];
+ $details->{'chunk-size'} = $working[1];
}
elsif ($working[0] eq 'Failed Devices'){
- $details{'c-failed'} = $working[1];
+ $details->{'c-failed'} = $working[1];
}
elsif ($working[0] eq 'Raid Devices'){
- $details{'c-raid'} = $working[1];
+ $details->{'c-raid'} = $working[1];
}
elsif ($working[0] eq 'Spare Devices'){
- $details{'c-spare'} = $working[1];
+ $details->{'c-spare'} = $working[1];
}
elsif ($working[0] eq 'State'){
- $details{'state'} = $working[1];
+ $details->{'state'} = $working[1];
}
elsif ($working[0] eq 'Total Devices'){
- $details{'c-total'} = $working[1];
+ $details->{'c-total'} = $working[1];
}
elsif ($working[0] eq 'Used Dev Size' && $working[1] =~ /^([0-9]+)\s\(/){
- $details{'dev-size'} = $1;
+ $details->{'dev-size'} = $1;
}
elsif ($working[0] eq 'UUID'){
- $details{'uuid'} = $working[1];
+ $details->{'uuid'} = $working[1];
}
elsif ($working[0] eq 'Working Devices'){
- $details{'c-working'} = $working[1];
+ $details->{'c-working'} = $working[1];
}
}
# end component data lines
@@ -19925,7 +20680,7 @@ sub md_details {
# 2 8 128 - spare /dev/sdi
next if !@working || $working[0] eq 'Number' || scalar @working < 6;
$working[-1] =~ s|^/dev/(mapper/)?||;
- $details{'devices'}->{$working[-1]} = {
+ $details->{'devices'}{$working[-1]} = {
'maj-min' => $working[1] . ':' . $working[2],
'number' => $working[0],
'raid-device' => $working[3],
@@ -19933,10 +20688,10 @@ sub md_details {
};
}
}
- # print Data::Dumper::Dumper \%details;
- main::log_data('dump',"$id: %details",\%details) if $b_log;
+ # print Data::Dumper::Dumper $details;
+ main::log_data('dump',$id . ': %$details',$details) if $b_log;
eval $end if $b_log;
- return %details;
+ return $details;
}
sub soft_data {
@@ -20014,11 +20769,11 @@ sub zfs_data {
my ($i,$j,$k) = (0,0,0);
if ($fake{'raid-zfs'}){
# my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-list-1-mirror-main-solestar.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-list-2-mirror-main-solestar.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-list-v-tank-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-list-v-gojev-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-list-v-w-spares-1.txt";
+ # $file = "$fake_data_dir/raid/zpool-list-1-mirror-main-solestar.txt";
+ # $file = "$fake_data_dir/raid/zpool-list-2-mirror-main-solestar.txt";
+ # $file = "$fake_data_dir/raid/zpool-list-v-tank-1.txt";
+ # $file = "$fake_data_dir/raid/zpool-list-v-gojev-1.txt";
+ # $file = "$fake_data_dir/raid/zpool-list-v-w-spares-1.txt";
#@working = main::reader($file);$zpool = '';
}
else {
@@ -20150,20 +20905,20 @@ sub zfs_data {
$zfs[$j]->{'arrays'}[$k]{'free'} = $free;
}
if ((!$maj_min || !$part_size) && @proc_partitions){
- my @part = PartitionData::get($working);
- if (@part){
- $maj_min = $part[0] . ':' . $part[1];
- $part_size = $part[2];
+ my $part = PartitionData::get($working);
+ if (@$part){
+ $maj_min = $part->[0] . ':' . $part->[1];
+ $part_size = $part->[2];
}
}
if ((!$maj_min || !$part_size) && @lsblk){
- my %data= LsblkData::get($working);
- $maj_min = $data{'maj-min'};
- $part_size = $data{'size'};
+ my $data= LsblkData::get($working);
+ $maj_min = $data->{'maj-min'};
+ $part_size = $data->{'size'};
}
if (!$part_size && $bsd_type){
- my %temp = DiskDataBSD::get($working);
- $part_size = $temp{'size'} if $temp{'size'};
+ my $temp = DiskDataBSD::get($working);
+ $part_size = $temp->{'size'} if $temp->{'size'};
}
$raw_logical[1] += $part_size if $part_size;
$zfs[$j]->{'arrays'}[$k]{'components'}[$i] = [$working,$part_size,$maj_min,$state];
@@ -20216,9 +20971,9 @@ sub zfs_status {
$k = 0;
if ($fake{'raid-zfs'}){
my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-status-1-mirror-main-solestar.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-status-2-mirror-main-solestar.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/zpool-status-tank-1.txt";
+ # $file = "$fake_data_dir/raid/zpool-status-1-mirror-main-solestar.txt";
+ # $file = "$fake_data_dir/raid/zpool-status-2-mirror-main-solestar.txt";
+ # $file = "$fake_data_dir/raid/zpool-status-tank-1.txt";
#@pool_status = main::reader($file,'strip');
}
else {
@@ -20280,32 +21035,33 @@ sub check_zfs_status {
package RamItem;
my ($vendors,$vendor_ids);
sub get {
- my (@data,@rows,$key1,@ram,$val1);
+ my ($key1,$ram,$val1);
+ my $rows = [];
my $num = 0;
- @rows = MemoryData::full('ram') if !$loaded{'memory'};
+ push(@$rows, MemoryData::full('ram')) if !$loaded{'memory'};
if ($bsd_type && !$force{'dmidecode'} && ($dboot{'ram'} || $fake{'dboot'})){
- @ram = dboot_data();
- if (@ram){
- @data = ram_output(\@ram,'dboot');
+ $ram = dboot_data();
+ if (@$ram){
+ ram_output($rows,$ram,'dboot');
}
else {
$key1 = 'message';
$val1 = main::message('ram-data-dmidecode');
- @data = ({
+ push(@$rows, {
main::key($num++,1,1,'RAM Report') => '',
main::key($num++,0,2,$key1) => $val1,
});
}
}
elsif ($fake{'dmidecode'} || $alerts{'dmidecode'}->{'action'} eq 'use'){
- @ram = dmidecode_data();
- if (@ram){
- @data = ram_output(\@ram,'dmidecode');
+ $ram = dmidecode_data();
+ if (@$ram){
+ ram_output($rows,$ram,'dmidecode');
}
else {
$key1 = 'message';
$val1 = main::message('ram-data');
- @data = ({
+ push(@$rows, {
main::key($num++,1,1,'RAM Report') => '',
main::key($num++,0,2,$key1) => $val1,
});
@@ -20314,58 +21070,57 @@ sub get {
else {
$key1 = $alerts{'dmidecode'}->{'action'};
$val1 = $alerts{'dmidecode'}->{'message'};
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'RAM Report') => '',
main::key($num++,0,2,$key1) => $val1,
});
}
- push(@rows,@data);
($vendors,$vendor_ids) = ();
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub ram_output {
eval $start if $b_log;
- my ($ram,$source) = @_;
+ my ($rows,$ram,$source) = @_;
return if !@$ram;
my $num = 0;
my $j = 0;
- my (@rows,$b_non_system);
+ my ($b_non_system);
my ($arrays,$modules,$slots,$type_holder) = (0,0,0,'');
if ($source eq 'dboot'){
- push(@rows, {
+ push(@$rows, {
main::key($num++,0,1,'Message') => main::message('ram-data-complete'),
});
}
foreach my $item (@$ram){
- $j = scalar @rows;
+ $j = scalar @$rows;
if (!$show{'ram-short'}){
$b_non_system = ($item->{'use'} && lc($item->{'use'}) ne 'system memory') ? 1:0 ;
$num = 1;
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Array') => '',
main::key($num++,1,2,'capacity') => process_size($item->{'capacity'}),
});
if ($item->{'cap-qualifier'}){
- $rows[$j]->{main::key($num++,0,3,'note')} = $item->{'cap-qualifier'};
+ $rows->[$j]{main::key($num++,0,3,'note')} = $item->{'cap-qualifier'};
}
- $rows[$j]->{main::key($num++,0,2,'use')} = $item->{'use'} if $b_non_system;
- $rows[$j]->{main::key($num++,1,2,'slots')} = $item->{'slots'};
+ $rows->[$j]{main::key($num++,0,2,'use')} = $item->{'use'} if $b_non_system;
+ $rows->[$j]{main::key($num++,1,2,'slots')} = $item->{'slots'};
if ($item->{'slots-qualifier'}){
- $rows[$j]->{main::key($num++,0,3,'note')} = $item->{'slots-qualifier'};
+ $rows->[$j]{main::key($num++,0,3,'note')} = $item->{'slots-qualifier'};
}
$item->{'eec'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'EC')} = $item->{'eec'};
+ $rows->[$j]{main::key($num++,0,2,'EC')} = $item->{'eec'};
if ($extra > 0 && (!$b_non_system ||
(main::is_numeric($item->{'max-module-size'}) && $item->{'max-module-size'} > 10))){
- $rows[$j]->{main::key($num++,1,2,'max-module-size')} = process_size($item->{'max-module-size'});
+ $rows->[$j]{main::key($num++,1,2,'max-module-size')} = process_size($item->{'max-module-size'});
if ($item->{'mod-qualifier'}){
- $rows[$j]->{main::key($num++,0,3,'note')} = $item->{'mod-qualifier'};
+ $rows->[$j]{main::key($num++,0,3,'note')} = $item->{'mod-qualifier'};
}
}
if ($extra > 1 && $item->{'voltage'}){
- $rows[$j]->{main::key($num++,0,2,'voltage')} = $item->{'voltage'};
+ $rows->[$j]{main::key($num++,0,2,'voltage')} = $item->{'voltage'};
}
}
else {
@@ -20377,7 +21132,7 @@ sub ram_output {
# print Data::Dumper::Dumper $entry;
foreach my $mod (@$entry){
$num = 1;
- $j = scalar @rows;
+ $j = scalar @$rows;
# multi array setups will start index at next from previous array
next if ref $mod ne 'HASH';
if ($show{'ram-short'}){
@@ -20387,31 +21142,31 @@ sub ram_output {
}
next if ($show{'ram-modules'} && $mod->{'size'} =~ /\D/);
$mod->{'locator'} ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,2,'Device') => $mod->{'locator'},
});
# this will contain the no module string
if ($mod->{'size'} =~ /\D/){
- $rows[$j]->{main::key($num++,0,3,'type')} = lc($mod->{'size'});
+ $rows->[$j]{main::key($num++,0,3,'type')} = lc($mod->{'size'});
next;
}
if ($extra > 1 && $mod->{'type'}){
- $rows[$j]->{main::key($num++,0,3,'info')} = $mod->{'type'};
+ $rows->[$j]{main::key($num++,0,3,'info')} = $mod->{'type'};
}
$mod->{'device-type'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,3,'type')} = $mod->{'device-type'};
+ $rows->[$j]{main::key($num++,1,3,'type')} = $mod->{'device-type'};
if ($extra > 2 && $mod->{'device-type'} ne 'N/A'){
$mod->{'device-type-detail'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,4,'detail')} = $mod->{'device-type-detail'};
+ $rows->[$j]{main::key($num++,0,4,'detail')} = $mod->{'device-type-detail'};
}
- $rows[$j]->{main::key($num++,0,3,'size')} = process_size($mod->{'size'});
+ $rows->[$j]{main::key($num++,0,3,'size')} = process_size($mod->{'size'});
if ($mod->{'speed'} && $mod->{'configured-clock-speed'} &&
$mod->{'speed'} ne $mod->{'configured-clock-speed'}){
- $rows[$j]->{main::key($num++,1,3,'speed')} = '';
- $rows[$j]->{main::key($num++,0,4,'spec')} = $mod->{'speed'};
- $rows[$j]->{main::key($num++,0,4,'note')} = $mod->{'speed-note'} if $mod->{'speed-note'};
- $rows[$j]->{main::key($num++,0,4,'actual')} = $mod->{'configured-clock-speed'};
- $rows[$j]->{main::key($num++,0,5,'note')} = $mod->{'configured-note'} if $mod->{'configured-note'};
+ $rows->[$j]{main::key($num++,1,3,'speed')} = '';
+ $rows->[$j]{main::key($num++,0,4,'spec')} = $mod->{'speed'};
+ $rows->[$j]{main::key($num++,0,4,'note')} = $mod->{'speed-note'} if $mod->{'speed-note'};
+ $rows->[$j]{main::key($num++,0,4,'actual')} = $mod->{'configured-clock-speed'};
+ $rows->[$j]{main::key($num++,0,5,'note')} = $mod->{'configured-note'} if $mod->{'configured-note'};
}
else {
if (!$mod->{'speed'} && $mod->{'configured-clock-speed'}){
@@ -20422,8 +21177,8 @@ sub ram_output {
}
# rare instances, dmi type 6, no speed, dboot also no speed
$mod->{'speed'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,3,'speed')} = $mod->{'speed'};
- $rows[$j]->{main::key($num++,0,4,'note')} = $mod->{'speed-note'} if $mod->{'speed-note'};
+ $rows->[$j]{main::key($num++,1,3,'speed')} = $mod->{'speed'};
+ $rows->[$j]{main::key($num++,0,4,'note')} = $mod->{'speed-note'} if $mod->{'speed-note'};
}
# handle cases where -xx or -xxx and no voltage data (common) or voltages
# are all the same.
@@ -20437,43 +21192,43 @@ sub ram_output {
($mod->{'voltage-min'} && $mod->{'voltage-max'} &&
$mod->{'voltage-max'} ne $mod->{'voltage-min'})
))){
- $rows[$j]->{main::key($num++,1,3,'volts')} = '';
+ $rows->[$j]{main::key($num++,1,3,'volts')} = '';
if ($mod->{'voltage-config'}){
- $rows[$j]->{main::key($num++,0,4,'curr')} = $mod->{'voltage-config'};
+ $rows->[$j]{main::key($num++,0,4,'curr')} = $mod->{'voltage-config'};
}
if ($mod->{'voltage-min'}){
- $rows[$j]->{main::key($num++,0,4,'min')} = $mod->{'voltage-min'};
+ $rows->[$j]{main::key($num++,0,4,'min')} = $mod->{'voltage-min'};
}
if ($mod->{'voltage-max'}){
- $rows[$j]->{main::key($num++,0,4,'max')} = $mod->{'voltage-max'};
+ $rows->[$j]{main::key($num++,0,4,'max')} = $mod->{'voltage-max'};
}
}
else {
$mod->{'voltage-config'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'volts')} = $mod->{'voltage-config'};
+ $rows->[$j]{main::key($num++,0,3,'volts')} = $mod->{'voltage-config'};
}
}
if ($source ne 'dboot' && $extra > 2){
if (!$mod->{'data-width'} && !$mod->{'total-width'}){
- $rows[$j]->{main::key($num++,0,3,'width')} = 'N/A';
+ $rows->[$j]{main::key($num++,0,3,'width')} = 'N/A';
}
else {
- $rows[$j]->{main::key($num++,1,3,'width (bits)')} = '';
+ $rows->[$j]{main::key($num++,1,3,'width (bits)')} = '';
$mod->{'data-width'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,4,'data')} = $mod->{'data-width'};
+ $rows->[$j]{main::key($num++,0,4,'data')} = $mod->{'data-width'};
$mod->{'total-width'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,4,'total')} = $mod->{'total-width'};
+ $rows->[$j]{main::key($num++,0,4,'total')} = $mod->{'total-width'};
}
}
if ($source ne 'dboot' && $extra > 1){
$mod->{'manufacturer'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'manufacturer')} = $mod->{'manufacturer'};
+ $rows->[$j]{main::key($num++,0,3,'manufacturer')} = $mod->{'manufacturer'};
$mod->{'part-number'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,3,'part-no')} = $mod->{'part-number'};
+ $rows->[$j]{main::key($num++,0,3,'part-no')} = $mod->{'part-number'};
}
if ($source ne 'dboot' && $extra > 2){
$mod->{'serial'} = main::filter($mod->{'serial'});
- $rows[$j]->{main::key($num++,0,3,'serial')} = $mod->{'serial'};
+ $rows->[$j]{main::key($num++,0,3,'serial')} = $mod->{'serial'};
}
}
}
@@ -20481,7 +21236,7 @@ sub ram_output {
if ($show{'ram-short'}){
$num = 1;
$type_holder ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Report') => '',
main::key($num++,0,2,'arrays') => $arrays,
main::key($num++,0,2,'slots') => $slots,
@@ -20490,14 +21245,14 @@ sub ram_output {
});
}
eval $end if $b_log;
- return @rows;
}
sub dmidecode_data {
eval $start if $b_log;
- my ($b_5,$handle,@ram,@temp);
+ my ($b_5,$handle,@temp);
my ($derived_module_size,$max_cap_5,$max_cap_16,$max_module_size) = (0,0,0,0);
my ($i,$j,$k) = (0,0,0);
+ my $ram = [];
my $check = main::message('note-check');
# print Data::Dumper::Dumper \@dmi;
foreach my $entry (@dmi){
@@ -20509,25 +21264,25 @@ sub dmidecode_data {
next if !$temp[1];
if ($temp[0] eq 'Maximum Memory Module Size'){
$max_module_size = calculate_size($temp[1],$max_module_size);
- $ram[$k]->{'max-module-size'} = $max_module_size;
+ $ram->[$k]{'max-module-size'} = $max_module_size;
}
elsif ($temp[0] eq 'Maximum Total Memory Size'){
$max_cap_5 = calculate_size($temp[1],$max_cap_5);
- $ram[$k]->{'max-capacity-5'} = $max_cap_5;
+ $ram->[$k]{'max-capacity-5'} = $max_cap_5;
}
elsif ($temp[0] eq 'Memory Module Voltage'){
$temp[1] =~ s/\s*V.*$//; # seen: 5.0 V 3.3 V
- $ram[$k]->{'voltage'} = $temp[1];
+ $ram->[$k]{'voltage'} = $temp[1];
}
elsif ($temp[0] eq 'Associated Memory Slots'){
- $ram[$k]->{'slots-5'} = $temp[1];
+ $ram->[$k]{'slots-5'} = $temp[1];
}
elsif ($temp[0] eq 'Error Detecting Method'){
$temp[1] ||= 'None';
- $ram[$k]->{'eec'} = $temp[1];
+ $ram->[$k]{'eec'} = $temp[1];
}
}
- $ram[$k]->{'modules'} = [];
+ $ram->[$k]{'modules'} = [];
# print Data::Dumper::Dumper \@ram;
$b_5 = 1;
}
@@ -20542,8 +21297,8 @@ sub dmidecode_data {
$size = calculate_size($temp[1],0);
# using this causes issues, really only works for 16
# if ($size =~ /^[0-9][0-9]+$/){
-# $ram[$k]->{'device-count-found'}++;
-# $ram[$k]->{'used-capacity'} += $size;
+# $ram->[$k]{'device-count-found'}++;
+# $ram->[$k]{'used-capacity'} += $size;
# }
# get data after module size
$temp[1] =~ s/ Connection\)?//;
@@ -20573,7 +21328,7 @@ sub dmidecode_data {
else {
$main_locator = $locator;
}
- $ram[$k]->{'modules'}[$j] = {
+ $ram->[$k]{'modules'}[$j] = {
'device-type' => $device_type,
'locator' => $main_locator,
'size' => $size,
@@ -20585,39 +21340,39 @@ sub dmidecode_data {
}
elsif ($entry->[0] == 16){
$handle = $entry->[1];
- $ram[$handle] = $ram[$k] if $ram[$k];
- $ram[$k] = undef;
+ $ram->[$handle] = $ram->[$k] if $ram->[$k];
+ $ram->[$k] = undef;
# ($derived_module_size,$max_cap_16) = (0,0);
foreach my $item (@$entry){
@temp = split(/:\s*/, $item, 2);
next if !$temp[1];
if ($temp[0] eq 'Maximum Capacity'){
$max_cap_16 = calculate_size($temp[1],$max_cap_16);
- $ram[$handle]->{'max-capacity-16'} = $max_cap_16;
+ $ram->[$handle]{'max-capacity-16'} = $max_cap_16;
}
# note: these 3 have cleaned data in DmiData, so replace stuff manually
elsif ($temp[0] eq 'Location'){
$temp[1] =~ s/\sOr\sMotherboard//;
$temp[1] ||= 'System Board';
- $ram[$handle]->{'location'} = $temp[1];
+ $ram->[$handle]{'location'} = $temp[1];
}
elsif ($temp[0] eq 'Use'){
$temp[1] ||= 'System Memory';
- $ram[$handle]->{'use'} = $temp[1];
+ $ram->[$handle]{'use'} = $temp[1];
}
elsif ($temp[0] eq 'Error Correction Type'){
$temp[1] ||= 'None';
- $ram[$handle]->{'eec'} = $temp[1];
+ $ram->[$handle]{'eec'} = $temp[1];
}
elsif ($temp[0] eq 'Number Of Devices'){
- $ram[$handle]->{'slots-16'} = $temp[1];
+ $ram->[$handle]{'slots-16'} = $temp[1];
}
# print "0: $temp[0]\n";
}
- $ram[$handle]->{'derived-module-size'} = 0;
- $ram[$handle]->{'device-count-found'} = 0;
- $ram[$handle]->{'used-capacity'} = 0;
- # print "s16: $ram[$handle]->{'slots-16'}\n";
+ $ram->[$handle]{'derived-module-size'} = 0;
+ $ram->[$handle]{'device-count-found'} = 0;
+ $ram->[$handle]{'used-capacity'} = 0;
+ # print "s16: $ram->[$handle]{'slots-16'}\n";
}
elsif ($entry->[0] == 17){
my ($bank_locator,$configured_speed,$configured_note,
@@ -20673,12 +21428,14 @@ sub dmidecode_data {
$device_type_detail = main::clean_dmi($temp[1]);
}
elsif ($temp[0] eq 'Speed'){
- ($speed,$speed_note) = process_speed($temp[1],$device_type,$check);
+ my $result = process_speed($temp[1],$device_type,$check);
+ ($speed,$speed_note) = @$result;
}
# this is the actual speed the system booted at, speed is hardcoded
# clock speed means MHz, memory speed MT/S
elsif ($temp[0] eq 'Configured Clock Speed' || $temp[0] eq 'Configured Memory Speed'){
- ($configured_speed,$configured_note) = process_speed($temp[1],$device_type,$check);
+ my $result = process_speed($temp[1],$device_type,$check);
+ ($configured_speed,$configured_note) = @$result;
}
elsif ($temp[0] eq 'Manufacturer'){
$temp[1] = main::clean_dmi($temp[1]);
@@ -20716,9 +21473,9 @@ sub dmidecode_data {
$main_locator = $locator;
}
if ($working_size =~ /^[0-9][0-9]+$/){
- $ram[$handle]->{'device-count-found'}++;
+ $ram->[$handle]{'device-count-found'}++;
# build up actual capacity found for override tests
- $ram[$handle]->{'used-capacity'} += $working_size;
+ $ram->[$handle]{'used-capacity'} += $working_size;
}
# sometimes the data is just wrong, they reverse total/data. data I believe is
# used for the actual memory bus width, total is some synthetic thing, sometimes missing.
@@ -20737,35 +21494,35 @@ sub dmidecode_data {
$vendor_id = lc($1) if $1;
}
if ((!$manufacturer || $vendor_id) && $part_number){
- my @result = ram_vendor($part_number);
- $manufacturer = $result[0] if $result[0];
- $part_number = $result[1] if $result[1];
+ my $result = ram_vendor($part_number);
+ $manufacturer = $result->[0] if $result->[0];
+ $part_number = $result->[1] if $result->[1];
}
if ($vendor_id && !$manufacturer){
- set_vendor_ids() if !$vendor_ids;
+ set_ram_vendor_ids() if !$vendor_ids;
if ($vendor_ids->{$vendor_id}){
$manufacturer = $vendor_ids->{$vendor_id};
}
}
- $ram[$handle]->{'derived-module-size'} = $derived_module_size;
- $ram[$handle]->{'modules'}[$i]{'configured-clock-speed'} = $configured_speed;
- $ram[$handle]->{'modules'}[$i]{'configured-note'} = $configured_note if $configured_note;
- $ram[$handle]->{'modules'}[$i]{'data-width'} = $data_width;
- $ram[$handle]->{'modules'}[$i]{'size'} = $device_size;
- $ram[$handle]->{'modules'}[$i]{'device-type'} = $device_type;
- $ram[$handle]->{'modules'}[$i]{'device-type-detail'} = lc($device_type_detail);
- $ram[$handle]->{'modules'}[$i]{'form-factor'} = $form_factor;
- $ram[$handle]->{'modules'}[$i]{'locator'} = $main_locator;
- $ram[$handle]->{'modules'}[$i]{'manufacturer'} = $manufacturer;
- $ram[$handle]->{'modules'}[$i]{'vendor-id'} = $vendor_id;
- $ram[$handle]->{'modules'}[$i]{'part-number'} = $part_number;
- $ram[$handle]->{'modules'}[$i]{'serial'} = $serial;
- $ram[$handle]->{'modules'}[$i]{'speed'} = $speed;
- $ram[$handle]->{'modules'}[$i]{'speed-note'} = $speed_note if $speed_note;
- $ram[$handle]->{'modules'}[$i]{'total-width'} = $total_width;
- $ram[$handle]->{'modules'}[$i]{'voltage-config'} = $voltage_config;
- $ram[$handle]->{'modules'}[$i]{'voltage-max'} = $voltage_max;
- $ram[$handle]->{'modules'}[$i]{'voltage-min'} = $voltage_min;
+ $ram->[$handle]{'derived-module-size'} = $derived_module_size;
+ $ram->[$handle]{'modules'}[$i]{'configured-clock-speed'} = $configured_speed;
+ $ram->[$handle]{'modules'}[$i]{'configured-note'} = $configured_note if $configured_note;
+ $ram->[$handle]{'modules'}[$i]{'data-width'} = $data_width;
+ $ram->[$handle]{'modules'}[$i]{'size'} = $device_size;
+ $ram->[$handle]{'modules'}[$i]{'device-type'} = $device_type;
+ $ram->[$handle]{'modules'}[$i]{'device-type-detail'} = lc($device_type_detail);
+ $ram->[$handle]{'modules'}[$i]{'form-factor'} = $form_factor;
+ $ram->[$handle]{'modules'}[$i]{'locator'} = $main_locator;
+ $ram->[$handle]{'modules'}[$i]{'manufacturer'} = $manufacturer;
+ $ram->[$handle]{'modules'}[$i]{'vendor-id'} = $vendor_id;
+ $ram->[$handle]{'modules'}[$i]{'part-number'} = $part_number;
+ $ram->[$handle]{'modules'}[$i]{'serial'} = $serial;
+ $ram->[$handle]{'modules'}[$i]{'speed'} = $speed;
+ $ram->[$handle]{'modules'}[$i]{'speed-note'} = $speed_note if $speed_note;
+ $ram->[$handle]{'modules'}[$i]{'total-width'} = $total_width;
+ $ram->[$handle]{'modules'}[$i]{'voltage-config'} = $voltage_config;
+ $ram->[$handle]{'modules'}[$i]{'voltage-max'} = $voltage_max;
+ $ram->[$handle]{'modules'}[$i]{'voltage-min'} = $voltage_min;
$i++
}
elsif ($entry->[0] < 17){
@@ -20775,17 +21532,17 @@ sub dmidecode_data {
last;
}
}
- print Data::Dumper::Dumper \@ram if $dbg[36];
- main::log_data('dump','@ram',\@ram) if $b_log;
- @ram = process_data(\@ram) if @ram;
- main::log_data('dump','@ram',\@ram) if $b_log;
- print Data::Dumper::Dumper \@ram if $dbg[36];
+ print Data::Dumper::Dumper $ram if $dbg[36];
+ main::log_data('dump','@$ram',$ram) if $b_log;
+ process_data($ram) if @$ram;
+ main::log_data('dump','@$ram',$ram) if $b_log;
+ print Data::Dumper::Dumper $ram if $dbg[36];
eval $end if $b_log;
- return @ram;
+ return $ram;
}
sub dboot_data {
eval $start if $b_log;
- my (@ram);
+ my $ram = [];
my $est = main::message('note-est');
my ($arr,$derived_module_size,$subtract) = (0,0,0);
my ($holder);
@@ -20798,8 +21555,8 @@ sub dboot_data {
$holder = $iic if !defined $holder; # prime for first use
# note: seen iic2 as only device
if ($iic != $holder){
- if ($ram[$arr] && $ram[$arr]->{'slots-16'}){
- $subtract += $ram[$arr]->{'slots-16'};
+ if ($ram->[$arr] && $ram->[$arr]{'slots-16'}){
+ $subtract += $ram->[$arr]{'slots-16'};
}
$holder = $iic;
# then since we are on a new iic device, assume new ram array.
@@ -20830,19 +21587,19 @@ sub dboot_data {
$size = main::translate_size($1)/1024;
$type = $2;
if ($addr){
- $ram[$arr]->{'slots-16'} = $addr - 80 + 1 - $subtract;
- $locator = 'Slot-' . $ram[$arr]->{'slots-16'};
+ $ram->[$arr]{'slots-16'} = $addr - 80 + 1 - $subtract;
+ $locator = 'Slot-' . $ram->[$arr]{'slots-16'};
}
- $ram[$arr]->{'device-count-found'}++;
+ $ram->[$arr]{'device-count-found'}++;
# build up actual capacity found for override tests
- $ram[$arr]->{'max-capacity-16'} += $size;
- $ram[$arr]->{'max-cap-qualifier'} = $est;
- $ram[$arr]->{'slots-16'}++ if !$addr;
+ $ram->[$arr]{'max-capacity-16'} += $size;
+ $ram->[$arr]{'max-cap-qualifier'} = $est;
+ $ram->[$arr]{'slots-16'}++ if !$addr;
$derived_module_size = $size if $size > $derived_module_size;
- $ram[$arr]->{'slots-qualifier'} = $est;
- $ram[$arr]->{'eec'} = $ecc;
- $ram[$arr]->{'derived-module-size'} = $derived_module_size;
- push(@{$ram[$arr]->{'modules'}},{
+ $ram->[$arr]{'slots-qualifier'} = $est;
+ $ram->[$arr]{'eec'} = $ecc;
+ $ram->[$arr]{'derived-module-size'} = $derived_module_size;
+ push(@{$ram->[$arr]{'modules'}},{
'device-type' => $type,
'device-type-detail' => $detail,
'locator' => $locator,
@@ -20852,26 +21609,26 @@ sub dboot_data {
}
}
}
- for (my $i = 0; $i++ ;scalar @ram){
- next if ref $ram[$i] ne 'HASH';
+ for (my $i = 0; $i++ ;scalar @$ram){
+ next if ref $ram->[$i] ne 'HASH';
# 1 slot is possible, but 3 is very unlikely due to dual channel ddr
- if ($ram[$i]->{'slots'} && $ram[$i]->{'slots'} > 2 && $ram[$i]->{'slots'} % 2 == 1){
- $ram[$i]->{'slots'}++;
+ if ($ram->[$i]{'slots'} && $ram->[$i]{'slots'} > 2 && $ram->[$i]{'slots'} % 2 == 1){
+ $ram->[$i]{'slots'}++;
}
}
- print Data::Dumper::Dumper \@ram if $dbg[36];
- main::log_data('dump','@ram',\@ram) if $b_log;
- @ram = process_data(\@ram) if @ram;
- main::log_data('dump','@ram',\@ram) if $b_log;
- print Data::Dumper::Dumper \@ram if $dbg[36];
+ print Data::Dumper::Dumper $ram if $dbg[36];
+ main::log_data('dump','@$ram',$ram) if $b_log;
+ process_data($ram) if @$ram;
+ main::log_data('dump','@$ram',$ram) if $b_log;
+ print Data::Dumper::Dumper $ram if $dbg[36];
eval $end if $b_log;
- return @ram;
+ return $ram;
}
sub process_data {
eval $start if $b_log;
- my ($ram) = @_;
+ my $ram = $_[0];
+ my @result;
my $b_debug = 0;
- my (@return);
my $check = main::message('note-check');
my $est = main::message('note-est');
foreach my $item (@$ram){
@@ -21025,7 +21782,7 @@ sub process_data {
$est_slots = $item->{'slots-qualifier'};
$est_cap = $est;
}
- push(@return, {
+ push(@result, {
'capacity' => $max_cap,
'cap-qualifier' => $est_cap,
'eec' => $item->{'eec'},
@@ -21041,8 +21798,8 @@ sub process_data {
'voltage-min' => $item->{'voltage-min'},
});
}
+ @$ram = @result;
eval $end if $b_log;
- return @return;
}
sub process_speed {
my ($speed,$device_type,$check) = @_;
@@ -21056,7 +21813,7 @@ sub process_speed {
if ($speed && $speed =~ /^([0-9]+)\s*M/){
$speed_note = $check if $1 < 50 || $1 > 20000 ;
}
- return ($speed,$speed_note);
+ return [$speed,$speed_note];
}
# this should be fixed, but for now, size in RAM is in MiB, not
# KiB like the rest of inxi.
@@ -21137,7 +21894,8 @@ sub speed_mapper {
);
return ($speeds{$type}) ? $speeds{$type} . ' MT/s' : $type;
}
-sub set_vendors {
+## START RAM VENDOR ##
+sub set_ram_vendors {
$vendors = [
# A-Data xpg: AX4U; AX\d{4} for axiom
['^(A[DX]\dU|AVD|A[\s-]?Data)','A[\s-]?Data','A-Data',''],
@@ -21185,7 +21943,7 @@ sub set_vendors {
];
}
# note: many of these are pci ids, not confirmed valid for ram
-sub set_vendor_ids {
+sub set_ram_vendor_ids {
$vendor_ids = {
'01f4' => 'Transcend',# confirmed
'02fe' => 'Elpida',# confirmed
@@ -21218,11 +21976,12 @@ sub set_vendor_ids {
# '' => '',
}
}
+## END RAM VENDOR ##
sub ram_vendor {
eval $end if $b_log;
my ($id) = $_[0];
- set_vendors() if !$vendors;
- my ($vendor,@data);
+ set_ram_vendors() if !$vendors;
+ my ($vendor);
foreach my $row (@$vendors){
if ($id =~ /$row->[0]/i){
$vendor = $row->[2];
@@ -21237,12 +21996,11 @@ sub ram_vendor {
}
$id =~ s/^[\/\[\s_-]+|[\/\s_-]+$//g;
$id =~ s/\s\s/ /g;
- @data = ($vendor,$id);
last;
}
}
eval $end if $b_log;
- return @data;
+ return [$vendor,$id];
}
}
@@ -21256,28 +22014,28 @@ my $num = 0;
sub get {
eval $start if $b_log;
($debugger_dir) = @_;
- my (@data,@rows,@rows_p,@rows_r);
+ my $rows = [];
if ($extra > 0 && !$loaded{'package-data'}){
- my %packages = PackageData::get('main',\$num);
- my @data;
- for (keys %packages){
- $rows_p[0]->{$_} = $packages{$_};
+ my $packages = PackageData::get('main',\$num);
+ for (keys %$packages){
+ $rows->[0]{$_} = $packages->{$_};
}
}
+ my $start = scalar @$rows; # to test if we found more rows after
$num = 0;
if ($bsd_type){
- @rows_r = get_repos_bsd();
+ get_repos_bsd($rows);
}
else {
- @rows_r = get_repos_linux();
+ get_repos_linux($rows);
}
if ($debugger_dir){
- @rows = @dbg_files;
+ @$rows = @dbg_files;
undef @dbg_files;
undef $debugger_dir;
}
else {
- if (!@rows_r){
+ if ($start == scalar @$rows){
my $pm_missing;
if ($bsd_type){
$pm_missing = main::message('repo-data-bsd',$uname[0]);
@@ -21285,16 +22043,16 @@ sub get {
else {
$pm_missing = main::message('repo-data');
}
- @data = ({main::key($num++,0,1,'Alert') => $pm_missing});
+ push(@$rows,{main::key($num++,0,1,'Alert') => $pm_missing});
}
- @rows = (@rows_p,@rows_r,@data);
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub get_repos_linux {
eval $start if $b_log;
- my (@content,@data,@data2,@data3,@files,$repo,@repos,@rows);
+ my $rows = $_[0];
+ my (@content,$data,@data2,@data3,@files,$repo,@repos);
my ($key,$path);
my $apk = '/etc/apk/repositories';
my $apt = '/etc/apt/sources.list';
@@ -21334,10 +22092,10 @@ sub get_repos_linux {
main::log_data('data',"apt repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log;
foreach (sort @files){
# altlinux/pclinuxos use rpms in apt files
- @data = repo_builder($_,'apt','^\s*(deb|rpm)') if -r $_;
- push(@rows,@data);
+ $data = repo_builder($_,'apt','^\s*(deb|rpm)') if -r $_;
+ push(@$rows,@$data);
}
- #@files = main::globber("$ENV{'HOME'}/bin/scripts/inxi/data/repo/apt/*.sources");
+ #@files = main::globber("$fake_data_dir/repo/apt/*.sources");
@files = main::globber("$apt.d/*.sources");
main::log_data('data',"apt deb822 repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log;
foreach $file (@files){
@@ -21416,7 +22174,7 @@ sub get_repos_linux {
else {
$key = repo_data('missing','apt');
}
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $file},
[@apt_urls],
);
@@ -21446,20 +22204,20 @@ sub get_repos_linux {
unshift(@files, $pacman) if @repos;
foreach (@files){
if (-f $_){
- @data = repo_builder($_,$repo,'^\s*Server','\s*=\s*',1);
- push(@rows,@data);
+ $data = repo_builder($_,$repo,'^\s*Server','\s*=\s*',1);
+ push(@$rows,@$data);
}
else {
# set it so the debugger knows the file wasn't there
push(@dbg_files, $_) if $debugger_dir;
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,'File listed in') => $pacman},
[("$_ does not seem to exist.")],
);
}
}
- if (!@rows){
- push(@rows,
+ if (!@$rows){
+ push(@$rows,
{main::key($num++,0,1,repo_data('missing','files')) => $pacman },
);
}
@@ -21468,21 +22226,20 @@ sub get_repos_linux {
if (-f $slackpkg || -f $slackpkg_plus || -d $slapt_get){
#$slackpkg = "$ENV{HOME}/bin/scripts/inxi/data/repo/slackware/slackpkg-2.conf";
if (-f $slackpkg){
- @data = repo_builder($slackpkg,'slackpkg','^[[:space:]]*[^#]+');
- push(@rows,@data);
+ $data = repo_builder($slackpkg,'slackpkg','^[[:space:]]*[^#]+');
+ push(@$rows,@$data);
}
if (-d $slapt_get){
@data2 = main::globber("${slapt_get}*");
foreach my $file (@data2){
- @data = repo_builder($file,'slaptget','^\s*SOURCE','\s*=\s*',1);
- push(@rows,@data);
+ $data = repo_builder($file,'slaptget','^\s*SOURCE','\s*=\s*',1);
+ push(@$rows,@$data);
}
}
if (-f $slackpkg_plus){
push(@dbg_files, $slackpkg_plus) if $debugger_dir;
- @data = main::reader($slackpkg_plus,'strip');
my (@repoplus_list,$active_repos);
- foreach my $row (@data){
+ foreach my $row (main::reader($slackpkg_plus,'strip')){
@data2 = split(/\s*=\s*/, $row);
@data2 = map { $_ =~ s/^\s+|\s+$//g ; $_ } @data2;
last if $data2[0] =~ /^SLACKPKGPLUS/i && $data2[1] eq 'off';
@@ -21508,12 +22265,12 @@ sub get_repos_linux {
clean_url(\@content);
$key = repo_data('active','slackpkg+');
}
- @data = (
+ my @data = (
{main::key($num++,1,1,$key) => $slackpkg_plus},
[@content],
);
clean_url(\@data);
- push(@rows,@data);
+ push(@$rows,@data);
@content = ();
}
}
@@ -21529,7 +22286,7 @@ sub get_repos_linux {
push(@files, main::globber("$zypp_repo_dir*.repo"));
main::log_data('data',"zypp repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log;
}
- # push(@files, "$ENV{'HOME'}/bin/scripts/inxi/data/repo/yum/rpmfusion-nonfree-1.repo");
+ # push(@files, "$fake_data_dir/repo/yum/rpmfusion-nonfree-1.repo");
if (@files){
foreach (sort @files){
@data2 = main::reader($_);
@@ -21591,14 +22348,14 @@ sub get_repos_linux {
clean_url(\@content);
$key = repo_data('active',$repo);
}
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $_},
[@content],
);
@content = ();
}
}
- # print Data::Dumper::Dumper \@rows;
+ # print Data::Dumper::Dumper \@$rows;
}
# gentoo
if ((-d $portage_dir || -d $portage_gentoo_dir) && main::check_program('emerge')){
@@ -21654,7 +22411,7 @@ sub get_repos_linux {
clean_url(\@content);
$key = repo_data('active','portage');
}
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $_},
[@content],
);
@@ -21664,13 +22421,13 @@ sub get_repos_linux {
}
# Alpine linux
if (-f $apk){
- @data = repo_builder($apk,'apk','^\s*[^#]+');
- push(@rows,@data);
+ $data = repo_builder($apk,'apk','^\s*[^#]+');
+ push(@$rows,@$data);
}
# Venom
if (-f $scratchpkg){
- @data = repo_builder($scratchpkg,'scratchpkg','^[[:space:]]*[^#]+');
- push(@rows,@data);
+ $data = repo_builder($scratchpkg,'scratchpkg','^[[:space:]]*[^#]+');
+ push(@$rows,@$data);
}
# cards/nutyx
if (-f $cards){
@@ -21689,7 +22446,7 @@ sub get_repos_linux {
clean_url(\@content);
$key = repo_data('active','cards');
}
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $cards},
[@content],
);
@@ -21697,11 +22454,11 @@ sub get_repos_linux {
}
# TinyCore
if (-e $tce_app || -f $tce_file || -f $tce_file2){
- @data = repo_builder($tce_file,'tce','^\s*[^#]+');
- push(@rows,@data);
+ $data = repo_builder($tce_file,'tce','^\s*[^#]+');
+ push(@$rows,@$data);
if (-f $tce_file2){
- @data = repo_builder($tce_file2,'tce','^\s*[^#]+');
- push(@rows,@data);
+ $data = repo_builder($tce_file2,'tce','^\s*[^#]+');
+ push(@$rows,@$data);
}
}
# Void
@@ -21710,8 +22467,8 @@ sub get_repos_linux {
push(@files,main::globber("$xbps_dir_2*.conf")) if -d $xbps_dir_2;
main::log_data('data',"xbps repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log;
foreach (sort @files){
- @data = repo_builder($_,'xbps','^\s*repository\s*=','\s*=\s*',1) if -r $_;
- push(@rows,@data);
+ $data = repo_builder($_,'xbps','^\s*repository\s*=','\s*=\s*',1) if -r $_;
+ push(@$rows,@$data);
}
}
# Mandriva/Mageia using: urpmq
@@ -21740,7 +22497,7 @@ sub get_repos_linux {
clean_url(\@content);
# get the repo
$repo = $2;
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,'urpmq repo') => $repo},
[@content],
);
@@ -21785,7 +22542,7 @@ sub get_repos_linux {
if ($repo && @content){
clean_url(\@content);
$key = repo_data('active',$which);
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $repo},
[@content],
);
@@ -21797,7 +22554,7 @@ sub get_repos_linux {
if ($repo && @content){
clean_url(\@content);
$key = repo_data('active',$which);
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $repo},
[@content],
);
@@ -21814,20 +22571,20 @@ sub get_repos_linux {
$key = repo_data('active','nix');
}
my $user = ($ENV{'USER'}) ? $ENV{'USER'}: 'N/A';
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $user},
[@content],
);
@content = ();
}
- # print Dumper \@rows;
+ # print Dumper $rows;
eval $end if $b_log;
- return @rows;
}
sub get_repos_bsd {
eval $start if $b_log;
- my (@content,@data,@data2,@data3,@files,@rows);
+ my $rows = $_[0];
+ my (@content,$data,@data2,@data3,@files);
my ($key);
my $bsd_pkg = '/usr/local/etc/pkg/repos/';
my $freebsd = '/etc/freebsd-update.conf';
@@ -21842,12 +22599,12 @@ sub get_repos_bsd {
if (-f $portsnap || -f $freebsd || -d $bsd_pkg ||
-f $ghostbsd_pkg || -f $hardenedbsd_pkg){
if (-f $portsnap){
- @data = repo_builder($portsnap,'portsnap','^\s*SERVERNAME','\s*=\s*',1);
- push(@rows,@data);
+ $data = repo_builder($portsnap,'portsnap','^\s*SERVERNAME','\s*=\s*',1);
+ push(@$rows,@$data);
}
if (-f $freebsd){
- @data = repo_builder($freebsd,'freebsd','^\s*ServerName','\s+',1);
- push(@rows,@data);
+ $data = repo_builder($freebsd,'freebsd','^\s*ServerName','\s+',1);
+ push(@$rows,@$data);
}
if (-d $bsd_pkg || -f $freebsd_pkg || -f $ghostbsd_pkg || -f $hardenedbsd_pkg){
@files = main::globber('/usr/local/etc/pkg/repos/*.conf');
@@ -21889,7 +22646,7 @@ sub get_repos_bsd {
clean_url(\@data3);
$key = repo_data('active','bsd-package');
}
- push(@rows,
+ push(@$rows,
{main::key($num++,1,1,$key) => $_},
[@data3],
);
@@ -21900,18 +22657,18 @@ sub get_repos_bsd {
}
if (-f $openbsd || -f $openbsd2){
if (-f $openbsd){
- @data = repo_builder($openbsd,'openbsd','^installpath','\s*=\s*',1);
- push(@rows,@data);
+ $data = repo_builder($openbsd,'openbsd','^installpath','\s*=\s*',1);
+ push(@$rows,@$data);
}
if (-f $openbsd2){
- @data = repo_builder($openbsd2,'openbsd','^(http|ftp)','',1);
- push(@rows,@data);
+ $data = repo_builder($openbsd2,'openbsd','^(http|ftp)','',1);
+ push(@$rows,@$data);
}
}
if (-f $netbsd){
# not an empty row, and not a row starting with #
- @data = repo_builder($netbsd,'netbsd','^\s*[^#]+$');
- push(@rows,@data);
+ $data = repo_builder($netbsd,'netbsd','^\s*[^#]+$');
+ push(@$rows,@$data);
}
# I don't think this is right, have to find out, for midnightbsd
# if (-f $mports){
@@ -21933,7 +22690,7 @@ sub get_repos_bsd {
# clean_url(\@data3);
# $key = repo_data('active','mports');
# }
-# push(@rows,
+# push(@$rows,
# {main::key($num++,1,1,$key) => $mports},
# [@data3],
# );
@@ -21941,7 +22698,7 @@ sub get_repos_bsd {
# }
# BSDs do not default always to having repo files, so show correct error
# mesage in that case
- if (!@rows){
+ if (!@$rows){
if ($bsd_type eq 'freebsd'){
$key = repo_data('missing','freebsd-files');
}
@@ -21954,13 +22711,12 @@ sub get_repos_bsd {
else {
$key = repo_data('missing','bsd-files');
}
- push(@rows,
+ push(@$rows,
{main::key($num++,0,1,'Message') => $key},
[()],
);
}
eval $start if $b_log;
- return @rows;
}
sub repo_data {
eval $start if $b_log;
@@ -22028,7 +22784,7 @@ sub repo_data {
sub repo_builder {
eval $start if $b_log;
my ($file,$type,$search,$split,$count) = @_;
- my (@content,@data,$key);
+ my (@content,$key);
push(@dbg_files, $file) if $debugger_dir;
if (-r $file){
@content = main::reader($file);
@@ -22048,12 +22804,11 @@ sub repo_builder {
$key = repo_data('active',$type);
clean_url(\@content);
}
- @data = (
+ eval $end if $b_log;
+ return [
{main::key($num++,1,1,$key) => $file},
[@content],
- );
- eval $end if $b_log;
- return @data;
+ ];
}
sub clean_data {
# basics: trim white space, get rid of double spaces; trim comments at
@@ -22084,9 +22839,12 @@ sub file_path {
## SensorItem
{
package SensorItem;
+my $gpu_data = [];
+my $sensors_raw = {};
sub get {
eval $start if $b_log;
- my ($key1,$program,$val1,@data,@rows,%sensors);
+ my ($b_data,$key1,$program,$val1,$sensors);
+ my $rows = [];
my $num = 0;
my $source = 'sensors';
# we're allowing 1 or 2 ipmi tools, first the gnu one, then the
@@ -22095,33 +22853,30 @@ sub get {
(($program = main::check_program('ipmi-sensors')) ||
($program = main::check_program('ipmitool'))))){
if ($fake{'ipmi'} || $b_root){
- %sensors = ipmi_data($program);
- @data = sensors_output('ipmi',\%sensors);
- if (!@data){
+ $sensors = ipmi_data($program);
+ $b_data = sensors_output($rows,'ipmi',$sensors);
+ if (!$b_data){
$key1 = 'Message';
$val1 = main::message('sensors-data-ipmi');
# $val1 = main::message('dev');
- @data = ({main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1});
}
- push(@rows,@data);
$source = 'lm-sensors'; # trips per sensor type output
}
else {
$key1 = 'Permissions';
$val1 = main::message('sensors-ipmi-root');
- @data = ({main::key($num++,0,1,$key1) => $val1,});
- push(@rows,@data);
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1});
}
}
if ($sysctl{'sensor'}){
- %sensors = sysctl_data();
- @data = sensors_output('sysctl-sensors',\%sensors);
- if (!@data){
+ $sensors = sysctl_data();
+ $b_data = sensors_output($rows,'sysctl-sensors',$sensors);
+ if (!$b_data){
$key1 = 'Message';
$val1 = main::message('sensors-data-bsd',$uname[0]);
- @data = ({main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1});
}
- push(@rows,@data);
}
else {
if (!$fake{'sensors'} && $alerts{'sensors'}->{'action'} ne 'use'){
@@ -22135,201 +22890,205 @@ sub get {
$val1 = $alerts{'sensors'}->{'message'};
$key1 = ucfirst($key1);
}
- @data = ({main::key($num++,0,1,$key1) => $val1,});
- push(@rows,@data);
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1,});
}
else {
- %sensors = lm_sensors_data();
- @data = sensors_output($source,\%sensors);
+ $sensors = lm_sensors_data();
+ $b_data = sensors_output($rows,$source,$sensors);
# print "here 2\n";
- if (!@data){
+ if (!$b_data){
$key1 = 'Message';
$val1 = main::message('sensors-data-linux');
- @data = ({main::key($num++,0,1,$key1) => $val1,});
+ push(@$rows,{main::key($num++,0,1,$key1) => $val1});
}
- push(@rows,@data);
}
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub sensors_output {
eval $start if $b_log;
- my ($source,$sensors) = @_;
- my (@gpu,@rows,@fan_default,@fan_main);
+ my ($rows,$source,$sensors) = @_;
+ my ($b_result,@fan_default,@fan_main);
my ($data_source) = ('');
my $fan_number = 0;
my $num = 0;
my $j = 0;
- @gpu = gpu_data() if ($source eq 'sensors' || $source eq 'lm-sensors');
+ if (!$loaded{'gpu-data'} &&
+ ($source eq 'sensors' || $source eq 'lm-sensors')){
+ gpu_sensor_data();
+ }
# gpu sensors data might be present even if standard sensors data wasn't
- return if !%$sensors && !@gpu;
+ return if !%$sensors && !@$gpu_data;
+ $b_result = 1; ## need t trip data found conditions
my $temp_unit = (defined $sensors->{'temp-unit'}) ? " $sensors->{'temp-unit'}": '';
my $cpu_temp = (defined $sensors->{'cpu-temp'}) ? $sensors->{'cpu-temp'} . $temp_unit: 'N/A';
my $mobo_temp = (defined $sensors->{'mobo-temp'}) ? $sensors->{'mobo-temp'} . $temp_unit: 'N/A';
my $cpu1_key = ($sensors->{'cpu2-temp'}) ? 'cpu-1': 'cpu' ;
$data_source = $source if ($source eq 'ipmi' || $source eq 'lm-sensors');
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'System Temperatures') => $data_source,
main::key($num++,0,2,$cpu1_key) => $cpu_temp,
});
if ($sensors->{'cpu2-temp'}){
- $rows[$j]->{main::key($num++,0,2,'cpu-2')} = $sensors->{'cpu2-temp'} . $temp_unit;
+ $rows->[$j]{main::key($num++,0,2,'cpu-2')} = $sensors->{'cpu2-temp'} . $temp_unit;
}
if ($sensors->{'cpu3-temp'}){
- $rows[$j]->{main::key($num++,0,2,'cpu-3')} = $sensors->{'cpu3-temp'} . $temp_unit;
+ $rows->[$j]{main::key($num++,0,2,'cpu-3')} = $sensors->{'cpu3-temp'} . $temp_unit;
}
if ($sensors->{'cpu4-temp'}){
- $rows[$j]->{main::key($num++,0,2,'cpu-4')} = $sensors->{'cpu4-temp'} . $temp_unit;
+ $rows->[$j]{main::key($num++,0,2,'cpu-4')} = $sensors->{'cpu4-temp'} . $temp_unit;
}
if (defined $sensors->{'pch-temp'}){
my $pch_temp = $sensors->{'pch-temp'} . $temp_unit;
- $rows[$j]->{main::key($num++,0,2,'pch')} = $pch_temp;
+ $rows->[$j]{main::key($num++,0,2,'pch')} = $pch_temp;
}
- $rows[$j]->{main::key($num++,0,2,'mobo')} = $mobo_temp;
+ $rows->[$j]{main::key($num++,0,2,'mobo')} = $mobo_temp;
if (defined $sensors->{'sodimm-temp'}){
my $sodimm_temp = $sensors->{'sodimm-temp'} . $temp_unit;
- $rows[$j]->{main::key($num++,0,2,'sodimm')} = $sodimm_temp;
+ $rows->[$j]{main::key($num++,0,2,'sodimm')} = $sodimm_temp;
}
if (defined $sensors->{'psu-temp'}){
my $psu_temp = $sensors->{'psu-temp'} . $temp_unit;
- $rows[$j]->{main::key($num++,0,2,'psu')} = $psu_temp;
+ $rows->[$j]{main::key($num++,0,2,'psu')} = $psu_temp;
}
if (defined $sensors->{'ambient-temp'}){
my $ambient_temp = $sensors->{'ambient-temp'} . $temp_unit;
- $rows[$j]->{main::key($num++,0,2,'ambient')} = $ambient_temp;
+ $rows->[$j]{main::key($num++,0,2,'ambient')} = $ambient_temp;
}
- if (scalar @gpu == 1 && defined $gpu[0]->{'temp'}){
- my $gpu_temp = $gpu[0]->{'temp'};
- my $gpu_type = $gpu[0]->{'type'};
- my $gpu_unit = (defined $gpu[0]{'temp-unit'} && $gpu_temp) ? " $gpu[0]->{'temp-unit'}" : ' C';
- $rows[$j]->{main::key($num++,1,2,'gpu')} = $gpu_type;
- $rows[$j]->{main::key($num++,0,3,'temp')} = $gpu_temp . $gpu_unit;
- if ($extra > 1 && $gpu[0]->{'temp-mem'}){
- $rows[$j]->{main::key($num++,0,3,'mem')} = $gpu[0]->{'temp-mem'} . $gpu_unit;
+ if (scalar @$gpu_data == 1 && defined $gpu_data->[0]{'temp'}){
+ my $gpu_temp = $gpu_data->[0]{'temp'};
+ my $gpu_type = $gpu_data->[0]{'type'};
+ my $gpu_unit = (defined $gpu_data->[0]{'temp-unit'} && $gpu_temp) ? " $gpu_data->[0]{'temp-unit'}" : ' C';
+ $rows->[$j]{main::key($num++,1,2,'gpu')} = $gpu_type;
+ $rows->[$j]{main::key($num++,0,3,'temp')} = $gpu_temp . $gpu_unit;
+ if ($extra > 1 && $gpu_data->[0]{'temp-mem'}){
+ $rows->[$j]{main::key($num++,0,3,'mem')} = $gpu_data->[0]{'temp-mem'} . $gpu_unit;
}
}
- $j = scalar @rows;
+ $j = scalar @$rows;
@fan_main = @{$sensors->{'fan-main'}} if $sensors->{'fan-main'};
@fan_default = @{$sensors->{'fan-default'}} if $sensors->{'fan-default'};
my $fan_def = ($data_source) ? $data_source : '';
if (!@fan_main && !@fan_default){
$fan_def = ($fan_def) ? "$data_source N/A" : 'N/A';
}
- $rows[$j]->{main::key($num++,1,1,'Fan Speeds (RPM)')} = $fan_def;
+ $rows->[$j]{main::key($num++,1,1,'Fan Speeds (RPM)')} = $fan_def;
my $b_cpu = 0;
for (my $i = 0; $i < scalar @fan_main; $i++){
next if $i == 0;# starts at 1, not 0
if (defined $fan_main[$i]){
if ($i == 1 || ($i == 2 && !$b_cpu)){
- $rows[$j]->{main::key($num++,0,2,'cpu')} = $fan_main[$i];
+ $rows->[$j]{main::key($num++,0,2,'cpu')} = $fan_main[$i];
$b_cpu = 1;
}
elsif ($i == 2 && $b_cpu){
- $rows[$j]->{main::key($num++,0,2,'mobo')} = $fan_main[$i];
+ $rows->[$j]{main::key($num++,0,2,'mobo')} = $fan_main[$i];
}
elsif ($i == 3){
- $rows[$j]->{main::key($num++,0,2,'psu')} = $fan_main[$i];
+ $rows->[$j]{main::key($num++,0,2,'psu')} = $fan_main[$i];
}
elsif ($i == 4){
- $rows[$j]->{main::key($num++,0,2,'sodimm')} = $fan_main[$i];
+ $rows->[$j]{main::key($num++,0,2,'sodimm')} = $fan_main[$i];
}
elsif ($i > 4){
$fan_number = $i - 4;
- $rows[$j]->{main::key($num++,0,2,"case-$fan_number")} = $fan_main[$i];
+ $rows->[$j]{main::key($num++,0,2,"case-$fan_number")} = $fan_main[$i];
}
}
}
for (my $i = 0; $i < scalar @fan_default; $i++){
next if $i == 0;# starts at 1, not 0
if (defined $fan_default[$i]){
- $rows[$j]->{main::key($num++,0,2,"fan-$i")} = $fan_default[$i];
+ $rows->[$j]{main::key($num++,0,2,"fan-$i")} = $fan_default[$i];
}
}
- $rows[$j]->{main::key($num++,0,2,'psu')} = $sensors->{'fan-psu'} if defined $sensors->{'fan-psu'};
- $rows[$j]->{main::key($num++,0,2,'psu-1')} = $sensors->{'fan-psu1'} if defined $sensors->{'fan-psu1'};
- $rows[$j]->{main::key($num++,0,2,'psu-2')} = $sensors->{'fan-psu2'} if defined $sensors->{'fan-psu2'};
+ $rows->[$j]{main::key($num++,0,2,'psu')} = $sensors->{'fan-psu'} if defined $sensors->{'fan-psu'};
+ $rows->[$j]{main::key($num++,0,2,'psu-1')} = $sensors->{'fan-psu1'} if defined $sensors->{'fan-psu1'};
+ $rows->[$j]{main::key($num++,0,2,'psu-2')} = $sensors->{'fan-psu2'} if defined $sensors->{'fan-psu2'};
# note: so far, only nvidia-settings returns speed, and that's in percent
- if (scalar @gpu == 1 && defined $gpu[0]->{'fan-speed'}){
- my $gpu_fan = $gpu[0]->{'fan-speed'} . $gpu[0]{'speed-unit'};
- my $gpu_type = $gpu[0]->{'type'};
- $rows[$j]->{main::key($num++,1,2,'gpu')} = $gpu_type;
- $rows[$j]->{main::key($num++,0,3,'fan')} = $gpu_fan;
- }
- if (scalar @gpu > 1){
- $j = scalar @rows;
- $rows[$j]->{main::key($num++,1,1,'GPU')} = '';
- my $gpu_unit = (defined $gpu[0]->{'temp-unit'}) ? " $gpu[0]->{'temp-unit'}" : ' C';
- foreach my $info (@gpu){
+ if (scalar @$gpu_data == 1 && defined $gpu_data->[0]{'fan-speed'}){
+ my $gpu_fan = $gpu_data->[0]{'fan-speed'} . $gpu_data->[0]{'speed-unit'};
+ my $gpu_type = $gpu_data->[0]{'type'};
+ $rows->[$j]{main::key($num++,1,2,'gpu')} = $gpu_type;
+ $rows->[$j]{main::key($num++,0,3,'fan')} = $gpu_fan;
+ }
+ if (scalar @$gpu_data > 1){
+ $j = scalar @$rows;
+ $rows->[$j]{main::key($num++,1,1,'GPU')} = '';
+ my $gpu_unit = (defined $gpu_data->[0]{'temp-unit'}) ? " $gpu_data->[0]{'temp-unit'}" : ' C';
+ foreach my $info (@$gpu_data){
# speed unit is either '' or %
my $gpu_fan = (defined $info->{'fan-speed'}) ? $info->{'fan-speed'} . $info->{'speed-unit'}: undef;
my $gpu_type = $info->{'type'};
my $gpu_temp = (defined $info->{'temp'}) ? $info->{'temp'} . $gpu_unit: 'N/A';
- $rows[$j]->{main::key($num++,1,2,'device')} = $gpu_type;
+ $rows->[$j]{main::key($num++,1,2,'device')} = $gpu_type;
if (defined $info->{'screen'}){
- $rows[$j]->{main::key($num++,0,3,'screen')} = $info->{'screen'};
+ $rows->[$j]{main::key($num++,0,3,'screen')} = $info->{'screen'};
}
- $rows[$j]->{main::key($num++,0,3,'temp')} = $gpu_temp;
+ $rows->[$j]{main::key($num++,0,3,'temp')} = $gpu_temp;
if ($extra > 1 && $info->{'temp-mem'}){
- $rows[$j]->{main::key($num++,0,3,'mem')} = $info->{'temp-mem'} . $gpu_unit;
+ $rows->[$j]{main::key($num++,0,3,'mem')} = $info->{'temp-mem'} . $gpu_unit;
}
if (defined $gpu_fan){
- $rows[$j]->{main::key($num++,0,3,'fan')} = $gpu_fan;
+ $rows->[$j]{main::key($num++,0,3,'fan')} = $gpu_fan;
}
if ($extra > 2 && $info->{'watts'}){
- $rows[$j]->{main::key($num++,0,3,'watts')} = $info->{'watts'};
+ $rows->[$j]{main::key($num++,0,3,'watts')} = $info->{'watts'};
}
if ($extra > 2 && $info->{'mvolts'}){
- $rows[$j]->{main::key($num++,0,3,'mV')} = $info->{'mvolts'};
+ $rows->[$j]{main::key($num++,0,3,'mV')} = $info->{'mvolts'};
}
}
}
if ($extra > 0 && ($source eq 'ipmi' ||
($sensors->{'volts-12'} || $sensors->{'volts-5'} || $sensors->{'volts-3.3'} ||
$sensors->{'volts-vbat'}))){
- $j = scalar @rows;
+ $j = scalar @$rows;
$sensors->{'volts-12'} ||= 'N/A';
$sensors->{'volts-5'} ||= 'N/A';
$sensors->{'volts-3.3'} ||= 'N/A';
$sensors->{'volts-vbat'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,1,'Power')} = $data_source;
- $rows[$j]->{main::key($num++,0,2,'12v')} = $sensors->{'volts-12'};
- $rows[$j]->{main::key($num++,0,2,'5v')} = $sensors->{'volts-5'};
- $rows[$j]->{main::key($num++,0,2,'3.3v')} = $sensors->{'volts-3.3'};
- $rows[$j]->{main::key($num++,0,2,'vbat')} = $sensors->{'volts-vbat'};
+ $rows->[$j]{main::key($num++,1,1,'Power')} = $data_source;
+ $rows->[$j]{main::key($num++,0,2,'12v')} = $sensors->{'volts-12'};
+ $rows->[$j]{main::key($num++,0,2,'5v')} = $sensors->{'volts-5'};
+ $rows->[$j]{main::key($num++,0,2,'3.3v')} = $sensors->{'volts-3.3'};
+ $rows->[$j]{main::key($num++,0,2,'vbat')} = $sensors->{'volts-vbat'};
if ($extra > 1 && $source eq 'ipmi'){
$sensors->{'volts-dimm-p1'} ||= 'N/A';
$sensors->{'volts-dimm-p2'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'dimm-p1')} = $sensors->{'volts-dimm-p1'} if $sensors->{'volts-dimm-p1'};
- $rows[$j]->{main::key($num++,0,2,'dimm-p2')} = $sensors->{'volts-dimm-p2'} if $sensors->{'volts-dimm-p2'};
- $rows[$j]->{main::key($num++,0,2,'soc-p1')} = $sensors->{'volts-soc-p1'} if $sensors->{'volts-soc-p1'};
- $rows[$j]->{main::key($num++,0,2,'soc-p2')} = $sensors->{'volts-soc-p2'} if $sensors->{'volts-soc-p2'};
+ $rows->[$j]{main::key($num++,0,2,'dimm-p1')} = $sensors->{'volts-dimm-p1'} if $sensors->{'volts-dimm-p1'};
+ $rows->[$j]{main::key($num++,0,2,'dimm-p2')} = $sensors->{'volts-dimm-p2'} if $sensors->{'volts-dimm-p2'};
+ $rows->[$j]{main::key($num++,0,2,'soc-p1')} = $sensors->{'volts-soc-p1'} if $sensors->{'volts-soc-p1'};
+ $rows->[$j]{main::key($num++,0,2,'soc-p2')} = $sensors->{'volts-soc-p2'} if $sensors->{'volts-soc-p2'};
}
- if (scalar @gpu == 1 && $extra > 2 && ($gpu[0]->{'watts'} || $gpu[0]->{'mvolts'})){
- $rows[$j]->{main::key($num++,1,2,'gpu')} = $gpu[0]->{'type'};
- $rows[$j]->{main::key($num++,0,3,'watts')} = $gpu[0]->{'watts'} if $gpu[0]->{'watts'} ;
- $rows[$j]->{main::key($num++,0,3,'mV')} = $gpu[0]->{'mvolts'} if $gpu[0]->{'mvolts'};
+ if (scalar @$gpu_data == 1 && $extra > 2 &&
+ ($gpu_data->[0]{'watts'} || $gpu_data->[0]{'mvolts'})){
+ $rows->[$j]{main::key($num++,1,2,'gpu')} = $gpu_data->[0]{'type'};
+ $rows->[$j]{main::key($num++,0,3,'watts')} = $gpu_data->[0]{'watts'} if $gpu_data->[0]{'watts'};
+ $rows->[$j]{main::key($num++,0,3,'mV')} = $gpu_data->[0]{'mvolts'} if $gpu_data->[0]{'mvolts'};
}
}
eval $end if $b_log;
- return @rows;
+ return $b_result;
}
sub ipmi_data {
eval $start if $b_log;
my ($program) = @_;
- my ($b_cpu_0,$cmd,$file,@data,$fan_working,%sensors,@row,$sys_fan_nu,
- $temp_working,$working_unit);
+ my ($b_cpu_0,$cmd,$file,@data,$fan_working,@row,$sys_fan_nu,$temp_working,
+ $working_unit);
my ($b_ipmitool,$i_key,$i_value,$i_unit);
+ my $sensors = {};
if ($fake{'ipmi'}){
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmitool-sensors-archerseven-1.txt";$program='ipmitool';
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmitool-sensors-crazy-epyc-1.txt";$program='ipmitool';
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmitool-sensors-RK016013.txt";$program='ipmitool';
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmitool-sensors-freebsd-offsite-backup.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmitool-sensor-tyan-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmi-sensors-crazy-epyc-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmi-sensors-lathander.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmi-sensors-zwerg.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ipmitool/ipmi-sensors-arm-server-1.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmitool-sensors-archerseven-1.txt";$program='ipmitool';
+ # $file = "$fake_data_dir/ipmitool/ipmitool-sensors-crazy-epyc-1.txt";$program='ipmitool';
+ # $file = "$fake_data_dir/ipmitool/ipmitool-sensors-RK016013.txt";$program='ipmitool';
+ # $file = "$fake_data_dir/ipmitool/ipmitool-sensors-freebsd-offsite-backup.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmitool-sensor-tyan-1.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmi-sensors-crazy-epyc-1.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmi-sensors-lathander.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmi-sensors-zwerg.txt";
+ # $file = "$fake_data_dir/ipmitool/ipmi-sensors-arm-server-1.txt";
# @data = main::reader($file);
# ($b_ipmitool,$i_key,$i_value,$i_unit) = (0,1,3,4); # ipmi-sensors
# ($b_ipmitool,$i_key,$i_value,$i_unit) = (1,0,1,2); # ipmitool sensors
@@ -22356,76 +23115,76 @@ sub ipmi_data {
# print "$row[$i_value]\n";
next if !main::is_numeric($row[$i_value]);
# print "$row[$i_key] - $row[$i_value]\n";
- if (!$sensors{'mobo-temp'} && $row[$i_key] =~ /^(MB_TEMP[0-9]|System[\s_]Temp|System[\s_]?Board([\s_]Temp)?)$/i){
- $sensors{'mobo-temp'} = int($row[$i_value]);
+ if (!$sensors->{'mobo-temp'} && $row[$i_key] =~ /^(MB_TEMP[0-9]|System[\s_]Temp|System[\s_]?Board([\s_]Temp)?)$/i){
+ $sensors->{'mobo-temp'} = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($row[$i_key] =~ /^(System\s)?(Ambient)([\s_]Temp)?$/i){
- $sensors{'ambient-temp'} = int($row[$i_value]);
+ $sensors->{'ambient-temp'} = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# Platform Control Hub (PCH), it is the X370 chip on the Crosshair VI Hero.
# VRM: voltage regulator module
# NOTE: CPU0_TEMP CPU1_TEMP is possible, unfortunately; CPU Temp Interf
- elsif (!$sensors{'cpu-temp'} && $row[$i_key] =~ /^CPU([01])?([\s_](below[\s_]Tmax|Temp))?$/i){
+ elsif (!$sensors->{'cpu-temp'} && $row[$i_key] =~ /^CPU([01])?([\s_](below[\s_]Tmax|Temp))?$/i){
$b_cpu_0 = 1 if defined $1 && $1 == 0;
- $sensors{'cpu-temp'} = int($row[$i_value]);
+ $sensors->{'cpu-temp'} = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($row[$i_key] =~ /^CPU([1-4])([\s_](below[\s_]Tmax|Temp))?$/i){
$temp_working = $1;
$temp_working++ if $b_cpu_0;
- $sensors{"cpu${temp_working}-temp"} = int($row[$i_value]);
+ $sensors->{"cpu${temp_working}-temp"} = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# for temp1/2 only use temp1/2 if they are null or greater than the last ones
elsif ($row[$i_key] =~ /^(MB[_]?TEMP1|Temp[\s_]1)$/i){
$temp_working = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- if (!$sensors{'temp1'} || (defined $temp_working && $temp_working > 0)){
- $sensors{'temp1'} = $temp_working;
+ if (!$sensors->{'temp1'} || (defined $temp_working && $temp_working > 0)){
+ $sensors->{'temp1'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($row[$i_key] =~ /^(MB[_]?TEMP2|Temp[\s_]2)$/i){
$temp_working = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- if (!$sensors{'temp2'} || (defined $temp_working && $temp_working > 0)){
- $sensors{'temp2'} = $temp_working;
+ if (!$sensors->{'temp2'} || (defined $temp_working && $temp_working > 0)){
+ $sensors->{'temp2'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# temp3 is only used as an absolute override for systems with all 3 present
elsif ($row[$i_key] =~ /^(MB[_]?TEMP3|Temp[\s_]3)$/i){
$temp_working = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- if (!$sensors{'temp3'} || (defined $temp_working && $temp_working > 0)){
- $sensors{'temp3'} = $temp_working;
+ if (!$sensors->{'temp3'} || (defined $temp_working && $temp_working > 0)){
+ $sensors->{'temp3'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
- elsif (!$sensors{'sodimm-temp'} && ($row[$i_key] =~ /^(DIMM[-_]([A-Z][0-9][-_])?[A-Z]?[0-9][A-Z]?)$/i ||
+ elsif (!$sensors->{'sodimm-temp'} && ($row[$i_key] =~ /^(DIMM[-_]([A-Z][0-9][-_])?[A-Z]?[0-9][A-Z]?)$/i ||
$row[$i_key] =~ /^DIMM[0-9] Area.*/)){
- $sensors{'sodimm-temp'} = int($row[$i_value]);
+ $sensors->{'sodimm-temp'} = int($row[$i_value]);
$working_unit = $row[$i_unit];
$working_unit =~ s/degrees\s// if $b_ipmitool;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# note: can be cpu fan:, cpu fan speed:, etc.
elsif ($row[$i_key] =~ /^(CPU|Processor)[\s_]Fan/i ||
$row[$i_key] =~ /^SYS\.[0-9][\s_]?\(CPU\s?0\)$/i){
- $sensors{'fan-main'}->[1] = int($row[$i_value]);
+ $sensors->{'fan-main'}->[1] = int($row[$i_value]);
}
# note that the counters are dynamically set for fan numbers here
# otherwise you could overwrite eg aux fan2 with case fan2 in theory
@@ -22435,77 +23194,77 @@ sub ipmi_data {
elsif ($row[$i_key] =~ /^(SYS[\s_])?FAN[\s_]?([0-9A-F]+)/i){
$sys_fan_nu = hex($2);
$fan_working = int($row[$i_value]);
- $sensors{'fan-default'} = () if !$sensors{'fan-default'};
+ $sensors->{'fan-default'} = () if !$sensors->{'fan-default'};
if ($sys_fan_nu =~ /^([0-9]+)$/){
# add to array if array index does not exist OR if number is > existing number
- if (defined $sensors{'fan-default'}->[$sys_fan_nu]){
- if ($fan_working >= $sensors{'fan-default'}->[$sys_fan_nu]){
- $sensors{'fan-default'}->[$sys_fan_nu] = $fan_working;
+ if (defined $sensors->{'fan-default'}->[$sys_fan_nu]){
+ if ($fan_working >= $sensors->{'fan-default'}->[$sys_fan_nu]){
+ $sensors->{'fan-default'}->[$sys_fan_nu] = $fan_working;
}
}
else {
- $sensors{'fan-default'}->[$sys_fan_nu] = $fan_working;
+ $sensors->{'fan-default'}->[$sys_fan_nu] = $fan_working;
}
}
}
elsif ($row[$i_key] =~ /^(FAN PSU|PSU FAN)$/i){
- $sensors{'fan-psu'} = int($row[$i_value]);
+ $sensors->{'fan-psu'} = int($row[$i_value]);
}
elsif ($row[$i_key] =~ /^(FAN PSU1|PSU1 FAN)$/i){
- $sensors{'fan-psu-1'} = int($row[$i_value]);
+ $sensors->{'fan-psu-1'} = int($row[$i_value]);
}
elsif ($row[$i_key] =~ /^(FAN PSU2|PSU2 FAN)$/i){
- $sensors{'fan-psu-2'} = int($row[$i_value]);
+ $sensors->{'fan-psu-2'} = int($row[$i_value]);
}
if ($extra > 0){
if ($row[$i_key] =~ /^((MAIN\s|P[_]?)?\+?12V|PSU[12]_VOUT)$/i){
- $sensors{'volts-12'} = $row[$i_value];
+ $sensors->{'volts-12'} = $row[$i_value];
}
elsif ($row[$i_key] =~ /^(MAIN\s5V|P5V|5VCC|5V( PG)?|5V_SB)$/i){
- $sensors{'volts-5'} = $row[$i_value];
+ $sensors->{'volts-5'} = $row[$i_value];
}
elsif ($row[$i_key] =~ /^(MAIN\s3\.3V|P3V3|3\.3VCC|3\.3V( PG)?|3V3_SB)$/i){
- $sensors{'volts-3.3'} = $row[$i_value];
+ $sensors->{'volts-3.3'} = $row[$i_value];
}
elsif ($row[$i_key] =~ /^((P_)?VBAT|CMOS Battery|BATT 3.0V)$/i){
- $sensors{'volts-vbat'} = $row[$i_value];
+ $sensors->{'volts-vbat'} = $row[$i_value];
}
# NOTE: VDimmP1ABC VDimmP1DEF
- elsif (!$sensors{'volts-dimm-p1'} && $row[$i_key] =~ /^(P1_VMEM|VDimmP1|MEM RSR A PG|DIMM_VR1_VOLT)/i){
- $sensors{'volts-dimm-p1'} = $row[$i_value];
+ elsif (!$sensors->{'volts-dimm-p1'} && $row[$i_key] =~ /^(P1_VMEM|VDimmP1|MEM RSR A PG|DIMM_VR1_VOLT)/i){
+ $sensors->{'volts-dimm-p1'} = $row[$i_value];
}
- elsif (!$sensors{'volts-dimm-p2'} && $row[$i_key] =~ /^(P2_VMEM|VDimmP2|MEM RSR B PG|DIMM_VR2_VOLT)/i){
- $sensors{'volts-dimm-p2'} = $row[$i_value];
+ elsif (!$sensors->{'volts-dimm-p2'} && $row[$i_key] =~ /^(P2_VMEM|VDimmP2|MEM RSR B PG|DIMM_VR2_VOLT)/i){
+ $sensors->{'volts-dimm-p2'} = $row[$i_value];
}
- elsif (!$sensors{'volts-soc-p1'} && $row[$i_key] =~ /^(P1_SOC_RUN$)/i){
- $sensors{'volts-soc-p1'} = $row[$i_value];
+ elsif (!$sensors->{'volts-soc-p1'} && $row[$i_key] =~ /^(P1_SOC_RUN$)/i){
+ $sensors->{'volts-soc-p1'} = $row[$i_value];
}
- elsif (!$sensors{'volts-soc-p2'} && $row[$i_key] =~ /^(P2_SOC_RUN$)/i){
- $sensors{'volts-soc-p2'} = $row[$i_value];
+ elsif (!$sensors->{'volts-soc-p2'} && $row[$i_key] =~ /^(P2_SOC_RUN$)/i){
+ $sensors->{'volts-soc-p2'} = $row[$i_value];
}
}
}
- print Data::Dumper::Dumper \%sensors if $dbg[31];
- %sensors = process_data(%sensors) if %sensors;
- main::log_data('dump','ipmi: %sensors',\%sensors) if $b_log;
+ print Data::Dumper::Dumper $sensors if $dbg[31];
+ process_data($sensors) if %$sensors;
+ main::log_data('dump','ipmi: %$sensors',$sensors) if $b_log;
eval $end if $b_log;
- print Data::Dumper::Dumper \%sensors if $dbg[31];
- return %sensors;
+ print Data::Dumper::Dumper $sensors if $dbg[31];
+ return $sensors;
}
sub lm_sensors_data {
eval $start if $b_log;
- my (%sensors);
+ my $sensors = {};
my ($sys_fan_nu) = (0);
my ($adapter,$fan_working,$temp_working,$working_unit) = ('','','','','');
- process_lm_sensors() if !$loaded{'lm-sensors'};
- foreach $adapter (keys %{$sensors_raw{'main'}}){
- next if !$adapter || ref $sensors_raw{'main'}->{$adapter} ne 'ARRAY';
+ load_lm_sensors();
+ foreach $adapter (keys %{$sensors_raw->{'main'}}){
+ next if !$adapter || ref $sensors_raw->{'main'}{$adapter} ne 'ARRAY';
# not sure why hwmon is excluded, forgot to add info in comments
if ((@sensors_use && !(grep {/$adapter/} @sensors_use)) ||
(@sensors_exclude && (grep {/$adapter/} @sensors_exclude))){
next;
}
- foreach (@{$sensors_raw{'main'}->{$adapter}}){
+ foreach (@{$sensors_raw->{'main'}{$adapter}}){
my @working = split(':', $_);
next if !$working[0];
# print "$working[0]:$working[1]\n";
@@ -22520,9 +23279,9 @@ sub lm_sensors_data {
if ($_ =~ /^T?(AMBIENT|M\/B|MB|Motherboard|SIO|SYS).*:([0-9\.]+)[\s°]*(C|F)/i){
# avoid SYSTIN: 118 C
if (main::is_numeric($2) && $2 < 90){
- $sensors{'mobo-temp'} = $2;
+ $sensors->{'mobo-temp'} = $2;
$working_unit = $3;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
}
# issue 58 msi/asus show wrong for CPUTIN so overwrite it if PECI 0 is present
@@ -22532,83 +23291,84 @@ sub lm_sensors_data {
# which is the maximum CPU temperature reported as critical temperature by coretemp"
# NOTE: I've seen an inexplicable case where: CPU:52.0°C fails to match with [\s°] but
# does match with: [\s°]*. I can't account for this, but that's why the * is there
- # Tdie is a new k10temp-pci syntax for cpu die temp
+ # Tdie is a new k10temp-pci syntax for real cpu die temp. Tctl is cpu control value,
+ # NOT the real cpu die temp.
elsif ($_ =~ /^(Chip 0.*?|T?CPU.*|Tdie.*):([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $2;
$working_unit = $3;
- if (!$sensors{'cpu-temp'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'cpu-temp'})){
- $sensors{'cpu-temp'} = $temp_working;
+ if (!$sensors->{'cpu-temp'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'cpu-temp'})){
+ $sensors->{'cpu-temp'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($_ =~ /^PECI\sAgent\s0.*:([0-9\.]+)[\s°]*(C|F)/i){
- $sensors{'cpu-peci-temp'} = $1;
+ $sensors->{'cpu-peci-temp'} = $1;
$working_unit = $2;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($_ =~ /^T?(P\/S|Power).*:([0-9\.]+)[\s°]*(C|F)/i){
- $sensors{'psu-temp'} = $2;
+ $sensors->{'psu-temp'} = $2;
$working_unit = $3;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($_ =~ /^T?(dimm|mem|sodimm).*?:([0-9\.]+)[\s°]*(C|F)/i){
- $sensors{'sodimm-temp'} = $1;
+ $sensors->{'sodimm-temp'} = $1;
$working_unit = $2;
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# for temp1/2 only use temp1/2 if they are null or greater than the last ones
elsif ($_ =~ /^temp1:([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $1;
$working_unit = $2;
- if (!$sensors{'temp1'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp1'})){
- $sensors{'temp1'} = $temp_working;
+ if (!$sensors->{'temp1'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'temp1'})){
+ $sensors->{'temp1'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
elsif ($_ =~ /^temp2:([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $1;
$working_unit = $2;
- if (!$sensors{'temp2'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp2'})){
- $sensors{'temp2'} = $temp_working;
+ if (!$sensors->{'temp2'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'temp2'})){
+ $sensors->{'temp2'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# temp3 is only used as an absolute override for systems with all 3 present
elsif ($_ =~ /^temp3:([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $1;
$working_unit = $2;
- if (!$sensors{'temp3'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp3'})){
- $sensors{'temp3'} = $temp_working;
+ if (!$sensors->{'temp3'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'temp3'})){
+ $sensors->{'temp3'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# final fallback if all else fails, funtoo user showed sensors putting
# temp on wrapped second line, not handled
elsif ($_ =~ /^T?(core0|core 0|Physical id 0)(.*):([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $3;
$working_unit = $4;
- if (!$sensors{'core-0-temp'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'core-0-temp'})){
- $sensors{'core-0-temp'} = $temp_working;
+ if (!$sensors->{'core-0-temp'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'core-0-temp'})){
+ $sensors->{'core-0-temp'} = $temp_working;
}
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit;
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit) if $working_unit;
}
# note: can be cpu fan:, cpu fan speed:, etc.
- elsif (!$sensors{'fan-main'}->[1] && $_ =~ /^F?(CPU|Processor).*:([0-9]+)[\s]RPM/i){
- $sensors{'fan-main'}->[1] = $2;
+ elsif (!$sensors->{'fan-main'}->[1] && $_ =~ /^F?(CPU|Processor).*:([0-9]+)[\s]RPM/i){
+ $sensors->{'fan-main'}->[1] = $2;
}
- elsif (!$sensors{'fan-main'}->[2] && $_ =~ /^F?(M\/B|MB|SYS|Motherboard).*:([0-9]+)[\s]RPM/i){
- $sensors{'fan-main'}->[2] = $2;
+ elsif (!$sensors->{'fan-main'}->[2] && $_ =~ /^F?(M\/B|MB|SYS|Motherboard).*:([0-9]+)[\s]RPM/i){
+ $sensors->{'fan-main'}->[2] = $2;
}
- elsif (!$sensors{'fan-main'}->[3] && $_ =~ /F?(Power|P\/S|POWER).*:([0-9]+)[\s]RPM/i){
- $sensors{'fan-main'}->[3] = $2;
+ elsif (!$sensors->{'fan-main'}->[3] && $_ =~ /F?(Power|P\/S|POWER).*:([0-9]+)[\s]RPM/i){
+ $sensors->{'fan-main'}->[3] = $2;
}
- elsif (!$sensors{'fan-main'}->[4] && $_ =~ /F?(dimm|mem|sodimm).*:([0-9]+)[\s]RPM/i){
- $sensors{'fan-main'}->[4] = $2;
+ elsif (!$sensors->{'fan-main'}->[4] && $_ =~ /F?(dimm|mem|sodimm).*:([0-9]+)[\s]RPM/i){
+ $sensors->{'fan-main'}->[4] = $2;
}
# note that the counters are dynamically set for fan numbers here
# otherwise you could overwrite eg aux fan2 with case fan2 in theory
@@ -22616,98 +23376,98 @@ sub lm_sensors_data {
elsif ($_ =~ /^F?(AUX|CASE|CHASSIS|FRONT|REAR).*:([0-9]+)[\s]RPM/i){
$temp_working = $2;
for (my $i = 5; $i < 30; $i++){
- next if defined $sensors{'fan-main'}->[$i];
- if (!defined $sensors{'fan-main'}->[$i]){
- $sensors{'fan-main'}->[$i] = $temp_working;
+ next if defined $sensors->{'fan-main'}->[$i];
+ if (!defined $sensors->{'fan-main'}->[$i]){
+ $sensors->{'fan-main'}->[$i] = $temp_working;
last;
}
}
}
# in rare cases syntax is like: fan1: xxx RPM
elsif ($_ =~ /^FAN(1)?:([0-9]+)[\s]RPM/i){
- $sensors{'fan-default'}->[1] = $2;
+ $sensors->{'fan-default'}->[1] = $2;
}
elsif ($_ =~ /^FAN([2-9]|1[0-9]).*:([0-9]+)[\s]RPM/i){
$fan_working = $2;
$sys_fan_nu = $1;
if ($sys_fan_nu =~ /^([0-9]+)$/){
# add to array if array index does not exist OR if number is > existing number
- if (defined $sensors{'fan-default'}->[$sys_fan_nu]){
- if ($fan_working >= $sensors{'fan-default'}->[$sys_fan_nu]){
- $sensors{'fan-default'}->[$sys_fan_nu] = $fan_working;
+ if (defined $sensors->{'fan-default'}->[$sys_fan_nu]){
+ if ($fan_working >= $sensors->{'fan-default'}->[$sys_fan_nu]){
+ $sensors->{'fan-default'}->[$sys_fan_nu] = $fan_working;
}
}
else {
- $sensors{'fan-default'}->[$sys_fan_nu] = $fan_working;
+ $sensors->{'fan-default'}->[$sys_fan_nu] = $fan_working;
}
}
}
if ($extra > 0){
if ($_ =~ /^[+]?(12 Volt|12V|V\+?12).*:([0-9\.]+)\sV/i){
- $sensors{'volts-12'} = $2;
+ $sensors->{'volts-12'} = $2;
}
# note: 5VSB is a field name
elsif ($_ =~ /^[+]?(5 Volt|5V|V\+?5):([0-9\.]+)\sV/i){
- $sensors{'volts-5'} = $2;
+ $sensors->{'volts-5'} = $2;
}
elsif ($_ =~ /^[+]?(3\.3 Volt|3\.3V|V\+?3\.3).*:([0-9\.]+)\sV/i){
- $sensors{'volts-3.3'} = $2;
+ $sensors->{'volts-3.3'} = $2;
}
elsif ($_ =~ /^(Vbat).*:([0-9\.]+)\sV/i){
- $sensors{'volts-vbat'} = $2;
+ $sensors->{'volts-vbat'} = $2;
}
elsif ($_ =~ /^v(dimm|mem|sodimm).*:([0-9\.]+)\sV/i){
- $sensors{'volts-mem'} = $2;
+ $sensors->{'volts-mem'} = $2;
}
}
}
}
- foreach $adapter (keys %{$sensors_raw{'pch'}}){
- next if !$adapter || ref $sensors_raw{'pch'}->{$adapter} ne 'ARRAY';
+ foreach $adapter (keys %{$sensors_raw->{'pch'}}){
+ next if !$adapter || ref $sensors_raw->{'pch'}{$adapter} ne 'ARRAY';
if ((@sensors_use && !(grep {/$adapter/} @sensors_use)) ||
(@sensors_exclude && (grep {/$adapter/} @sensors_exclude))){
next;
}
$temp_working = '';
- foreach (@{$sensors_raw{'pch'}->{$adapter}}){
+ foreach (@{$sensors_raw->{'pch'}{$adapter}}){
if ($_ =~ /^[^:]+:([0-9\.]+)[\s°]*(C|F)/i){
$temp_working = $1;
$working_unit = $2;
- if (!$sensors{'pch-temp'} ||
- (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'pch-temp'})){
- $sensors{'pch-temp'} = $temp_working;
+ if (!$sensors->{'pch-temp'} ||
+ (defined $temp_working && $temp_working > 0 && $temp_working > $sensors->{'pch-temp'})){
+ $sensors->{'pch-temp'} = $temp_working;
}
- if (!$sensors{'temp-unit'} && $working_unit){
- $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit);
+ if (!$sensors->{'temp-unit'} && $working_unit){
+ $sensors->{'temp-unit'} = set_temp_unit($sensors->{'temp-unit'},$working_unit);
}
}
}
}
- print Data::Dumper::Dumper \%sensors if $dbg[31];
- %sensors = process_data(%sensors) if %sensors;
- main::log_data('dump','lm-sensors: %sensors',\%sensors) if $b_log;
- print Data::Dumper::Dumper \%sensors if $dbg[31];
+ print Data::Dumper::Dumper $sensors if $dbg[31];
+ process_data($sensors) if %$sensors;
+ main::log_data('dump','lm-sensors: %sensors',$sensors) if $b_log;
+ print Data::Dumper::Dumper $sensors if $dbg[31];
eval $end if $b_log;
- return %sensors;
+ return $sensors;
}
-sub process_lm_sensors {
+sub load_lm_sensors {
eval $start if $b_log;
- my (@data,@sensors_data,@values);
+ my (@sensors_data,@values);
my ($adapter,$holder,$type) = ('','','');
- if ($fake{'sensors'}){
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/amdgpu-w-fan-speed-stretch-k10.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/peci-tin-geggo.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-w-other-biker.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-asus-chassis-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-devnull-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-jammin1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-mx-incorrect-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-maximus-arch-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/kernel-58-sensors-ant-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-zenpower-nvme-2.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-pch-intel-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-ppc-sr71.txt";
- my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sensors/sensors-applesmc-1.txt";
+ if ($fake{'sensors'}){
+ # my $file = "$fake_data_dir/sensors/amdgpu-w-fan-speed-stretch-k10.txt";
+ # my $file = "$fake_data_dir/sensors/peci-tin-geggo.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-w-other-biker.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-asus-chassis-1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-devnull-1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-jammin1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-mx-incorrect-1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-maximus-arch-1.txt";
+ # my $file = "$fake_data_dir/sensors/kernel-58-sensors-ant-1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-zenpower-nvme-2.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-pch-intel-1.txt";
+ # my $file = "$fake_data_dir/sensors/sensors-ppc-sr71.txt";
+ my $file = "$fake_data_dir/sensors/sensors-applesmc-1.txt";
@sensors_data = main::reader($file);
}
else {
@@ -22750,7 +23510,7 @@ sub process_lm_sensors {
else {
$type = 'main';
}
- $sensors_raw{$type}->{$adapter} = [@values];
+ $sensors_raw->{$type}{$adapter} = [@values];
@values = ();
$adapter = '';
}
@@ -22764,21 +23524,16 @@ sub process_lm_sensors {
$holder = $_;
}
}
- $loaded{'lm-sensors'} = 1;
- if ($dbg[18]){
- print 'lm sensors: ' , Data::Dumper::Dumper \%sensors_raw;
- }
- if ($b_log){
- main::log_data('dump','lm-sensors data: %sensors_raw',\%sensors_raw);
- }
+ print 'lm sensors: ' , Data::Dumper::Dumper $sensors_raw if $dbg[18];
+ main::log_data('dump','lm-sensors data: %$sensors_raw',$sensors_raw) if $b_log;
eval $end if $b_log;
- return @data;
}
# bsds sysctl may have hw.sensors data
sub sysctl_data {
eval $start if $b_log;
- my (@data,%sensors);
+ my (@data);
+ my $sensors = {};
# assume always starts at 0, can't do dynamic because freebsd shows tz1 first
my $add = 1;
foreach (@{$sysctl{'sensor'}}){
@@ -22810,42 +23565,42 @@ sub sysctl_data {
my $working = (split(':\s*', $_))[1];
if (defined $working && $working =~ /^([0-9\.]+)\s?((deg)?([CF]))?\b/){
$value = $1 ;
- $sensors{'temp-unit'} = $4 if $4 && !$sensors{'temp-unit'};
+ $sensors->{'temp-unit'} = $4 if $4 && !$sensors->{'temp-unit'};
}
else {
next;
}
$number += $add;
- if ($type eq 'cpu' && !defined $sensors{'cpu-temp'}){
- $sensors{'cpu-temp'} = $value;
+ if ($type eq 'cpu' && !defined $sensors->{'cpu-temp'}){
+ $sensors->{'cpu-temp'} = $value;
}
- elsif ($type eq 'temp' && !defined $sensors{'temp' . $number}){
- $sensors{'temp' . $number} = $value;
+ elsif ($type eq 'temp' && !defined $sensors->{'temp' . $number}){
+ $sensors->{'temp' . $number} = $value;
}
- elsif ($type eq 'fan' && !defined $sensors{'fan-main'}->[$number]){
- $sensors{'fan-main'}->[$number] = $value;
+ elsif ($type eq 'fan' && !defined $sensors->{'fan-main'}->[$number]){
+ $sensors->{'fan-main'}->[$number] = $value;
}
elsif ($type eq 'volt'){
if ($working =~ /\+3\.3V/i){
- $sensors{'volts-3.3'} = $value;
+ $sensors->{'volts-3.3'} = $value;
}
elsif ($working =~ /\+5V/i){
- $sensors{'volts-5'} = $value;
+ $sensors->{'volts-5'} = $value;
}
elsif ($working =~ /\+12V/i){
- $sensors{'volts-12'} = $value;
+ $sensors->{'volts-12'} = $value;
}
elsif ($working =~ /VBAT/i){
- $sensors{'volts-vbat'} = $value;
+ $sensors->{'volts-vbat'} = $value;
}
}
}
}
- %sensors = process_data(%sensors) if %sensors;
- main::log_data('dump','%sensors',\%sensors) if $b_log;
- print Data::Dumper::Dumper \%sensors if $dbg[31];;
+ process_data($sensors) if %$sensors;
+ main::log_data('dump','%$sensors',$sensors) if $b_log;
+ print Data::Dumper::Dumper $sensors if $dbg[31];;
eval $end if $b_log;
- return %sensors;
+ return $sensors;
}
sub set_temp_unit {
my ($sensors,$working) = @_;
@@ -22861,7 +23616,7 @@ sub set_temp_unit {
sub process_data {
eval $start if $b_log;
- my (%sensors) = @_;
+ my ($sensors) = @_;
my ($cpu_temp,$cpu2_temp,$cpu3_temp,$cpu4_temp,$mobo_temp,$pch_temp,$psu_temp);
my ($fan_type,$i,$j,$index_count_fan_default,$index_count_fan_main) = (0,0,0,0,0);
my $temp_diff = 20; # for C, handled for F after that is determined
@@ -22870,23 +23625,23 @@ sub process_data {
# note, for rare cases of weird cool cpus, user can override in their prefs and force the assignment
# this is wrong for systems with > 2 tempX readings, but the logic is too complex with 3 variables
# so have to accept that it will be wrong in some cases, particularly for motherboard temp readings.
- if ($sensors{'temp1'} && $sensors{'temp2'}){
+ if ($sensors->{'temp1'} && $sensors->{'temp2'}){
if ($sensors_cpu_nu){
$fan_type = $sensors_cpu_nu;
}
else {
# first some fringe cases with cooler cpu than mobo: assume which is cpu temp based on fan speed
# but only if other fan speed is 0.
- if ($sensors{'temp1'} >= $sensors{'temp2'} &&
+ if ($sensors->{'temp1'} >= $sensors->{'temp2'} &&
defined $fan_default[1] && defined $fan_default[2] && $fan_default[1] == 0 && $fan_default[2] > 0){
$fan_type = 2;
}
- elsif ($sensors{'temp2'} >= $sensors{'temp1'} &&
+ elsif ($sensors->{'temp2'} >= $sensors->{'temp1'} &&
defined $fan_default[1] && defined $fan_default[2] && $fan_default[2] == 0 && $fan_default[1] > 0){
$fan_type = 1;
}
# then handle the standard case if these fringe cases are false
- elsif ($sensors{'temp1'} >= $sensors{'temp2'}){
+ elsif ($sensors->{'temp1'} >= $sensors->{'temp2'}){
$fan_type = 1;
}
else {
@@ -22895,116 +23650,116 @@ sub process_data {
}
}
# need a case for no temps at all reported, like with old intels
- elsif (!$sensors{'temp2'} && !$sensors{'cpu-temp'}){
- if (!$sensors{'temp1'} && !$sensors{'mobo-temp'}){
+ elsif (!$sensors->{'temp2'} && !$sensors->{'cpu-temp'}){
+ if (!$sensors->{'temp1'} && !$sensors->{'mobo-temp'}){
$fan_type = 1;
}
- elsif ($sensors{'temp1'} && !$sensors{'mobo-temp'}){
+ elsif ($sensors->{'temp1'} && !$sensors->{'mobo-temp'}){
$fan_type = 1;
}
- elsif ($sensors{'temp1'} && $sensors{'mobo-temp'}){
+ elsif ($sensors->{'temp1'} && $sensors->{'mobo-temp'}){
$fan_type = 1;
}
}
# convert the diff number for F, it needs to be bigger that is
- if ($sensors{'temp-unit'} && $sensors{'temp-unit'} eq "F"){
+ if ($sensors->{'temp-unit'} && $sensors->{'temp-unit'} eq "F"){
$temp_diff = $temp_diff * 1.8
}
- if ($sensors{'cpu-temp'}){
+ if ($sensors->{'cpu-temp'}){
# specific hack to handle broken CPUTIN temps with PECI
- if ($sensors{'cpu-peci-temp'} && ($sensors{'cpu-temp'} - $sensors{'cpu-peci-temp'}) > $temp_diff){
- $cpu_temp = $sensors{'cpu-peci-temp'};
+ if ($sensors->{'cpu-peci-temp'} && ($sensors->{'cpu-temp'} - $sensors->{'cpu-peci-temp'}) > $temp_diff){
+ $cpu_temp = $sensors->{'cpu-peci-temp'};
}
# then get the real cpu temp, best guess is hottest is real, though only within narrowed diff range
else {
- $cpu_temp = $sensors{'cpu-temp'};
+ $cpu_temp = $sensors->{'cpu-temp'};
}
}
else {
if ($fan_type){
# there are some weird scenarios
if ($fan_type == 1){
- if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}){
- $cpu_temp = $sensors{'temp2'};
+ if ($sensors->{'temp1'} && $sensors->{'temp2'} && $sensors->{'temp2'} > $sensors->{'temp1'}){
+ $cpu_temp = $sensors->{'temp2'};
}
else {
- $cpu_temp = $sensors{'temp1'};
+ $cpu_temp = $sensors->{'temp1'};
}
}
else {
- if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}){
- $cpu_temp = $sensors{'temp1'};
+ if ($sensors->{'temp1'} && $sensors->{'temp2'} && $sensors->{'temp1'} > $sensors->{'temp2'}){
+ $cpu_temp = $sensors->{'temp1'};
}
else {
- $cpu_temp = $sensors{'temp2'};
+ $cpu_temp = $sensors->{'temp2'};
}
}
}
else {
- $cpu_temp = $sensors{'temp1'}; # can be null, that is ok
+ $cpu_temp = $sensors->{'temp1'}; # can be null, that is ok
}
if ($cpu_temp){
- # using $sensors{'temp3'} is just not reliable enough, more errors caused than fixed imo
- # if ($sensors{'temp3'} && $sensors{'temp3'} > $cpu_temp){
- # $cpu_temp = $sensors{'temp3'};
+ # using $sensors->{'temp3'} is just not reliable enough, more errors caused than fixed imo
+ # if ($sensors->{'temp3'} && $sensors->{'temp3'} > $cpu_temp){
+ # $cpu_temp = $sensors->{'temp3'};
# }
- # there are some absurdly wrong $sensors{'temp1'}: acpitz-virtual-0 $sensors{'temp1'}: +13.8°C
- if ($sensors{'core-0-temp'} && ($sensors{'core-0-temp'} - $cpu_temp) > $temp_diff){
- $cpu_temp = $sensors{'core-0-temp'};
+ # there are some absurdly wrong $sensors->{'temp1'}: acpitz-virtual-0 $sensors->{'temp1'}: +13.8°C
+ if ($sensors->{'core-0-temp'} && ($sensors->{'core-0-temp'} - $cpu_temp) > $temp_diff){
+ $cpu_temp = $sensors->{'core-0-temp'};
}
}
}
# if all else fails, use core0/peci temp if present and cpu is null
if (!$cpu_temp){
- if ($sensors{'core-0-temp'}){
- $cpu_temp = $sensors{'core-0-temp'};
+ if ($sensors->{'core-0-temp'}){
+ $cpu_temp = $sensors->{'core-0-temp'};
}
# note that peci temp is known to be colder than the actual system
# sometimes so it is the last fallback we want to use even though in theory
# it is more accurate, but fact suggests theory wrong.
- elsif ($sensors{'cpu-peci-temp'}){
- $cpu_temp = $sensors{'cpu-peci-temp'};
+ elsif ($sensors->{'cpu-peci-temp'}){
+ $cpu_temp = $sensors->{'cpu-peci-temp'};
}
}
# then the real mobo temp
- if ($sensors{'mobo-temp'}){
- $mobo_temp = $sensors{'mobo-temp'};
+ if ($sensors->{'mobo-temp'}){
+ $mobo_temp = $sensors->{'mobo-temp'};
}
elsif ($fan_type){
if ($fan_type == 1){
- if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}){
- $mobo_temp = $sensors{'temp1'};
+ if ($sensors->{'temp1'} && $sensors->{'temp2'} && $sensors->{'temp2'} > $sensors->{'temp1'}){
+ $mobo_temp = $sensors->{'temp1'};
}
else {
- $mobo_temp = $sensors{'temp2'};
+ $mobo_temp = $sensors->{'temp2'};
}
}
else {
- if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}){
- $mobo_temp = $sensors{'temp2'};
+ if ($sensors->{'temp1'} && $sensors->{'temp2'} && $sensors->{'temp1'} > $sensors->{'temp2'}){
+ $mobo_temp = $sensors->{'temp2'};
}
else {
- $mobo_temp = $sensors{'temp1'};
+ $mobo_temp = $sensors->{'temp1'};
}
}
- ## NOTE: not safe to assume $sensors{'temp3'} is the mobo temp, sad to say
- # if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp3'} && $sensors{'temp3'} < $mobo_temp){
- # $mobo_temp = $sensors{'temp3'};
+ ## NOTE: not safe to assume $sensors->{'temp3'} is the mobo temp, sad to say
+ # if ($sensors->{'temp1'} && $sensors->{'temp2'} && $sensors->{'temp3'} && $sensors->{'temp3'} < $mobo_temp){
+ # $mobo_temp = $sensors->{'temp3'};
# }
}
# in case with cpu-temp AND temp1 and not temp 2, or temp 2 only, fan type: 0
else {
- if ($sensors{'cpu-temp'} && $sensors{'temp1'} &&
- $sensors{'cpu-temp'} > $sensors{'temp1'}){
- $mobo_temp = $sensors{'temp1'};
+ if ($sensors->{'cpu-temp'} && $sensors->{'temp1'} &&
+ $sensors->{'cpu-temp'} > $sensors->{'temp1'}){
+ $mobo_temp = $sensors->{'temp1'};
}
- elsif ($sensors{'temp2'}){
- $mobo_temp = $sensors{'temp2'};
+ elsif ($sensors->{'temp2'}){
+ $mobo_temp = $sensors->{'temp2'};
}
}
- @fan_main = @{$sensors{'fan-main'}} if $sensors{'fan-main'};
+ @fan_main = @{$sensors->{'fan-main'}} if $sensors->{'fan-main'};
$index_count_fan_main = (@fan_main) ? scalar @fan_main : 0;
- @fan_default = @{$sensors{'fan-default'}} if $sensors{'fan-default'};
+ @fan_default = @{$sensors->{'fan-default'}} if $sensors->{'fan-default'};
$index_count_fan_default = (@fan_default) ? scalar @fan_default : 0;
# then set the cpu fan speed
if (!$fan_main[1]){
@@ -23049,35 +23804,35 @@ sub process_data {
}
# if they are ALL null, print error message. psFan is not used in output currently
if (!$cpu_temp && !$mobo_temp && !$fan_main[1] && !$fan_main[2] && !$fan_main[1] && !@fan_default){
- %sensors = ();
+ %$sensors = ();
}
else {
my ($ambient_temp,$psu_fan,$psu1_fan,$psu2_fan,$psu_temp,$sodimm_temp,
$v_12,$v_5,$v_3_3,$v_dimm_p1,$v_dimm_p2,$v_soc_p1,$v_soc_p2,$v_vbat);
- $psu_temp = $sensors{'psu-temp'} if $sensors{'psu-temp'};
+ $psu_temp = $sensors->{'psu-temp'} if $sensors->{'psu-temp'};
# sodimm fan is fan_main[4]
- $sodimm_temp = $sensors{'sodimm-temp'} if $sensors{'sodimm-temp'};
- $cpu2_temp = $sensors{'cpu2-temp'} if $sensors{'cpu2-temp'};
- $cpu3_temp = $sensors{'cpu3-temp'} if $sensors{'cpu3-temp'};
- $cpu4_temp = $sensors{'cpu4-temp'} if $sensors{'cpu4-temp'};
- $ambient_temp = $sensors{'ambient-temp'} if $sensors{'ambient-temp'};
- $pch_temp = $sensors{'pch-temp'} if $sensors{'pch-temp'};
- $psu_fan = $sensors{'fan-psu'} if $sensors{'fan-psu'};
- $psu1_fan = $sensors{'fan-psu-1'} if $sensors{'fan-psu-1'};
- $psu2_fan = $sensors{'fan-psu-2'} if $sensors{'fan-psu-2'};
+ $sodimm_temp = $sensors->{'sodimm-temp'} if $sensors->{'sodimm-temp'};
+ $cpu2_temp = $sensors->{'cpu2-temp'} if $sensors->{'cpu2-temp'};
+ $cpu3_temp = $sensors->{'cpu3-temp'} if $sensors->{'cpu3-temp'};
+ $cpu4_temp = $sensors->{'cpu4-temp'} if $sensors->{'cpu4-temp'};
+ $ambient_temp = $sensors->{'ambient-temp'} if $sensors->{'ambient-temp'};
+ $pch_temp = $sensors->{'pch-temp'} if $sensors->{'pch-temp'};
+ $psu_fan = $sensors->{'fan-psu'} if $sensors->{'fan-psu'};
+ $psu1_fan = $sensors->{'fan-psu-1'} if $sensors->{'fan-psu-1'};
+ $psu2_fan = $sensors->{'fan-psu-2'} if $sensors->{'fan-psu-2'};
# so far only for ipmi, sensors data is junk for volts
- if ($extra > 0 && ($sensors{'volts-12'} || $sensors{'volts-5'} ||
- $sensors{'volts-3.3'} || $sensors{'volts-vbat'})){
- $v_12 = $sensors{'volts-12'} if $sensors{'volts-12'};
- $v_5 = $sensors{'volts-5'} if $sensors{'volts-5'};
- $v_3_3 = $sensors{'volts-3.3'} if $sensors{'volts-3.3'};
- $v_vbat = $sensors{'volts-vbat'} if $sensors{'volts-vbat'};
- $v_dimm_p1 = $sensors{'volts-dimm-p1'} if $sensors{'volts-dimm-p1'};
- $v_dimm_p2 = $sensors{'volts-dimm-p2'} if $sensors{'volts-dimm-p2'};
- $v_soc_p1 = $sensors{'volts-soc-p1'} if $sensors{'volts-soc-p1'};
- $v_soc_p2 = $sensors{'volts-soc-p2'} if $sensors{'volts-soc-p2'};
- }
- %sensors = (
+ if ($extra > 0 && ($sensors->{'volts-12'} || $sensors->{'volts-5'} ||
+ $sensors->{'volts-3.3'} || $sensors->{'volts-vbat'})){
+ $v_12 = $sensors->{'volts-12'} if $sensors->{'volts-12'};
+ $v_5 = $sensors->{'volts-5'} if $sensors->{'volts-5'};
+ $v_3_3 = $sensors->{'volts-3.3'} if $sensors->{'volts-3.3'};
+ $v_vbat = $sensors->{'volts-vbat'} if $sensors->{'volts-vbat'};
+ $v_dimm_p1 = $sensors->{'volts-dimm-p1'} if $sensors->{'volts-dimm-p1'};
+ $v_dimm_p2 = $sensors->{'volts-dimm-p2'} if $sensors->{'volts-dimm-p2'};
+ $v_soc_p1 = $sensors->{'volts-soc-p1'} if $sensors->{'volts-soc-p1'};
+ $v_soc_p2 = $sensors->{'volts-soc-p2'} if $sensors->{'volts-soc-p2'};
+ }
+ %$sensors = (
'ambient-temp' => $ambient_temp,
'cpu-temp' => $cpu_temp,
'cpu2-temp' => $cpu2_temp,
@@ -23086,7 +23841,7 @@ sub process_data {
'mobo-temp' => $mobo_temp,
'pch-temp' => $pch_temp,
'psu-temp' => $psu_temp,
- 'temp-unit' => $sensors{'temp-unit'},
+ 'temp-unit' => $sensors->{'temp-unit'},
'fan-main' => \@fan_main,
'fan-default' => \@fan_default,
'fan-psu' => $psu_fan,
@@ -23094,30 +23849,29 @@ sub process_data {
'fan-psu2' => $psu2_fan,
);
if ($psu_temp){
- $sensors{'psu-temp'} = $psu_temp;
+ $sensors->{'psu-temp'} = $psu_temp;
}
if ($sodimm_temp){
- $sensors{'sodimm-temp'} = $sodimm_temp;
+ $sensors->{'sodimm-temp'} = $sodimm_temp;
}
if ($extra > 0 && ($v_12 || $v_5 || $v_3_3 || $v_vbat)){
- $sensors{'volts-12'} = $v_12;
- $sensors{'volts-5'} = $v_5;
- $sensors{'volts-3.3'} = $v_3_3;
- $sensors{'volts-vbat'} = $v_vbat;
- $sensors{'volts-dimm-p1'} = $v_dimm_p1;
- $sensors{'volts-dimm-p2'} = $v_dimm_p2;
- $sensors{'volts-soc-p1'} = $v_soc_p1;
- $sensors{'volts-soc-p2'} = $v_soc_p2;
+ $sensors->{'volts-12'} = $v_12;
+ $sensors->{'volts-5'} = $v_5;
+ $sensors->{'volts-3.3'} = $v_3_3;
+ $sensors->{'volts-vbat'} = $v_vbat;
+ $sensors->{'volts-dimm-p1'} = $v_dimm_p1;
+ $sensors->{'volts-dimm-p2'} = $v_dimm_p2;
+ $sensors->{'volts-soc-p1'} = $v_soc_p1;
+ $sensors->{'volts-soc-p2'} = $v_soc_p2;
}
}
eval $end if $b_log;
- return %sensors;
}
-sub gpu_data {
+sub gpu_sensor_data {
eval $start if $b_log;
- return @gpudata if $loaded{'gpu-data'};
my ($cmd,@data,@data2,$path,@screens,$temp);
- my ($j) = (0);
+ my $j = 0;
+ $loaded{'gpu-data'} = 1;
if ($path = main::check_program('nvidia-settings')){
# first get the number of screens. This only work if you are in X
if ($b_display){
@@ -23157,31 +23911,31 @@ sub gpu_data {
@data = main::grabber($cmd);
main::log_data('cmd',$cmd) if $b_log;
push(@data,@data2);
- $j = scalar @gpudata;
+ $j = scalar @$gpu_data;
foreach my $item (@data){
if ($item =~ /^\s*Attribute\s\'([^']+)\'\s.*:\s*([\S]+)\.$/){
my $attribute = $1;
my $value = $2;
- $gpudata[$j]->{'type'} = 'nvidia';
- $gpudata[$j]->{'speed-unit'} = '%';
- $gpudata[$j]->{'screen'} = $screen;
- if (!$gpudata[$j]->{'temp'} && $attribute eq 'GPUCoreTemp'){
- $gpudata[$j]->{'temp'} = $value;
+ $gpu_data->[$j]{'type'} = 'nvidia';
+ $gpu_data->[$j]{'speed-unit'} = '%';
+ $gpu_data->[$j]{'screen'} = $screen;
+ if (!$gpu_data->[$j]{'temp'} && $attribute eq 'GPUCoreTemp'){
+ $gpu_data->[$j]{'temp'} = $value;
}
- elsif (!$gpudata[$j]->{'ram'} && $attribute eq 'VideoRam'){
- $gpudata[$j]->{'ram'} = $value;
+ elsif (!$gpu_data->[$j]{'ram'} && $attribute eq 'VideoRam'){
+ $gpu_data->[$j]{'ram'} = $value;
}
- elsif (!$gpudata[$j]->{'clock'} && $attribute eq 'GPUCurrentClockFreqs'){
- $gpudata[$j]->{'clock'} = $value;
+ elsif (!$gpu_data->[$j]{'clock'} && $attribute eq 'GPUCurrentClockFreqs'){
+ $gpu_data->[$j]{'clock'} = $value;
}
- elsif (!$gpudata[$j]->{'bus'} && $attribute eq 'PCIBus'){
- $gpudata[$j]->{'bus'} = $value;
+ elsif (!$gpu_data->[$j]{'bus'} && $attribute eq 'PCIBus'){
+ $gpu_data->[$j]{'bus'} = $value;
}
- elsif (!$gpudata[$j]->{'bus-id'} && $attribute eq 'PCIDevice'){
- $gpudata[$j]->{'bus-id'} = $value;
+ elsif (!$gpu_data->[$j]{'bus-id'} && $attribute eq 'PCIDevice'){
+ $gpu_data->[$j]{'bus-id'} = $value;
}
- elsif (!$gpudata[$j]->{'fan-speed'} && $attribute eq 'GPUCurrentFanSpeed'){
- $gpudata[$j]->{'fan-speed'} = $value;
+ elsif (!$gpu_data->[$j]{'fan-speed'} && $attribute eq 'GPUCurrentFanSpeed'){
+ $gpu_data->[$j]{'fan-speed'} = $value;
}
}
}
@@ -23192,53 +23946,50 @@ sub gpu_data {
@data = main::grabber("$path --adapter=all --od-gettemperature 2>/dev/null");
foreach (@data){
if (/Sensor [^0-9]*([0-9\.]+) /){
- $j = scalar @gpudata;
+ $j = scalar @$gpu_data;
my $value = $1;
- $gpudata[$j]->{'type'} = 'amd';
- $gpudata[$j]->{'temp'} = $value;
+ $gpu_data->[$j]{'type'} = 'amd';
+ $gpu_data->[$j]{'temp'} = $value;
}
}
}
- if ($sensors_raw{'gpu'}){
+ if ($sensors_raw->{'gpu'}){
# my ($b_found,$holder) = (0,'');
- foreach my $adapter (keys %{$sensors_raw{'gpu'}}){
- $j = scalar @gpudata;
- $gpudata[$j]->{'type'} = $adapter;
- $gpudata[$j]->{'type'} =~ s/^(amdgpu|intel|nouveau|radeon)-.*/$1/;
+ foreach my $adapter (keys %{$sensors_raw->{'gpu'}}){
+ $j = scalar @$gpu_data;
+ $gpu_data->[$j]{'type'} = $adapter;
+ $gpu_data->[$j]{'type'} =~ s/^(amdgpu|intel|nouveau|radeon)-.*/$1/;
# print "ad: $adapter\n";
- foreach (@{$sensors_raw{'gpu'}->{$adapter}}){
+ foreach (@{$sensors_raw->{'gpu'}{$adapter}}){
# print "val: $_\n";
if (/^[^:]*mem[^:]*:([0-9\.]+).*\b(C|F)\b/i){
- $gpudata[$j]->{'temp-mem'} = $1;
- $gpudata[$j]->{'unit'} = $2;
+ $gpu_data->[$j]{'temp-mem'} = $1;
+ $gpu_data->[$j]{'unit'} = $2;
# print "temp: $_\n";
}
elsif (/^[^:]+:([0-9\.]+).*\b(C|F)\b/i){
- $gpudata[$j]->{'temp'} = $1;
- $gpudata[$j]->{'unit'} = $2;
+ $gpu_data->[$j]{'temp'} = $1;
+ $gpu_data->[$j]{'unit'} = $2;
# print "temp: $_\n";
}
# speeds can be in percents or rpms, so need the 'fan' in regex
elsif (/^.*?fan.*?:([0-9\.]+).*(RPM)?/i){
- $gpudata[$j]->{'fan-speed'} = $1;
+ $gpu_data->[$j]{'fan-speed'} = $1;
# NOTE: we test for nvidia %, everything else stays with nothing
- $gpudata[$j]->{'speed-unit'} = '';
+ $gpu_data->[$j]{'speed-unit'} = '';
}
elsif (/^[^:]+:([0-9\.]+)\s+W\s/i){
- $gpudata[$j]->{'watts'} = $1;
+ $gpu_data->[$j]{'watts'} = $1;
}
elsif (/^[^:]+:([0-9\.]+)\s+mV\s/i){
- $gpudata[$j]->{'mvolts'} = $1;
+ $gpu_data->[$j]{'mvolts'} = $1;
}
}
}
}
- main::log_data('dump','sensors output: video: @gpudata',\@gpudata);
- # we'll probably use this data elsewhere so make it a one time call
- $loaded{'gpu-data'} = 1;
- print 'gpudata: ', Data::Dumper::Dumper \@gpudata if $dbg[18];
+ main::log_data('dump','sensors output: video: @$gpu_data',$gpu_data) if $b_log;
+ print 'gpu_data: ', Data::Dumper::Dumper $gpu_data if $dbg[18];
eval $end if $b_log;
- return @gpudata;
}
}
@@ -23248,7 +23999,8 @@ package SlotItem;
my ($sys_slots);
sub get {
eval $start if $b_log;
- my ($data,@rows,$key1,$val1);
+ my ($data,$key1,$val1);
+ my $rows = [];
my $num = 0;
if ($fake{'dmidecode'} || ($alerts{'dmidecode'}->{'action'} eq 'use' &&
(!%risc || $use{'slot-tool'}))){
@@ -23256,88 +24008,86 @@ sub get {
slot_data_sys();
}
$data = slot_data_dmi();
- @rows = slot_output($data) if $data;
- if (!@rows){
+ slot_output($rows,$data) if @$data;
+ if (!@$rows){
my $key = 'Message';
- push(@rows, {
- main::key($num++,0,1,$key) => main::message('pci-slot-data',''),
- },);
+ push(@$rows, {
+ main::key($num++,0,1,$key) => main::message('pci-slot-data','')
+ });
}
}
elsif (%risc && !$use{'slot-tool'}){
$key1 = 'Message';
$val1 = main::message('risc-pci',$risc{'id'});
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
elsif ($alerts{'dmidecode'}->{'action'} ne 'use'){
$key1 = $alerts{'dmidecode'}->{'action'};
$val1 = $alerts{'dmidecode'}->{'message'};
$key1 = ucfirst($key1);
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub slot_output {
eval $start if $b_log;
- my $data = $_[0];
- my (@rows);
+ my ($rows,$data) = @_;
my $num = 1;
foreach my $slot_data (@$data){
next if !$slot_data || ref $slot_data ne 'HASH';
$num = 1;
- my $j = scalar @rows;
+ my $j = scalar @$rows;
$slot_data->{'id'} = 'N/A' if !defined $slot_data->{'id'}; # can be 0
$slot_data->{'pci'} ||= 'N/A';
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Slot') => $slot_data->{'id'},
main::key($num++,0,2,'type') => $slot_data->{'pci'},
},);
# PCIe only
if ($extra > 1 && $slot_data->{'gen'}){
- $rows[$j]->{main::key($num++,0,2,'gen')} = $slot_data->{'gen'};
+ $rows->[$j]{main::key($num++,0,2,'gen')} = $slot_data->{'gen'};
}
if ($slot_data->{'lanes-phys'} && $slot_data->{'lanes-active'} &&
$slot_data->{'lanes-phys'} ne $slot_data->{'lanes-active'}){
- $rows[$j]->{main::key($num++,1,2,'lanes')} = '';
- $rows[$j]->{main::key($num++,0,3,'phys')} = $slot_data->{'lanes-phys'};
- $rows[$j]->{main::key($num++,0,3,'active')} = $slot_data->{'lanes-active'};
+ $rows->[$j]{main::key($num++,1,2,'lanes')} = '';
+ $rows->[$j]{main::key($num++,0,3,'phys')} = $slot_data->{'lanes-phys'};
+ $rows->[$j]{main::key($num++,0,3,'active')} = $slot_data->{'lanes-active'};
}
elsif ($slot_data->{'lanes-phys'}){
- $rows[$j]->{main::key($num++,0,2,'lanes')} = $slot_data->{'lanes-phys'};
+ $rows->[$j]{main::key($num++,0,2,'lanes')} = $slot_data->{'lanes-phys'};
}
# Non PCIe only
if ($extra > 1 && $slot_data->{'bits'}){
- $rows[$j]->{main::key($num++,0,2,'bits')} = $slot_data->{'bits'};
+ $rows->[$j]{main::key($num++,0,2,'bits')} = $slot_data->{'bits'};
}
# PCI-X and PCI only
if ($extra > 1 && $slot_data->{'mhz'}){
- $rows[$j]->{main::key($num++,0,2,'MHz')} = $slot_data->{'mhz'};
+ $rows->[$j]{main::key($num++,0,2,'MHz')} = $slot_data->{'mhz'};
}
- $rows[$j]->{main::key($num++,0,2,'status')} = $slot_data->{'usage'};
+ $rows->[$j]{main::key($num++,0,2,'status')} = $slot_data->{'usage'};
if ($slot_data->{'extra'}){
- $rows[$j]->{main::key($num++,0,2,'info')} = join(', ', @{$slot_data->{'extra'}});
+ $rows->[$j]{main::key($num++,0,2,'info')} = join(', ', @{$slot_data->{'extra'}});
}
if ($extra > 1){
$slot_data->{'length'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'length')} = $slot_data->{'length'};
+ $rows->[$j]{main::key($num++,0,2,'length')} = $slot_data->{'length'};
if ($slot_data->{'cpu'}){
- $rows[$j]->{main::key($num++,0,2,'cpu')} = $slot_data->{'cpu'};
+ $rows->[$j]{main::key($num++,0,2,'cpu')} = $slot_data->{'cpu'};
}
if ($slot_data->{'volts'}){
- $rows[$j]->{main::key($num++,0,2,'volts')} = $slot_data->{'volts'};
+ $rows->[$j]{main::key($num++,0,2,'volts')} = $slot_data->{'volts'};
}
}
if ($extra > 0){
$slot_data->{'bus_address'} ||= 'N/A';
- $rows[$j]->{main::key($num++,1,2,'bus-ID')} = $slot_data->{'bus_address'};
+ $rows->[$j]{main::key($num++,1,2,'bus-ID')} = $slot_data->{'bus_address'};
if ($b_admin && $slot_data->{'children'}){
- children_output(\@rows,$j,\$num,$slot_data->{'children'},3);
+ children_output($rows,$j,\$num,$slot_data->{'children'},3);
}
}
}
eval $end if $b_log;
- return @rows;
}
sub children_output {
my ($rows,$j,$num,$children,$ind) = @_;
@@ -23362,7 +24112,7 @@ sub children_output {
sub slot_data_dmi {
eval $start if $b_log;
my $i = 0;
- my @slots;
+ my $slots = [];
foreach my $slot_data (@dmi){
next if $slot_data->[0] != 9;
my (%data,@extra);
@@ -23463,12 +24213,12 @@ sub slot_data_dmi {
@extra = grep {$_ ne $data{'pci'}} @extra;
}
$data{'extra'} = [@extra] if @extra;
- push(@slots,{%data}) if %data;
+ push(@$slots,{%data}) if %data;
}
- print '@slots: ', Data::Dumper::Dumper \@slots if $dbg[48];
- main::log_data('dump','@slots final',\@slots) if $b_log;
+ print '@$slots: ', Data::Dumper::Dumper $slots if $dbg[48];
+ main::log_data('dump','@$slots final',$slots) if $b_log;
eval $end if $b_log;
- return \@slots if @slots;
+ return $slots;
}
sub slot_data_sys {
eval $start if $b_log;
@@ -23552,19 +24302,18 @@ package SwapItem;
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
- @rows = create_output();
- if (!@rows){
- push(@rows,
- {main::key($num++,0,1,'Alert') => main::message('swap-data')},
- );
+ create_output($rows);
+ if (!@$rows){
+ @$rows = ({main::key($num++,0,1,'Alert') => main::message('swap-data')});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub create_output {
eval $start if $b_log;
+ my $rows = $_[0];
my $num = 0;
my $j = 0;
my (@rows,$dev,$percent,$raw_size,$size,$used);
@@ -23582,20 +24331,20 @@ sub create_output {
if ($b_admin && !$bsd_type && $j == 0){
$j = scalar @rows;
if (defined $row->{'swappiness'} || defined $row->{'cache-pressure'}){
- $rows[$j]->{main::key($num++,1,1,'Kernel')} = '';
+ $rows->[$j]{main::key($num++,1,1,'Kernel')} = '';
if (defined $row->{'swappiness'}){
- $rows[$j]->{main::key($num++,0,2,'swappiness')} = $row->{'swappiness'};
+ $rows->[$j]{main::key($num++,0,2,'swappiness')} = $row->{'swappiness'};
}
if (defined $row->{'cache-pressure'}){
- $rows[$j]->{main::key($num++,0,2,'cache-pressure')} = $row->{'cache-pressure'};
+ $rows->[$j]{main::key($num++,0,2,'cache-pressure')} = $row->{'cache-pressure'};
}
}
else {
- $rows[$j]->{main::key($num++,0,1,'Message')} = main::message('swap-admin');
+ $rows->[$j]{main::key($num++,0,1,'Message')} = main::message('swap-admin');
}
}
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'ID') => $row->{'id'},
main::key($num++,0,2,'type') => $row->{'swap-type'},
});
@@ -23603,48 +24352,47 @@ sub create_output {
if ($b_admin && $row->{'raw-size'}){
# It's an error! permissions or missing tool
$raw_size = main::get_size($row->{'raw-size'},'string');
- $rows[$j]->{main::key($num++,0,2,'raw-size')} = $raw_size;
+ $rows->[$j]{main::key($num++,0,2,'raw-size')} = $raw_size;
}
# not used for swap as far as I know
if ($b_admin && $row->{'raw-available'} && $size ne 'N/A'){
$size .= ' (' . $row->{'raw-available'} . '%)';
}
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
- $rows[$j]->{main::key($num++,0,2,'used')} = $used . $percent;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'used')} = $used . $percent;
# not used for swap as far as I know
if ($b_admin && $row->{'block-size'}){
- $rows[$j]->{main::key($num++,0,2,'block-size')} = $row->{'block-size'} . ' B';;
- #$rows[$j]->{main::key($num++,0,2,'physical')} = $row->{'block-size'} . ' B';
- #$rows[$j]->{main::key($num++,0,2,'logical')} = $row->{'block-logical'} . ' B';
+ $rows->[$j]{main::key($num++,0,2,'block-size')} = $row->{'block-size'} . ' B';;
+ #$rows->[$j]{main::key($num++,0,2,'physical')} = $row->{'block-size'} . ' B';
+ #$rows->[$j]{main::key($num++,0,2,'logical')} = $row->{'block-logical'} . ' B';
}
if ($extra > 1 && defined $row->{'priority'}){
- $rows[$j]->{main::key($num++,0,2,'priority')} = $row->{'priority'};
+ $rows->[$j]{main::key($num++,0,2,'priority')} = $row->{'priority'};
}
$row->{'mount'} =~ s|/home/[^/]+/(.*)|/home/$filter_string/$1| if $row->{'mount'} && $use{'filter'};
- $rows[$j]->{main::key($num++,1,2,$dev)} = ($row->{'mount'}) ? $row->{'mount'} : 'N/A';
+ $rows->[$j]{main::key($num++,1,2,$dev)} = ($row->{'mount'}) ? $row->{'mount'} : 'N/A';
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,3,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,3,'maj-min')} = $row->{'maj-min'};
}
if ($extra > 0 && $row->{'dev-mapped'}){
- $rows[$j]->{main::key($num++,0,3,'mapped')} = $row->{'dev-mapped'};
+ $rows->[$j]{main::key($num++,0,3,'mapped')} = $row->{'dev-mapped'};
}
if ($show{'label'} && ($row->{'label'} || $row->{'swap-type'} eq 'partition')){
if ($use{'filter-label'}){
$row->{'label'} = main::filter_partition('part', $row->{'label'}, '');
}
$row->{'label'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'};
+ $rows->[$j]{main::key($num++,0,2,'label')} = $row->{'label'};
}
if ($show{'uuid'} && ($row->{'uuid'} || $row->{'swap-type'} eq 'partition')){
if ($use{'filter-uuid'}){
$row->{'uuid'} = main::filter_partition('part', $row->{'uuid'}, '');
}
$row->{'uuid'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
+ $rows->[$j]{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
}
}
eval $end if $b_log;
- return @rows;
}
}
@@ -23655,19 +24403,20 @@ package UnmountedItem;
sub get {
eval $start if $b_log;
- my (@data,@rows,$key1,$val1);
+ my ($data,$key1,$val1);
+ my $rows = [];
my $num = 0;
if ($bsd_type){
DiskDataBSD::set() if !$loaded{'disk-data-bsd'};
if (%disks_bsd && ($alerts{'disklabel'}->{'action'} eq 'use' ||
$alerts{'gpart'}->{'action'} eq 'use')){
- @data = bsd_data();
- if (!@data){
+ $data = bsd_data();
+ if (!@$data){
$key1 = 'Message';
$val1 = main::message('unmounted-data');
}
else {
- @rows = create_output(\@data);
+ create_output($rows,$data);
}
}
else {
@@ -23683,13 +24432,13 @@ sub get {
}
else {
if ($system_files{'proc-partitions'}){
- @data = proc_data();
- if (!@data){
+ $data = proc_data();
+ if (!@$data){
$key1 = 'Message';
$val1 = main::message('unmounted-data');
}
else {
- @rows = create_output(\@data);
+ create_output($rows,$data);
}
}
else {
@@ -23697,16 +24446,16 @@ sub get {
$val1 = main::message('unmounted-file');
}
}
- if (!@rows && $key1){
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ if (!@$rows && $key1){
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub create_output {
eval $start if $b_log;
- my ($unmounted) = @_;
- my (@rows,$fs);
+ my ($rows,$unmounted) = @_;
+ my ($fs);
my ($j,$num) = (0,0);
@$unmounted = sort { $a->{'dev-base'} cmp $b->{'dev-base'} } @$unmounted;
my $fs_skip = PartitionItem::fs_excludes('label-uuid');
@@ -23727,20 +24476,20 @@ sub create_output {
$fs = main::message('tool-missing-basic','file');
}
}
- $j = scalar @rows;
- push(@rows, {
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'ID') => "/dev/$row->{'dev-base'}",
});
if ($b_admin && $row->{'maj-min'}){
- $rows[$j]->{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
+ $rows->[$j]{main::key($num++,0,2,'maj-min')} = $row->{'maj-min'};
}
if ($extra > 0 && $row->{'dev-mapped'}){
- $rows[$j]->{main::key($num++,0,2,'mapped')} = $row->{'dev-mapped'};
+ $rows->[$j]{main::key($num++,0,2,'mapped')} = $row->{'dev-mapped'};
}
$row->{'label'} ||= 'N/A';
$row->{'uuid'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'size')} = $size;
- $rows[$j]->{main::key($num++,0,2,'fs')} = $fs;
+ $rows->[$j]{main::key($num++,0,2,'size')} = $size;
+ $rows->[$j]{main::key($num++,0,2,'fs')} = $fs;
# don't show for fs known to not have label/uuid
if (($show{'label'} || $show{'uuid'}) && $fs !~ /^$fs_skip$/){
if ($show{'label'}){
@@ -23748,23 +24497,23 @@ sub create_output {
$row->{'label'} = main::filter_partition('part', $row->{'label'}, '');
}
$row->{'label'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'};
+ $rows->[$j]{main::key($num++,0,2,'label')} = $row->{'label'};
}
if ($show{'uuid'}){
if ($use{'filter-uuid'}){
$row->{'uuid'} = main::filter_partition('part', $row->{'uuid'}, '');
}
$row->{'uuid'} ||= 'N/A';
- $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
+ $rows->[$j]{main::key($num++,0,2,'uuid')} = $row->{'uuid'};
}
}
}
eval $end if $b_log;
- return @rows;
}
sub proc_data {
eval $start if $b_log;
- my ($dev_mapped,$fs,$label,$maj_min,$size,$uuid,%part,@unmounted);
+ my ($dev_mapped,$fs,$label,$maj_min,$size,$uuid,$part);
+ my $unmounted = [];
# last filters to make sure these are dumped
my @filters = ('scd[0-9]+','sr[0-9]+','cdrom[0-9]*','cdrw[0-9]*',
'dvd[0-9]*','dvdrw[0-9]*','fd[0-9]','ram[0-9]*');
@@ -23772,8 +24521,8 @@ sub proc_data {
# set labels, uuid, gpart
PartitionItem::set_partitions() if !$loaded{'set-partitions'};
RaidItem::raid_data() if !$loaded{'raid'};
- my @mounted = get_mounted();
- # print join("\n",(@filters,@mounted)),"\n";
+ my $mounted = get_mounted();
+ # print join("\n",(@filters,@$mounted)),"\n";
foreach my $row (@proc_partitions){
($dev_mapped,$fs,$label,$maj_min,$uuid,$size) = ('','','','','','');
# note that size 1 means it is a logical extended partition container
@@ -23793,19 +24542,19 @@ sub proc_data {
if ($row->[-1] !~ /^(nvme[0-9]+n|mmcblk|mtdblk|mtdblock)[0-9]+$/ &&
$row->[-1] =~ /[a-z][0-9]+$|dm-[0-9]+$/ &&
$row->[-1] !~ /\bloop/ &&
- !(grep {$row->[-1] =~ /$_$/} (@filters,@mounted)) &&
- !(grep {$_ =~ /(block\/)?$row->[-1]$/} @mounted) &&
- !(grep {$_ =~ /^sd[a-z]+$/ && $row->[-1] =~ /^$_[0-9]+/} @mounted)){
+ !(grep {$row->[-1] =~ /$_$/} (@filters,@$mounted)) &&
+ !(grep {$_ =~ /(block\/)?$row->[-1]$/} @$mounted) &&
+ !(grep {$_ =~ /^sd[a-z]+$/ && $row->[-1] =~ /^$_[0-9]+/} @$mounted)){
$dev_mapped = $dmmapper{$row->[-1]} if $dmmapper{$row->[-1]};
if (@lsblk){
my $id = ($dev_mapped) ? $dev_mapped: $row->[-1];
- %part = LsblkData::get($id);
- if (%part){
- $fs = $part{'fs'};
- $label = $part{'label'};
- $maj_min = $part{'maj-min'};
- $uuid = $part{'uuid'};
- $size = $part{'size'} if $part{'size'} && !$row->[2];
+ $part = LsblkData::get($id);
+ if (%$part){
+ $fs = $part->{'fs'};
+ $label = $part->{'label'};
+ $maj_min = $part->{'maj-min'};
+ $uuid = $part->{'uuid'};
+ $size = $part->{'size'} if $part->{'size'} && !$row->[2];
}
}
$size ||= $row->[2];
@@ -23826,7 +24575,7 @@ sub proc_data {
$uuid = $temp[2] if $temp[2];
}
$maj_min = "$row->[0]:$row->[1]" if !$maj_min;
- push(@unmounted, {
+ push(@$unmounted, {
'dev-base' => $row->[-1],
'dev-mapped' => $dev_mapped,
'fs' => $fs,
@@ -23837,28 +24586,29 @@ sub proc_data {
});
}
}
- print Data::Dumper::Dumper \@unmounted if $dbg[35];
- main::log_data('dump','@unmounted',\@unmounted) if $b_log;
+ print Data::Dumper::Dumper $unmounted if $dbg[35];
+ main::log_data('dump','@$unmounted',$unmounted) if $b_log;
eval $end if $b_log;
- return @unmounted;
+ return $unmounted;
}
sub bsd_data {
eval $start if $b_log;
- my ($fs,$label,$size,$uuid,%part,@unmounted);
+ my ($fs,$label,$size,$uuid,%part);
+ my $unmounted = [];
PartitionItem::set_partitions() if !$loaded{'set-partitions'};
RaidItem::raid_data() if !$loaded{'raid'};
- my @mounted = get_mounted();
+ my $mounted = get_mounted();
foreach my $id (sort keys %disks_bsd){
next if !$disks_bsd{$id}->{'partitions'};
foreach my $part (sort keys %{$disks_bsd{$id}->{'partitions'}}){
- if (!(grep {$_ =~ /$part$/} @mounted)){
+ if (!(grep {$_ =~ /$part$/} @$mounted)){
$fs = $disks_bsd{$id}->{'partitions'}{$part}{'fs'};
next if $fs && $fs =~ /(raid|_member)$/i;
$label = $disks_bsd{$id}->{'partitions'}{$part}{'label'};
$size = $disks_bsd{$id}->{'partitions'}{$part}{'size'};
$uuid = $disks_bsd{$id}->{'partitions'}{$part}{'uuid'};
# $fs = unmounted_filesystem($part) if !$fs;
- push(@unmounted, {
+ push(@$unmounted, {
'dev-base' => $part,
'dev-mapped' => '',
'fs' => $fs,
@@ -23870,21 +24620,22 @@ sub bsd_data {
}
}
}
- print Data::Dumper::Dumper \@unmounted if $dbg[35];
- main::log_data('dump','@unmounted',\@unmounted) if $b_log;
+ print Data::Dumper::Dumper $unmounted if $dbg[35];
+ main::log_data('dump','@$unmounted',$unmounted) if $b_log;
eval $end if $b_log;
- return @unmounted;
+ return $unmounted;
}
sub get_mounted {
eval $start if $b_log;
- my (@arrays,@mounted);
+ my (@arrays);
+ my $mounted = [];
foreach my $row (@partitions){
- push(@mounted, $row->{'dev-base'}) if $row->{'dev-base'};
+ push(@$mounted, $row->{'dev-base'}) if $row->{'dev-base'};
}
# print Data::Dumper::Dumper \@zfs_raid;
foreach my $row ((@btrfs_raid,@lvm_raid,@md_raid,@soft_raid,@zfs_raid)){
# we want to not show md0 etc in unmounted report
- push(@mounted, $row->{'id'}) if $row->{'id'};
+ push(@$mounted, $row->{'id'}) if $row->{'id'};
# print Data::Dumper::Dumper $row;
# row->arrays->components: zfs; row->components: lvm,mdraid,softraid
if ($row->{'arrays'} && ref $row->{'arrays'} eq 'ARRAY'){
@@ -23901,12 +24652,12 @@ sub get_mounted {
foreach my $component (@components){
# md has ~, not zfs,lvm,softraid
my $temp = (split('~', $component->[0]))[0];
- push(@mounted, $temp);
+ push(@$mounted, $temp);
}
}
}
eval $end if $b_log;
- return @mounted;
+ return $mounted;
}
# bsds do not seem to return any useful data so only for linux
sub unmounted_filesystem {
@@ -23948,7 +24699,8 @@ sub unmounted_filesystem {
package UsbItem;
sub get {
eval $start if $b_log;
- my (@rows,$key1,$val1);
+ my ($key1,$val1);
+ my $rows = [];
my $num = 0;
if (!$usb{'main'} && $alerts{'lsusb'}->{'action'} ne 'use' &&
$alerts{'usbdevs'}->{'action'} ne 'use' &&
@@ -23975,31 +24727,32 @@ sub get {
# }
}
$key1 = ucfirst($key1);
- @rows = ({main::key($num++,0,1,$key1) => $val1,});
+ @$rows = ({main::key($num++,0,1,$key1) => $val1});
}
else {
- @rows = usb_output();
- if (!@rows){
+ usb_output($rows);
+ if (!@$rows){
my $key = 'Message';
- push(@rows, {
- main::key($num++,0,1,$key) => main::message('usb-data',''),
- },);
+ @$rows = ({
+ main::key($num++,0,1,$key) => main::message('usb-data','')
+ });
}
}
eval $end if $b_log;
- return @rows;
+ return $rows;
}
sub usb_output {
eval $start if $b_log;
return if !$usb{'main'};
- my (@rows);
- my ($b_hub,$bus_id,$chip_id,$driver,$ind_sc,$path_id,$ports,$product,$serial,$speed,$type);
+ my $rows = $_[0];
+ my ($b_hub,$bus_id,$chip_id,$driver,$ind_sc,$path_id,$ports,$product,$serial,
+ $speed,$type);
my $num = 0;
my $j = 0;
# note: the data has been presorted in UsbData:
# bus alpah id, so we don't need to worry about the order
foreach my $id (@{$usb{'main'}}){
- $j = scalar @rows;
+ $j = scalar @$rows;
($b_hub,$ind_sc,$num) = (0,3,1);
($driver,$path_id,$ports,$product,
$serial,$speed,$type) = ('','','','','','','');
@@ -24015,7 +24768,7 @@ sub usb_output {
$ports = $id->[10] if $id->[10];
$ports ||= 'N/A';
# print "pt0:$protocol\n";
- push(@rows, {
+ push(@$rows, {
main::key($num++,1,1,'Hub') => $bus_id,
main::key($num++,0,2,'info') => $product,
main::key($num++,0,2,'ports') => $ports,
@@ -24031,45 +24784,44 @@ sub usb_output {
$type ||= 'N/A';
$driver ||= 'N/A';
# print "pt3:$class:$product\n";
- $rows[$j]->{main::key($num++,1,2,'Device')} = $bus_id;
- $rows[$j]->{main::key($num++,0,3,'info')} = $product;
- $rows[$j]->{main::key($num++,0,3,'type')} = $type;
+ $rows->[$j]{main::key($num++,1,2,'Device')} = $bus_id;
+ $rows->[$j]{main::key($num++,0,3,'info')} = $product;
+ $rows->[$j]{main::key($num++,0,3,'type')} = $type;
if ($extra > 0){
- $rows[$j]->{main::key($num++,0,3,'driver')} = $driver;
+ $rows->[$j]{main::key($num++,0,3,'driver')} = $driver;
}
if ($extra > 2 && $id->[9]){
- $rows[$j]->{main::key($num++,0,3,'interfaces')} = $id->[9];
+ $rows->[$j]{main::key($num++,0,3,'interfaces')} = $id->[9];
}
- $rows[$j]->{main::key($num++,0,3,'rev')} = $speed;
+ $rows->[$j]{main::key($num++,0,3,'rev')} = $speed;
}
# for either hub or device
if ($extra > 1 && main::is_numeric($id->[17])){
my $speed = $id->[17];
if ($speed >= 1000){$speed = ($id->[17]/1000) . " Gb/s"}
else {$speed = $id->[17] . " Mb/s"}
- $rows[$j]->{main::key($num++,0,$ind_sc,'speed')} = $speed;
+ $rows->[$j]{main::key($num++,0,$ind_sc,'speed')} = $speed;
}
if ($extra > 2 && $id->[19] && $id->[19] ne '0mA'){
- $rows[$j]->{main::key($num++,0,$ind_sc,'power')} = $id->[19];
+ $rows->[$j]{main::key($num++,0,$ind_sc,'power')} = $id->[19];
}
if ($extra > 1){
$chip_id = $id->[7];
$chip_id ||= 'N/A';
- $rows[$j]->{main::key($num++,0,$ind_sc,'chip-ID')} = $chip_id;
+ $rows->[$j]{main::key($num++,0,$ind_sc,'chip-ID')} = $chip_id;
}
if ($extra > 2 && defined $id->[5] && $id->[5] ne ''){
my $id = sprintf("%02s",$id->[4]) . sprintf("%02s", $id->[5]);
- $rows[$j]->{main::key($num++,0,$ind_sc,'class-ID')} = $id;
+ $rows->[$j]{main::key($num++,0,$ind_sc,'class-ID')} = $id;
}
if (!$b_hub && $extra > 2){
if ($serial){
- $rows[$j]->{main::key($num++,0,$ind_sc,'serial')} = main::filter($serial);
+ $rows->[$j]{main::key($num++,0,$ind_sc,'serial')} = main::filter($serial);
}
}
}
# print Data::Dumper::Dumper \@rows;
eval $end if $b_log;
- return @rows;
}
}
@@ -24079,143 +24831,167 @@ sub usb_output {
package WeatherItem;
sub get {
eval $start if $b_log;
- my (@rows);
+ my $rows = [];
my $num = 0;
- @rows = weather_output();
- eval $end if $b_log;
- return @rows;
-}
-sub weather_output {
- eval $start if $b_log;
- my ($j,$num) = (0,0);
- my (@location,@rows,$value,%weather,);
- my ($conditions) = ('NA');
- if ($show{'weather-location'}){
- my $location_string;
- $location_string = $show{'weather-location'};
- $location_string =~ s/\+/ /g;
- if ($location_string =~ /,/){
- my @temp = split(',', $location_string);
- my $sep = '';
- my $string = '';
- foreach (@temp){
- $_ = ucfirst($_);
- $string .= $sep . $_;
- $sep = ', ';
- }
- $location_string = $string;
- }
- $location_string = main::filter($location_string);
- @location = ($show{'weather-location'},$location_string,'');
+ my $location = [];
+ location_data($location);
+ if (!$location->[0]){
+ @$rows = ({
+ main::key($num++,0,1,'Message') => main::message('weather-null','current location')
+ });
}
else {
- @location = get_location();
- if (!$location[0]){
- return @rows = ({
- main::key($num++,0,1,'Message') => main::message('weather-null','current location'),
+ my $weather = get_weather($location);
+ if ($weather->{'error'}){
+ @$rows = ({
+ main::key($num++,0,1,'Message') => main::message('weather-error',$weather->{'error'})
});
}
+ elsif (!$weather->{'weather'}){
+ @$rows = ({
+ main::key($num++,0,1,'Message') => main::message('weather-null','weather data')
+ });
+ }
+ else {
+ weather_output($rows,$location,$weather);
+ }
}
- %weather = get_weather(\@location);
- if ($weather{'error'}){
- return @rows = ({
- main::key($num++,0,1,'Message') => main::message('weather-error',$weather{'error'}),
- });
- }
- if (!$weather{'weather'}){
- return @rows = ({
- main::key($num++,0,1,'Message') => main::message('weather-null','weather data'),
+ if (!@$rows){
+ @$rows = ({
+ main::key($num++,0,1,'Message') => main::message('weather-null','weather data')
});
}
- $conditions = "$weather{'weather'}";
- my $temp = process_unit($weather{'temp'},$weather{'temp-c'},'C',$weather{'temp-f'},'F');
- $j = scalar @rows;
- push(@rows, {
+ eval $end if $b_log;
+ return $rows;
+}
+sub weather_output {
+ eval $start if $b_log;
+ my ($rows,$location,$weather) = @_;
+ my ($j,$num) = (0,0);
+ my ($value);
+ my ($conditions) = ('NA');
+ $conditions = "$weather->{'weather'}";
+ my $temp = process_unit(
+ $weather->{'temp'},
+ $weather->{'temp-c'},'C',
+ $weather->{'temp-f'},'F');
+ $j = scalar @$rows;
+ push(@$rows, {
main::key($num++,1,1,'Report') => '',
main::key($num++,0,2,'temperature') => $temp,
main::key($num++,0,2,'conditions') => $conditions,
},);
if ($extra > 0){
- my $pressure = process_unit($weather{'pressure'},$weather{'pressure-mb'},'mb',$weather{'pressure-in'},'in');
- my $wind = process_wind($weather{'wind'},$weather{'wind-direction'},$weather{'wind-mph'},$weather{'wind-ms'},
- $weather{'wind-gust-mph'},$weather{'wind-gust-ms'});
- $rows[$j]->{main::key($num++,0,2,'wind')} = $wind;
+ my $pressure = process_unit(
+ $weather->{'pressure'},
+ $weather->{'pressure-mb'},'mb',
+ $weather->{'pressure-in'},'in');
+ my $wind = process_wind(
+ $weather->{'wind'},
+ $weather->{'wind-direction'},
+ $weather->{'wind-mph'},
+ $weather->{'wind-ms'},
+ $weather->{'wind-gust-mph'},
+ $weather->{'wind-gust-ms'});
+ $rows->[$j]{main::key($num++,0,2,'wind')} = $wind;
if ($extra > 1){
- if (defined $weather{'cloud-cover'}){
- $rows[$j]->{main::key($num++,0,2,'cloud cover')} = $weather{'cloud-cover'} . '%';
+ if (defined $weather->{'cloud-cover'}){
+ $rows->[$j]{main::key($num++,0,2,'cloud cover')} = $weather->{'cloud-cover'} . '%';
}
- if ($weather{'precip-1h-mm'} && defined $weather{'precip-1h-in'}){
- $value = process_unit('',$weather{'precip-1h-mm'},'mm',$weather{'precip-1h-in'},'in');
- $rows[$j]->{main::key($num++,0,2,'precipitation')} = $value;
+ if ($weather->{'precip-1h-mm'} && defined $weather->{'precip-1h-in'}){
+ $value = process_unit('',$weather->{'precip-1h-mm'},'mm',
+ $weather->{'precip-1h-in'},'in');
+ $rows->[$j]{main::key($num++,0,2,'precipitation')} = $value;
}
- if ($weather{'rain-1h-mm'} && defined $weather{'rain-1h-in'}){
- $value = process_unit('',$weather{'rain-1h-mm'},'mm',$weather{'rain-1h-in'},'in');
- $rows[$j]->{main::key($num++,0,2,'rain')} = $value;
+ if ($weather->{'rain-1h-mm'} && defined $weather->{'rain-1h-in'}){
+ $value = process_unit('',$weather->{'rain-1h-mm'},'mm',
+ $weather->{'rain-1h-in'},'in');
+ $rows->[$j]{main::key($num++,0,2,'rain')} = $value;
}
- if ($weather{'snow-1h-mm'} && defined $weather{'snow-1h-in'}){
- $value = process_unit('',$weather{'snow-1h-mm'},'mm',$weather{'snow-1h-in'},'in');
- $rows[$j]->{main::key($num++,0,2,'snow')} = $value;
+ if ($weather->{'snow-1h-mm'} && defined $weather->{'snow-1h-in'}){
+ $value = process_unit('',$weather->{'snow-1h-mm'},'mm',
+ $weather->{'snow-1h-in'},'in');
+ $rows->[$j]{main::key($num++,0,2,'snow')} = $value;
}
}
- $rows[$j]->{main::key($num++,0,2,'humidity')} = $weather{'humidity'} . '%';
+ $rows->[$j]{main::key($num++,0,2,'humidity')} = $weather->{'humidity'} . '%';
if ($extra > 1){
- if ($weather{'dewpoint'} || (defined $weather{'dewpoint-c'} && defined $weather{'dewpoint-f'})){
- $value = process_unit($weather{'dewpoint'},$weather{'dewpoint-c'},'C',$weather{'dewpoint-f'},'F');
- $rows[$j]->{main::key($num++,0,2,'dew point')} = $value;
+ if ($weather->{'dewpoint'} || (defined $weather->{'dewpoint-c'} &&
+ defined $weather->{'dewpoint-f'})){
+ $value = process_unit(
+ $weather->{'dewpoint'},
+ $weather->{'dewpoint-c'},
+ 'C',
+ $weather->{'dewpoint-f'},
+ 'F');
+ $rows->[$j]{main::key($num++,0,2,'dew point')} = $value;
}
}
- $rows[$j]->{main::key($num++,0,2,'pressure')} = $pressure;
+ $rows->[$j]{main::key($num++,0,2,'pressure')} = $pressure;
}
if ($extra > 1){
- if ($weather{'heat-index'} || (defined $weather{'heat-index-c'} && defined $weather{'heat-index-f'})){
- $value = process_unit($weather{'heat-index'},$weather{'heat-index-c'},'C',$weather{'heat-index-f'},'F');
- $rows[$j]->{main::key($num++,0,2,'heat index')} = $value;
- }
- if ($weather{'windchill'} || (defined $weather{'windchill-c'} && defined $weather{'windchill-f'})){
- $value = process_unit($weather{'windchill'},$weather{'windchill-c'},'C',$weather{'windchill-f'},'F');
- $rows[$j]->{main::key($num++,0,2,'wind chill')} = $value;
+ if ($weather->{'heat-index'} || (defined $weather->{'heat-index-c'} &&
+ defined $weather->{'heat-index-f'})){
+ $value = process_unit(
+ $weather->{'heat-index'},
+ $weather->{'heat-index-c'},'C',
+ $weather->{'heat-index-f'},'F');
+ $rows->[$j]{main::key($num++,0,2,'heat index')} = $value;
+ }
+ if ($weather->{'windchill'} || (defined $weather->{'windchill-c'} &&
+ defined $weather->{'windchill-f'})){
+ $value = process_unit(
+ $weather->{'windchill'},
+ $weather->{'windchill-c'},'C',
+ $weather->{'windchill-f'},'F');
+ $rows->[$j]{main::key($num++,0,2,'wind chill')} = $value;
}
if ($extra > 2){
- if ($weather{'forecast'}){
- $j = scalar @rows;
- push(@rows, {
- main::key($num++,1,1,'Forecast') => $weather{'forecast'},
+ if ($weather->{'forecast'}){
+ $j = scalar @$rows;
+ push(@$rows, {
+ main::key($num++,1,1,'Forecast') => $weather->{'forecast'},
},);
}
}
}
- $j = scalar @rows;
- my $location = '';
+ $j = scalar @$rows;
if ($extra > 2 && !$use{'filter'}){
- $location = complete_location($location[1],$weather{'city'},$weather{'state'},$weather{'country'});
- }
- push(@rows, {
- main::key($num++,1,1,'Locale') => $location,
+ complete_location(
+ $location,
+ $weather->{'city'},
+ $weather->{'state'},
+ $weather->{'country'});
+ }
+ push(@$rows, {
+ main::key($num++,1,1,'Locale') => $location->[1],
},);
- if ($extra > 2 && !$use{'filter'} && ($weather{'elevation-m'} || $weather{'elevation-ft'})){
- $rows[$j]->{main::key($num++,0,2,'altitude')} = process_elevation($weather{'elevation-m'},$weather{'elevation-ft'});
+ if ($extra > 2 && !$use{'filter'} && ($weather->{'elevation-m'} ||
+ $weather->{'elevation-ft'})){
+ $rows->[$j]{main::key($num++,0,2,'altitude')} = process_elevation(
+ $weather->{'elevation-m'},
+ $weather->{'elevation-ft'});
}
- $rows[$j]->{main::key($num++,0,2,'current time')} = $weather{'date-time'},;
+ $rows->[$j]{main::key($num++,0,2,'current time')} = $weather->{'date-time'},;
if ($extra > 2){
- $weather{'observation-time-local'} = 'N/A' if !$weather{'observation-time-local'};
- $rows[$j]->{main::key($num++,0,2,'observation time')} = $weather{'observation-time-local'};
- if ($weather{'sunrise'}){
- $rows[$j]->{main::key($num++,0,2,'sunrise')} = $weather{'sunrise'};
+ $weather->{'observation-time-local'} = 'N/A' if !$weather->{'observation-time-local'};
+ $rows->[$j]{main::key($num++,0,2,'observation time')} = $weather->{'observation-time-local'};
+ if ($weather->{'sunrise'}){
+ $rows->[$j]{main::key($num++,0,2,'sunrise')} = $weather->{'sunrise'};
}
- if ($weather{'sunset'}){
- $rows[$j]->{main::key($num++,0,2,'sunset')} = $weather{'sunset'};
+ if ($weather->{'sunset'}){
+ $rows->[$j]{main::key($num++,0,2,'sunset')} = $weather->{'sunset'};
}
- if ($weather{'moonphase'}){
- $value = $weather{'moonphase'} . '%';
- $value .= ($weather{'moonphase-graphic'}) ? ' ' . $weather{'moonphase-graphic'} :'';
- $rows[$j]->{main::key($num++,0,2,'moonphase')} = $value;
+ if ($weather->{'moonphase'}){
+ $value = $weather->{'moonphase'} . '%';
+ $value .= ($weather->{'moonphase-graphic'}) ? ' ' . $weather->{'moonphase-graphic'} :'';
+ $rows->[$j]{main::key($num++,0,2,'moonphase')} = $value;
}
}
- if ($weather{'api-source'}){
- $rows[$j]->{main::key($num++,0,1,'Source')} = $weather{'api-source'};
+ if ($weather->{'api-source'}){
+ $rows->[$j]{main::key($num++,0,1,'Source')} = $weather->{'api-source'};
}
eval $end if $b_log;
- return @rows;
}
sub process_elevation {
eval $start if $b_log;
@@ -24330,272 +25106,276 @@ sub get_weather {
eval $start if $b_log;
my ($location) = @_;
my $now = POSIX::strftime "%Y%m%d%H%M", localtime;
- my ($date_time,$freshness,$tz,@weather_data,%weather);
+ my ($date_time,$freshness,$tz,$weather_data);
+ my $weather = {};
my $loc_name = lc($location->[0]);
$loc_name =~ s/-\/|\s|,/-/g;
$loc_name =~ s/--/-/g;
my $file_cached = "$user_data_dir/weather-$loc_name-$weather_source.txt";
if (-r $file_cached){
- @weather_data = main::reader($file_cached);
- $freshness = (split(/\^\^/, $weather_data[0]))[1];
+ @$weather_data = main::reader($file_cached);
+ $freshness = (split(/\^\^/, $weather_data->[0]))[1];
# print "$now:$freshness\n";
}
if (!$freshness || $freshness < ($now - 60)){
- @weather_data = download_weather($now,$file_cached,$location);
+ $weather_data = download_weather($now,$file_cached,$location);
}
# print join("\n", @weather_data), "\n";
# NOTE: because temps can be 0, we can't do if value tests
- foreach (@weather_data){
+ foreach (@$weather_data){
my @working = split(/\s*\^\^\s*/, $_);
next if ! defined $working[1] || $working[1] eq '';
if ($working[0] eq 'api_source'){
- $weather{'api-source'} = $working[1];
+ $weather->{'api-source'} = $working[1];
}
elsif ($working[0] eq 'city'){
- $weather{'city'} = $working[1];
+ $weather->{'city'} = $working[1];
}
elsif ($working[0] eq 'cloud_cover'){
- $weather{'cloud-cover'} = $working[1];
+ $weather->{'cloud-cover'} = $working[1];
}
elsif ($working[0] eq 'country'){
- $weather{'country'} = $working[1];
+ $weather->{'country'} = $working[1];
}
elsif ($working[0] eq 'dewpoint_string'){
- $weather{'dewpoint'} = $working[1];
+ $weather->{'dewpoint'} = $working[1];
$working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/;
- $weather{'dewpoint-c'} = $2;;
- $weather{'dewpoint-f'} = $1;;
+ $weather->{'dewpoint-c'} = $2;;
+ $weather->{'dewpoint-f'} = $1;;
}
elsif ($working[0] eq 'dewpoint_c'){
- $weather{'dewpoint-c'} = $working[1];
+ $weather->{'dewpoint-c'} = $working[1];
}
elsif ($working[0] eq 'dewpoint_f'){
- $weather{'dewpoint-f'} = $working[1];
+ $weather->{'dewpoint-f'} = $working[1];
}
# WU: there are two elevations, we want the first one
- elsif (!$weather{'elevation-m'} && $working[0] eq 'elevation'){
+ elsif (!$weather->{'elevation-m'} && $working[0] eq 'elevation'){
# note: bug in source data uses ft for meters, not 100% of time, but usually
- $weather{'elevation-m'} = $working[1];
- $weather{'elevation-m'} =~ s/\s*(ft|m).*$//;
+ $weather->{'elevation-m'} = $working[1];
+ $weather->{'elevation-m'} =~ s/\s*(ft|m).*$//;
}
elsif ($working[0] eq 'error'){
- $weather{'error'} = $working[1];
+ $weather->{'error'} = $working[1];
}
elsif ($working[0] eq 'forecast'){
- $weather{'forecast'} = $working[1];
+ $weather->{'forecast'} = $working[1];
}
elsif ($working[0] eq 'heat_index_string'){
- $weather{'heat-index'} = $working[1];
+ $weather->{'heat-index'} = $working[1];
$working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/;
- $weather{'heat-index-c'} = $2;;
- $weather{'heat-index-f'} = $1;
+ $weather->{'heat-index-c'} = $2;;
+ $weather->{'heat-index-f'} = $1;
}
elsif ($working[0] eq 'heat_index_c'){
- $weather{'heat-index-c'} = $working[1];
+ $weather->{'heat-index-c'} = $working[1];
}
elsif ($working[0] eq 'heat_index_f'){
- $weather{'heat-index-f'} = $working[1];
+ $weather->{'heat-index-f'} = $working[1];
}
elsif ($working[0] eq 'relative_humidity'){
$working[1] =~ s/%$//;
- $weather{'humidity'} = $working[1];
+ $weather->{'humidity'} = $working[1];
}
elsif ($working[0] eq 'local_time'){
- $weather{'local-time'} = $working[1];
+ $weather->{'local-time'} = $working[1];
}
elsif ($working[0] eq 'local_epoch'){
- $weather{'local-epoch'} = $working[1];
+ $weather->{'local-epoch'} = $working[1];
}
elsif ($working[0] eq 'moonphase'){
- $weather{'moonphase'} = $working[1];
+ $weather->{'moonphase'} = $working[1];
}
elsif ($working[0] eq 'moonphase_graphic'){
- $weather{'moonphase-graphic'} = $working[1];
+ $weather->{'moonphase-graphic'} = $working[1];
}
elsif ($working[0] eq 'observation_time_rfc822'){
- $weather{'observation-time-rfc822'} = $working[1];
+ $weather->{'observation-time-rfc822'} = $working[1];
}
elsif ($working[0] eq 'observation_epoch'){
- $weather{'observation-epoch'} = $working[1];
+ $weather->{'observation-epoch'} = $working[1];
}
elsif ($working[0] eq 'observation_time'){
- $weather{'observation-time-local'} = $working[1];
- $weather{'observation-time-local'} =~ s/Last Updated on //;
+ $weather->{'observation-time-local'} = $working[1];
+ $weather->{'observation-time-local'} =~ s/Last Updated on //;
}
elsif ($working[0] eq 'precip_mm'){
- $weather{'precip-1h-mm'} = $working[1];
+ $weather->{'precip-1h-mm'} = $working[1];
}
elsif ($working[0] eq 'precip_in'){
- $weather{'precip-1h-in'} = $working[1];
+ $weather->{'precip-1h-in'} = $working[1];
}
elsif ($working[0] eq 'pressure_string'){
- $weather{'pressure'} = $working[1];
+ $weather->{'pressure'} = $working[1];
}
elsif ($working[0] eq 'pressure_mb'){
- $weather{'pressure-mb'} = $working[1];
+ $weather->{'pressure-mb'} = $working[1];
}
elsif ($working[0] eq 'pressure_in'){
- $weather{'pressure-in'} = $working[1];
+ $weather->{'pressure-in'} = $working[1];
}
elsif ($working[0] eq 'rain_1h_mm'){
- $weather{'rain-1h-mm'} = $working[1];
+ $weather->{'rain-1h-mm'} = $working[1];
}
elsif ($working[0] eq 'rain_1h_in'){
- $weather{'rain-1h-in'} = $working[1];
+ $weather->{'rain-1h-in'} = $working[1];
}
elsif ($working[0] eq 'snow_1h_mm'){
- $weather{'snow-1h-mm'} = $working[1];
+ $weather->{'snow-1h-mm'} = $working[1];
}
elsif ($working[0] eq 'snow_1h_in'){
- $weather{'snow-1h-in'} = $working[1];
+ $weather->{'snow-1h-in'} = $working[1];
}
elsif ($working[0] eq 'state_name'){
- $weather{'state'} = $working[1];
+ $weather->{'state'} = $working[1];
}
elsif ($working[0] eq 'sunrise'){
if ($working[1]){
if ($working[1] !~ /^[0-9]+$/){
- $weather{'sunrise'} = $working[1];
+ $weather->{'sunrise'} = $working[1];
}
# trying to figure out remote time from UTC is too hard
elsif (!$show{'weather-location'}){
- $weather{'sunrise'} = POSIX::strftime "%T", localtime($working[1]);
+ $weather->{'sunrise'} = POSIX::strftime "%T", localtime($working[1]);
}
}
}
elsif ($working[0] eq 'sunset'){
if ($working[1]){
if ($working[1] !~ /^[0-9]+$/){
- $weather{'sunset'} = $working[1];
+ $weather->{'sunset'} = $working[1];
}
# trying to figure out remote time from UTC is too hard
elsif (!$show{'weather-location'}){
- $weather{'sunset'} = POSIX::strftime "%T", localtime($working[1]);
+ $weather->{'sunset'} = POSIX::strftime "%T", localtime($working[1]);
}
}
}
elsif ($working[0] eq 'temperature_string'){
- $weather{'temp'} = $working[1];
+ $weather->{'temp'} = $working[1];
$working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/;
- $weather{'temp-c'} = $2;;
- $weather{'temp-f'} = $1;
-# $weather{'temp'} =~ s/\sF/\xB0 F/; # B0
-# $weather{'temp'} =~ s/\sF/\x{2109}/;
-# $weather{'temp'} =~ s/\sC/\x{2103}/;
+ $weather->{'temp-c'} = $2;;
+ $weather->{'temp-f'} = $1;
+# $weather->{'temp'} =~ s/\sF/\xB0 F/; # B0
+# $weather->{'temp'} =~ s/\sF/\x{2109}/;
+# $weather->{'temp'} =~ s/\sC/\x{2103}/;
}
elsif ($working[0] eq 'temp_f'){
- $weather{'temp-f'} = $working[1];
+ $weather->{'temp-f'} = $working[1];
}
elsif ($working[0] eq 'temp_c'){
- $weather{'temp-c'} = $working[1];
+ $weather->{'temp-c'} = $working[1];
}
elsif ($working[0] eq 'timezone'){
- $weather{'timezone'} = $working[1];
+ $weather->{'timezone'} = $working[1];
}
elsif ($working[0] eq 'visibility'){
- $weather{'visibility'} = $working[1];
+ $weather->{'visibility'} = $working[1];
}
elsif ($working[0] eq 'visibility_km'){
- $weather{'visibility-km'} = $working[1];
+ $weather->{'visibility-km'} = $working[1];
}
elsif ($working[0] eq 'visibility_mi'){
- $weather{'visibility-mi'} = $working[1];
+ $weather->{'visibility-mi'} = $working[1];
}
elsif ($working[0] eq 'weather'){
- $weather{'weather'} = $working[1];
+ $weather->{'weather'} = $working[1];
}
elsif ($working[0] eq 'wind_degrees'){
- $weather{'wind-degrees'} = $working[1];
+ $weather->{'wind-degrees'} = $working[1];
}
elsif ($working[0] eq 'wind_dir'){
- $weather{'wind-direction'} = $working[1];
+ $weather->{'wind-direction'} = $working[1];
}
elsif ($working[0] eq 'wind_mph'){
- $weather{'wind-mph'} = $working[1];
+ $weather->{'wind-mph'} = $working[1];
}
elsif ($working[0] eq 'wind_gust_mph'){
- $weather{'wind-gust-mph'} = $working[1];
+ $weather->{'wind-gust-mph'} = $working[1];
}
elsif ($working[0] eq 'wind_gust_ms'){
- $weather{'wind-gust-ms'} = $working[1];
+ $weather->{'wind-gust-ms'} = $working[1];
}
elsif ($working[0] eq 'wind_ms'){
- $weather{'wind-ms'} = $working[1];
+ $weather->{'wind-ms'} = $working[1];
}
elsif ($working[0] eq 'wind_string'){
- $weather{'wind'} = $working[1];
+ $weather->{'wind'} = $working[1];
}
elsif ($working[0] eq 'windchill_string'){
- $weather{'windchill'} = $working[1];
+ $weather->{'windchill'} = $working[1];
$working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/;
- $weather{'windchill-c'} = $2;
- $weather{'windchill-f'} = $1;
+ $weather->{'windchill-c'} = $2;
+ $weather->{'windchill-f'} = $1;
}
elsif ($working[0] eq 'windchill_c'){
- $weather{'windchill-c'} = $working[1];
+ $weather->{'windchill-c'} = $working[1];
}
elsif ($working[0] eq 'windchill_f'){
- $weather{'windchill_f'} = $working[1];
+ $weather->{'windchill_f'} = $working[1];
}
}
if ($show{'weather-location'}){
- if ($weather{'observation-time-local'} &&
- $weather{'observation-time-local'} =~ /^(.*)\s([a-z_]+\/[a-z_]+)$/i){
+ if ($weather->{'observation-time-local'} &&
+ $weather->{'observation-time-local'} =~ /^(.*)\s([a-z_]+\/[a-z_]+)$/i){
$tz = $2;
}
- if (!$tz && $weather{'timezone'}){
- $tz = $weather{'timezone'};
- $weather{'observation-time-local'} .= ' (' . $weather{'timezone'} . ')' if $weather{'observation-time-local'};
+ if (!$tz && $weather->{'timezone'}){
+ $tz = $weather->{'timezone'};
+ $weather->{'observation-time-local'} .= ' (' . $weather->{'timezone'} . ')' if $weather->{'observation-time-local'};
}
# very clever trick, just make the system think it's in the
# remote timezone for this local block only
local $ENV{'TZ'} = $tz if $tz;
$date_time = POSIX::strftime "%c", localtime();
$date_time = test_locale_date($date_time,'','');
- $weather{'date-time'} = $date_time;
+ $weather->{'date-time'} = $date_time;
# only wu has rfc822 value, and we want the original observation time then
- if ($weather{'observation-epoch'} && $tz){
- $date_time = POSIX::strftime "%Y-%m-%d %T ($tz %z)", localtime($weather{'observation-epoch'});
- $date_time = test_locale_date($date_time,$show{'weather-location'},$weather{'observation-epoch'});
- $weather{'observation-time-local'} = $date_time;
+ if ($weather->{'observation-epoch'} && $tz){
+ $date_time = POSIX::strftime "%Y-%m-%d %T ($tz %z)", localtime($weather->{'observation-epoch'});
+ $date_time = test_locale_date($date_time,$show{'weather-location'},$weather->{'observation-epoch'});
+ $weather->{'observation-time-local'} = $date_time;
}
}
else {
$date_time = POSIX::strftime "%c", localtime();
$date_time = test_locale_date($date_time,'','');
$tz = ($location->[2]) ? " ($location->[2])" : '';
- $weather{'date-time'} = $date_time . $tz;
+ $weather->{'date-time'} = $date_time . $tz;
}
# we get the wrong time using epoch for remote -W location
- if (!$show{'weather-location'} && $weather{'observation-epoch'}){
- $date_time = POSIX::strftime "%c", localtime($weather{'observation-epoch'});
- $date_time = test_locale_date($date_time,$show{'weather-location'},$weather{'observation-epoch'});
- $weather{'observation-time-local'} = $date_time;
+ if (!$show{'weather-location'} && $weather->{'observation-epoch'}){
+ $date_time = POSIX::strftime "%c", localtime($weather->{'observation-epoch'});
+ $date_time = test_locale_date($date_time,$show{'weather-location'},$weather->{'observation-epoch'});
+ $weather->{'observation-time-local'} = $date_time;
}
eval $end if $b_log;
- return %weather;
+ return $weather;
}
sub download_weather {
eval $start if $b_log;
my ($now,$file_cached,$location) = @_;
- my (@weather,$temp,$ua,$url);
+ my ($temp,$ua,$url);
+ my $weather = [];
$url = "https://smxi.org/opt/xr2.php?loc=$location->[0]&src=$weather_source";
$ua = 'weather';
-# {
-# # my $file2 = "$ENV{'HOME'}/bin/scripts/inxi/data/weather/weather-1.xml";
-# # my $file2 = "$ENV{'HOME'}/bin/scripts/inxi/data/weather/feed-oslo-1.xml";
-# local $/;
-# my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/weather/weather-1.xml";
-# open(my $fh, '<', $file) or die "can't open $file: $!";
-# $temp = <$fh>;
-# }
- $temp = main::download_file('stdout',$url,'',$ua);
- @weather = split('\n', $temp) if $temp;
- unshift(@weather, "timestamp^^$now");
- main::writer($file_cached,\@weather);
+ if ($fake{'weather'}){
+ # my $file2 = "$fake_data_dir/weather/weather-1.xml";
+ # my $file2 = "$fake_data_dir/weather/feed-oslo-1.xml";
+ # local $/;
+ # my $file = "$fake_data_dir/weather/weather-1.xml";
+ # open(my $fh, '<', $file) or die "can't open $file: $!";
+ # $temp = <$fh>;
+ }
+ else {
+ $temp = main::download_file('stdout',$url,'',$ua);
+ }
+ @$weather = split('\n', $temp) if $temp;
+ unshift(@$weather, "timestamp^^$now");
+ main::writer($file_cached,$weather);
# print "$file_cached: download/cleaned\n";
eval $end if $b_log;
- return @weather;
+ return $weather;
}
# resolve wide character issue, if detected, switch to iso
# date format, we won't try to be too clever here.
@@ -24615,8 +25395,37 @@ sub test_locale_date {
# print "2: $date_time\n";
return $date_time;
}
+
+## Location Data ##
+sub location_data {
+ eval $start if $b_log;
+ my $location = $_[0];
+ if ($show{'weather-location'}){
+ my $location_string;
+ $location_string = $show{'weather-location'};
+ $location_string =~ s/\+/ /g;
+ if ($location_string =~ /,/){
+ my @temp = split(',', $location_string);
+ my $sep = '';
+ my $string = '';
+ foreach (@temp){
+ $_ = ucfirst($_);
+ $string .= $sep . $_;
+ $sep = ', ';
+ }
+ $location_string = $string;
+ }
+ $location_string = main::filter($location_string);
+ @$location = ($show{'weather-location'},$location_string,'');
+ }
+ else {
+ get_location($location);
+ }
+ eval $end if $b_log;
+}
sub get_location {
eval $start if $b_log;
+ my $location = $_[0];
my ($city,$country,$freshness,%loc,$loc_arg,$loc_string,@loc_data,$state);
my $now = POSIX::strftime "%Y%m%d%H%M", localtime;
my $file_cached = "$user_data_dir/location-main.txt";
@@ -24627,12 +25436,12 @@ sub get_location {
if (!$freshness || $freshness < $now - 90){
my $temp;
my $url = "http://geoip.ubuntu.com/lookup";
-# {
-# local $/;
-# my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/weather/location-1.xml";
-# open(my $fh, '<', $file) or die "can't open $file: $!";
-# $temp = <$fh>;
-# }
+ # {
+ # local $/;
+ # my $file = "$fake_data_dir/weather/location-1.xml";
+ # open(my $fh, '<', $file) or die "can't open $file: $!";
+ # $temp = <$fh>;
+ # }
$temp = main::download_file('stdout',$url);
@loc_data = split('\n', $temp);
@loc_data = map {
@@ -24699,21 +25508,19 @@ sub get_location {
$city = ($loc{'city'}) ? $loc{'city'} : 'City N/A';
$state = ($loc{'region-id'}) ? $loc{'region-id'} : 'Region N/A';
$loc_string = main::filter("$city, $state, $country");
- my @location = ($loc_arg,$loc_string,$loc{'tz'});
+ @$location = ($loc_arg,$loc_string,$loc{'tz'});
# print ($loc_arg,"\n", join("\n", @loc_data), "\n",scalar @loc_data, "\n");
eval $end if $b_log;
- return @location;
}
sub complete_location {
eval $start if $b_log;
my ($location,$city,$state,$country) = @_;
- if ($location && $location =~ /[0-9+-]/ && $city){
- $location = $country . ', ' . $location if $country && $location !~ m|$country|i;
- $location = $state . ', ' . $location if $state && $location !~ m|$state|i;
- $location = $city . ', ' . $location if $city && $location !~ m|$city|i;
+ if ($location->[1] && $location->[1] =~ /[0-9+-]/ && $city){
+ $location->[1] = $country . ', ' . $location->[1] if $country && $location->[1] !~ m|$country|i;
+ $location->[1] = $state . ', ' . $location->[1] if $state && $location->[1] !~ m|$state|i;
+ $location->[1] = $city . ', ' . $location->[1] if $city && $location->[1] !~ m|$city|i;
}
eval $end if $b_log;
- return $location;
}
}
@@ -24777,20 +25584,21 @@ sub set_build_prop {
package CompilerVersion;
sub get {
eval $start if $b_log;
- my (@compiler);
+ my $compiler = [];
if (my $file = $system_files{'proc-version'}){
- @compiler = version_proc($file);
+ version_proc($compiler,$file);
}
elsif ($bsd_type){
- @compiler = version_bsd();
+ version_bsd($compiler);
}
eval $end if $b_log;
- return @compiler;
+ return $compiler;
}
sub version_bsd {
eval $start if $b_log;
- my (@compiler,@working);
+ my $compiler = $_[0];
+ my (@working);
if ($alerts{'sysctl'}->{'action'} && $alerts{'sysctl'}->{'action'} eq 'use'){
if ($sysctl{'kernel'}){
my @working;
@@ -24801,28 +25609,27 @@ sub version_bsd {
if (/^kern.compiler_version/){
@working = split(/:\s*/, $_);
$working[1] =~ /.*(gcc|clang)\sversion\s([\S]+)\s.*/;
- @compiler = ($1,$2);
+ @$compiler = ($1,$2);
last;
}
}
}
# OpenBSD doesn't show compiler data in sysctl or dboot but it's going to
# be Clang until way into the future, and it will be the installed version.
- if (!@compiler){
+ if (!@$compiler){
if (my $path = main::check_program('clang')){
- $compiler[0] = 'clang';
- $compiler[1] = main::program_version($path,'clang',3,'--version');
+ $compiler->[0] = 'clang';
+ $compiler->[1] = main::program_version($path,'clang',3,'--version');
}
}
}
- main::log_data('dump','@compiler',\@compiler) if $b_log;
+ main::log_data('dump','@$compiler',$compiler) if $b_log;
eval $end if $b_log;
- return @compiler;
}
sub version_proc {
eval $start if $b_log;
- my ($file) = @_;
- my (@compiler,$version);
+ my ($compiler,$file) = @_;
+ my ($version);
my @data = main::reader($file);
my $result = $data[0] if @data;
if ($result){
@@ -24840,17 +25647,16 @@ sub version_proc {
if ($result =~ /(gcc|clang).*version\s([^\s\)]+)/){
$version = $2;
$version ||= 'N/A';
- @compiler = ($1,$version);
+ @$compiler = ($1,$version);
}
elsif ($result =~ /\((gcc|clang)[^\(]*\([^\)]+\)\s+([0-9\.]+)(\s[^.]*)?,\s*/){
$version = $2;
$version ||= 'N/A';
- @compiler = ($1,$version);
+ @$compiler = ($1,$version);
}
}
- main::log_data('dump','@compiler',\@compiler) if $b_log;
+ main::log_data('dump','@$compiler',$compiler) if $b_log;
eval $end if $b_log;
- return @compiler;
}
}
@@ -24863,14 +25669,14 @@ sub set_dboot_data {
$file = $system_files{'dmesg-boot'};
}
else {
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/bsd-disks-diabolus.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/freebsd-disks-solestar.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/freebsd-enceladus-1.txt";
+ # $file = "$fake_data_dir/dmesg-boot/bsd-disks-diabolus.txt";
+ # $file = "$fake_data_dir/dmesg-boot/freebsd-disks-solestar.txt";
+ # $file = "$fake_data_dir/dmesg-boot/freebsd-enceladus-1.txt";
## matches: toshiba: openbsd-5.6-sysctl-2.txt
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/openbsd-5.6-dmesg.boot-1.txt";
+ # $file = "$fake_data_dir/dmesg-boot/openbsd-5.6-dmesg.boot-1.txt";
## matches: compaq: openbsd-5.6-sysctl-1.txt"
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/openbsd-dmesg.boot-1.txt";
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmesg-boot/openbsd-6.8-battery-sensors-1.txt";
+ # $file = "$fake_data_dir/dmesg-boot/openbsd-dmesg.boot-1.txt";
+ $file = "$fake_data_dir/dmesg-boot/openbsd-6.8-battery-sensors-1.txt";
}
if ($file){
return if ! -r $file;
@@ -25045,25 +25851,26 @@ sub set_dboot_data {
{
package DesktopEnvironment;
my ($b_gtk,$b_qt,$b_xprop,$desktop_session,$gdmsession,$kde_session_version,
-$xdg_desktop,@desktop,@data,@xprop);
+$xdg_desktop,@data,@xprop);
+my $desktop = [];
sub get {
eval $start if $b_log;
set_desktop_values();
main::set_ps_gui() if !$loaded{'ps-gui'};
get_kde_trinity_data();
- if (!@desktop){
+ if (!@$desktop){
get_env_de_data();
}
- if (!@desktop){
+ if (!@$desktop){
get_env_xprop_gnome_based_data();
}
- if (!@desktop && $b_xprop){
+ if (!@$desktop && $b_xprop){
get_env_xprop_non_gnome_based_data();
}
- if (!@desktop){
+ if (!@$desktop){
get_ps_de_data();
}
- if ($extra > 2 && @desktop){
+ if ($extra > 2 && @$desktop){
set_info_data();
}
if ($b_display && !$force{'display'} && $extra > 1){
@@ -25071,10 +25878,10 @@ sub get {
}
set_gtk_data() if $b_gtk && $extra > 1;
set_qt_data() if $b_qt && $extra > 1;
- main::log_data('dump','@desktop', \@desktop) if $b_log;
+ main::log_data('dump','@$desktop', $desktop) if $b_log;
# ($b_xprop,$kde_session_version,$xdg_desktop,@data,@xprop) = ();
eval $end if $b_log;
- return @desktop;
+ return $desktop;
}
sub set_desktop_values {
# NOTE $XDG_CURRENT_DESKTOP envvar is not reliable, but it shows certain desktops better.
@@ -25107,14 +25914,14 @@ sub get_kde_trinity_data {
$kded_name = 'kded';
}
if ($desktop_session eq 'trinity' || $xdg_desktop eq 'trinity' || (grep {/^tde/} @ps_gui)){
- $desktop[0] = 'Trinity';
+ $desktop->[0] = 'Trinity';
if ($program = main::check_program('kdesktop')){
@version_data = main::grabber("$program --version 2>/dev/null");
- $desktop[1] = main::awk(\@version_data,'^TDE:',2,'\s+') if @version_data;
+ $desktop->[1] = main::awk(\@version_data,'^TDE:',2,'\s+') if @version_data;
}
if ($extra > 1 && @version_data){
- $desktop[2] = 'Qt';
- $desktop[3] = main::awk(\@version_data,'^Qt:',2,'\s+') if @version_data;
+ $desktop->[2] = 'Qt';
+ $desktop->[3] = main::awk(\@version_data,'^Qt:',2,'\s+') if @version_data;
}
}
# works on 4, assume 5 will id the same, why not, no need to update in future
@@ -25125,14 +25932,14 @@ sub get_kde_trinity_data {
if ($kde_session_version && $kde_session_version <= 4){
@data = ($kded_name) ? main::program_values($kded_name) : ();
if (@data){
- $desktop[0] = $data[3];
- $desktop[1] = main::program_version($kded,$data[0],$data[1],$data[2],$data[5],$data[6]);
+ $desktop->[0] = $data[3];
+ $desktop->[1] = main::program_version($kded,$data[0],$data[1],$data[2],$data[5],$data[6]);
# kded exists, so we can now get the qt data string as well
- if ($desktop[1] && $kded){
+ if ($desktop->[1] && $kded){
@version_data = main::grabber("$kded --version 2>/dev/null");
}
}
- $desktop[0] = 'KDE' if !$desktop[0];
+ $desktop->[0] = 'KDE' if !$desktop->[0];
}
else {
# NOTE: this command string is almost certain to change, and break, with next
@@ -25154,39 +25961,39 @@ sub get_kde_trinity_data {
}
if ($program = main::check_program("plasmashell")){
@version_data2 = main::grabber("$program --version 2>/dev/null");
- $desktop[1] = main::awk(\@version_data2,'^plasmashell',-1,'\s+');
+ $desktop->[1] = main::awk(\@version_data2,'^plasmashell',-1,'\s+');
}
- $desktop[0] = 'KDE Plasma';
+ $desktop->[0] = 'KDE Plasma';
}
- if (!$desktop[1]){
- $desktop[1] = ($kde_session_version) ? $kde_session_version: main::message('unknown-desktop-version');
+ if (!$desktop->[1]){
+ $desktop->[1] = ($kde_session_version) ? $kde_session_version: main::message('unknown-desktop-version');
}
# print Data::Dumper::Dumper \@version_data;
if ($extra > 1){
if (@version_data){
- $desktop[3] = main::awk(\@version_data,'^Qt:', 2,'\s+');
+ $desktop->[3] = main::awk(\@version_data,'^Qt:', 2,'\s+');
}
# qmake can have variants, qt4-qmake, qt5-qmake, also qt5-default but not tested
- if (!$desktop[3] && main::check_program("qmake")){
+ if (!$desktop->[3] && main::check_program("qmake")){
# note: this program has issues, it may appear to be in /usr/bin, but it
# often fails to execute, so the below will have null output, but use as a
# fall back test anyway.
- ($desktop[2],$desktop[3]) = main::program_data('qmake');
+ ($desktop->[2],$desktop->[3]) = main::program_data('qmake');
}
- $desktop[2] ||= 'Qt';
+ $desktop->[2] ||= 'Qt';
}
}
# KDE_FULL_SESSION property is only available since KDE 3.5.5.
elsif ($kde_full_session eq 'true'){
@version_data = ($kded) ? main::grabber("$kded --version 2>/dev/null") : ();
- $desktop[0] = 'KDE';
- $desktop[1] = main::awk(\@version_data,'^KDE:',2,'\s+') if @version_data;
- if (!$desktop[1]){
- $desktop[1] = '3.5';
+ $desktop->[0] = 'KDE';
+ $desktop->[1] = main::awk(\@version_data,'^KDE:',2,'\s+') if @version_data;
+ if (!$desktop->[1]){
+ $desktop->[1] = '3.5';
}
if ($extra > 1 && @version_data){
- $desktop[2] = 'Qt';
- $desktop[3] = main::awk(\@version_data,'^Qt:',2,'\s+') if @version_data;
+ $desktop->[2] = 'Qt';
+ $desktop->[3] = main::awk(\@version_data,'^Qt:',2,'\s+') if @version_data;
}
}
eval $end if $b_log;
@@ -25194,7 +26001,7 @@ sub get_kde_trinity_data {
sub get_env_de_data {
eval $start if $b_log;
my ($program,@version_data);
- if (!$desktop[0]){
+ if (!$desktop->[0]){
# 0: 1/0; 1: env var search; 2: data; 3: gtk tk; 4: qt tk; 5: ps_gui search
my @desktops =(
[1,'unity','unity',0,0],
@@ -25224,7 +26031,7 @@ sub get_env_de_data {
if ((($item->[0] && ($xdg_desktop eq $item->[1] || $desktop_session eq $item->[1])) ||
(!$item->[0] && ($xdg_desktop =~ /$item->[1]/ || $desktop_session =~ /$item->[1]/))) ||
($item->[5] && @ps_gui && (grep {/$item->[5]/} @ps_gui))){
- ($desktop[0],$desktop[1]) = main::program_data($item->[2]);
+ ($desktop->[0],$desktop->[1]) = main::program_data($item->[2]);
$b_gtk = $item->[3];
$b_qt = $item->[4];
last;
@@ -25248,9 +26055,9 @@ sub get_env_xprop_gnome_based_data {
if ($xdg_desktop eq 'cinnamon' || $gdmsession eq 'cinnamon' ||
(main::check_program('muffin') || main::check_program('cinnamon-session')) &&
($b_xprop && main::awk(\@xprop,'_muffin'))){
- ($desktop[0],$desktop[1]) = main::program_data('cinnamon','cinnamon',0);
+ ($desktop->[0],$desktop->[1]) = main::program_data('cinnamon','cinnamon',0);
$b_gtk = 1;
- $desktop[0] ||= 'Cinnamon';
+ $desktop->[0] ||= 'Cinnamon';
}
elsif ($xdg_desktop eq 'mate' || $gdmsession eq 'mate' ||
($b_xprop && main::awk(\@xprop,'_marco'))){
@@ -25260,25 +26067,25 @@ sub get_env_xprop_gnome_based_data {
foreach my $key (keys %versions){
if ($program = main::check_program($key)){
@data = main::program_data($key,$program,0);
- $desktop[0] = $data[0];
+ $desktop->[0] = $data[0];
$versions{$key} = $data[1];
}
}
# no consistent rule about which version is higher, so just compare them and take highest
- $desktop[1] = main::compare_versions($versions{'mate-about'},$versions{'mate-session'});
+ $desktop->[1] = main::compare_versions($versions{'mate-about'},$versions{'mate-session'});
# $b_gtk = 1;
- $desktop[0] ||= 'MATE';
+ $desktop->[0] ||= 'MATE';
}
# See sub for logic and comments
elsif (check_gnome()){
if (main::check_program('gnome-about')){
- ($desktop[0],$desktop[1]) = main::program_data('gnome-about');
+ ($desktop->[0],$desktop->[1]) = main::program_data('gnome-about');
}
elsif (main::check_program('gnome-shell')){
- ($desktop[0],$desktop[1]) = main::program_data('gnome','gnome-shell');
+ ($desktop->[0],$desktop->[1]) = main::program_data('gnome','gnome-shell');
}
$b_gtk = 1;
- $desktop[0] ||= 'GNOME';
+ $desktop->[0] ||= 'GNOME';
}
eval $end if $b_log;
}
@@ -25348,50 +26155,50 @@ sub get_env_xprop_non_gnome_based_data {
$version = '4';
}
@data = main::program_values('xfdesktop');
- $desktop[0] = $data[3];
+ $desktop->[0] = $data[3];
# xfdesktop --version out of x fails to get display, so no data
@version_data = main::grabber('xfdesktop --version 2>/dev/null');
# out of x, this error goes to stderr, so it's an empty result
- $desktop[1] = main::awk(\@version_data,$data[0],$data[1],'\s+');
- #$desktop[1] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]);
- if (!$desktop[1]){
+ $desktop->[1] = main::awk(\@version_data,$data[0],$data[1],'\s+');
+ #$desktop->[1] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]);
+ if (!$desktop->[1]){
@data = main::program_values("xfce${version}-panel");
# print Data::Dumper::Dumper \@data;
# this returns an error message to stdout in x, which breaks the version
# xfce4-panel --version out of x fails to get display, so no data
- $desktop[1] = main::program_version("xfce${version}-panel",$data[0],$data[1],$data[2],$data[5],$data[6]);
+ $desktop->[1] = main::program_version("xfce${version}-panel",$data[0],$data[1],$data[2],$data[5],$data[6]);
# out of x this kicks out an error: xfce4-panel: Cannot open display
- $desktop[1] = '' if $desktop[1] !~ /[0-9]\./;
+ $desktop->[1] = '' if $desktop->[1] !~ /[0-9]\./;
}
- $desktop[0] ||= 'Xfce';
- $desktop[1] ||= ''; # xfce isn't going to be 4 forever
+ $desktop->[0] ||= 'Xfce';
+ $desktop->[1] ||= ''; # xfce isn't going to be 4 forever
if ($extra > 1){
@data = main::program_values('xfdesktop-toolkit');
- #$desktop[3] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]);
- $desktop[3] = main::awk(\@version_data,$data[0],$data[1],'\s+');
- $desktop[2] = $data[3];
+ #$desktop->[3] = main::program_version('xfdesktop',$data[0],$data[1],$data[2],$data[5],$data[6]);
+ $desktop->[3] = main::awk(\@version_data,$data[0],$data[1],'\s+');
+ $desktop->[2] = $data[3];
}
}
elsif ($xdg_desktop eq 'moksha' || $gdmsession eq 'moksha' ||
(main::check_program('enlightenment') || main::check_program('moksha')) && main::awk(\@xprop,'moksha')){
# no -v or --version but version is in xprop -root
# ENLIGHTENMENT_VERSION(STRING) = "Moksha 0.2.0.15989"
- $desktop[0] = 'Moksha';
- $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+');
- $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1];
+ $desktop->[0] = 'Moksha';
+ $desktop->[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+');
+ $desktop->[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop->[1];
}
elsif ($xdg_desktop eq 'enlightenment' || $gdmsession eq 'enlightenment' ||
(main::check_program('enlightenment') && main::awk(\@xprop,'enlightenment'))){
# no -v or --version but version is in xprop -root
# ENLIGHTENMENT_VERSION(STRING) = "Enlightenment 0.16.999.49898"
- $desktop[0] = 'Enlightenment';
- $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+');
- $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1];
+ $desktop->[0] = 'Enlightenment';
+ $desktop->[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+');
+ $desktop->[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop->[1];
}
# the sequence here matters, some desktops like icewm, razor, let you set different
# wm, so we want to get the main controlling desktop first, then fall back to the wm
# detections. get_ps_de_data() and get_wm() will handle alternate wm detections.
- if (!$desktop[0]){
+ if (!$desktop->[0]){
# 0 check program; 1 xprop search; 2: data; 3 - optional: ps_gui search
my @desktops =(
['icewm','icewm','icewm'],
@@ -25410,7 +26217,7 @@ sub get_env_xprop_non_gnome_based_data {
foreach my $item (@desktops){
if (main::check_program($item->[0]) && main::awk(\@xprop,$item->[1]) &&
(!$item->[4] || (@ps_gui && (grep {/$item->[4]/} @ps_gui)))){
- ($desktop[0],$desktop[1]) = main::program_data($item->[2]);
+ ($desktop->[0],$desktop->[1]) = main::program_data($item->[2]);
last;
}
}
@@ -25442,14 +26249,14 @@ sub get_ps_de_data {
# no need to use check program with short list of ps_gui
if ($psg =~ /^($matches)$/){
my $item = $1;
- ($desktop[0],$desktop[1]) = main::program_data($item);
+ ($desktop->[0],$desktop->[1]) = main::program_data($item);
if ($extra > 1 && $item eq 'xfdesktop'){
- ($desktop[2],$desktop[3]) = main::program_data('xfdesktop-toolkit',$item,1);
+ ($desktop->[2],$desktop->[3]) = main::program_data('xfdesktop-toolkit',$item,1);
}
last;
}
}
- if (!$desktop[0]){
+ if (!$desktop->[0]){
# order matters, these have alternate search patterns from default name
# 1 check program; 2 ps_gui search; 3 data; 4: trigger alternate values/version
@wms =(
@@ -25469,9 +26276,9 @@ sub get_ps_de_data {
foreach my $item (@wms){
# no need to use check program with short list of ps_gui
if (grep {/^$item->[1]$/} @ps_gui){
- ($desktop[0],$desktop[1]) = main::program_data($item->[2],$item->[3]);
+ ($desktop->[0],$desktop->[1]) = main::program_data($item->[2],$item->[3]);
if ($extra > 1 && $item->[0] eq 'xfdesktop'){
- ($desktop[2],$desktop[3]) = main::program_data('xfdesktop-toolkit',$item->[0],1);
+ ($desktop->[2],$desktop->[3]) = main::program_data('xfdesktop-toolkit',$item->[0],1);
}
last;
}
@@ -25485,7 +26292,7 @@ sub get_ps_de_data {
sub set_gtk_data {
eval $start if $b_log;
if (main::check_program('gtk-launch')){
- ($desktop[2],$desktop[3]) = main::program_data('gtk-launch');
+ ($desktop->[2],$desktop->[3]) = main::program_data('gtk-launch');
}
eval $end if $b_log;
}
@@ -25502,22 +26309,22 @@ sub set_qt_data {
}
# alternate: qt4-default, qt4-qmake or qt5-default, qt5-qmake
# often this exists, is executable, but actually is nothing, shows error
- if (!$desktop[3] && main::check_program('qmake')){
- ($desktop[2],$desktop[3]) = main::program_data('qmake');
+ if (!$desktop->[3] && main::check_program('qmake')){
+ ($desktop->[2],$desktop->[3]) = main::program_data('qmake');
}
- if (!$desktop[3] && main::check_program('qtdiag')){
- ($desktop[2],$desktop[3]) = main::program_data('qtdiag');
+ if (!$desktop->[3] && main::check_program('qtdiag')){
+ ($desktop->[2],$desktop->[3]) = main::program_data('qtdiag');
}
- if (!$desktop[3] && ($program = main::check_program("kf$kde_version-config"))){
+ if (!$desktop->[3] && ($program = main::check_program("kf$kde_version-config"))){
@version_data = main::grabber("$program --version 2>/dev/null");
- $desktop[2] = 'Qt';
- $desktop[3] = main::awk(\@version_data,'^Qt:',2) if @version_data;
+ $desktop->[2] = 'Qt';
+ $desktop->[3] = main::awk(\@version_data,'^Qt:',2) if @version_data;
}
# note: qt 5 does not show qt version in kded5, sigh
- if (!$desktop[3] && ($program = main::check_program("kded$kde_version"))){
+ if (!$desktop->[3] && ($program = main::check_program("kded$kde_version"))){
@version_data = main::grabber("$program --version 2>/dev/null");
- $desktop[2] = 'Qt';
- $desktop[3] = main::awk(\@version_data,'^Qt:',2) if @version_data;
+ $desktop->[2] = 'Qt';
+ $desktop->[3] = main::awk(\@version_data,'^Qt:',2) if @version_data;
}
eval $end if $b_log;
}
@@ -25528,7 +26335,7 @@ sub get_wm {
get_wm_main();
}
# note, some wm, like cinnamon muffin, do not appear in ps aux, but do in wmctrl
- if ((!$desktop[5] || $force{'wmctrl'}) && (my $program = main::check_program('wmctrl'))){
+ if ((!$desktop->[5] || $force{'wmctrl'}) && (my $program = main::check_program('wmctrl'))){
get_wm_wmctrl($program);
}
eval $end if $b_log;
@@ -25549,7 +26356,7 @@ sub get_wm_main {
}
}
}
- if (!$desktop[5]){
+ if (!$desktop->[5]){
main::set_ps_gui() if !$loaded{'ps-gui'};
# order matters, see above logic
# due to lisp/python starters, clfswm/stumpwm/qtile will not detect here
@@ -25571,7 +26378,7 @@ sub get_wm_main {
}
}
get_wm_version('manual',$working) if $working;
- $desktop[5] = $working if !$desktop[5] && $working;
+ $desktop->[5] = $working if !$desktop->[5] && $working;
eval $end if $b_log;
}
sub get_wm_wmctrl {
@@ -25580,19 +26387,19 @@ sub get_wm_wmctrl {
my $cmd = "$program -m 2>/dev/null";
my @data = main::grabber($cmd,'','strip');
main::log_data('dump','@data',\@data) if $b_log;
- $desktop[5] = main::awk(\@data,'^Name',2,'\s*:\s*');
- $desktop[5] = '' if $desktop[5] && $desktop[5] eq 'N/A';
- if ($desktop[5]){
+ $desktop->[5] = main::awk(\@data,'^Name',2,'\s*:\s*');
+ $desktop->[5] = '' if $desktop->[5] && $desktop->[5] eq 'N/A';
+ if ($desktop->[5]){
# variants: gnome shell;
# IceWM 1.3.8 (Linux 3.2.0-4-amd64/i686) ; Metacity (Marco) ; Xfwm4
- $desktop[5] =~ s/\d+\.\d\S+|[\[\(].*\d+\.\d.*[\)\]]//g;
- $desktop[5] = main::trimmer($desktop[5]);
+ $desktop->[5] =~ s/\d+\.\d\S+|[\[\(].*\d+\.\d.*[\)\]]//g;
+ $desktop->[5] = main::trimmer($desktop->[5]);
# change Metacity (Marco) to marco
- if ($desktop[5] =~ /marco/i){$desktop[5] = 'marco'}
- elsif ($desktop[5] =~ /muffin/i){$desktop[5] = 'muffin'}
- elsif (lc($desktop[5]) eq 'gnome shell'){$desktop[5] = 'gnome-shell'}
- elsif ($desktop_session eq 'trinity' && lc($desktop[5]) eq 'kwin'){$desktop[5] = 'Twin'}
- get_wm_version('wmctrl',$desktop[5]);
+ if ($desktop->[5] =~ /marco/i){$desktop->[5] = 'marco'}
+ elsif ($desktop->[5] =~ /muffin/i){$desktop->[5] = 'muffin'}
+ elsif (lc($desktop->[5]) eq 'gnome shell'){$desktop->[5] = 'gnome-shell'}
+ elsif ($desktop_session eq 'trinity' && lc($desktop->[5]) eq 'kwin'){$desktop->[5] = 'Twin'}
+ get_wm_version('wmctrl',$desktop->[5]);
}
eval $end if $b_log;
}
@@ -25601,7 +26408,7 @@ sub get_wm_version {
my ($type,$wm) = @_;
# we don't want the gnome-shell version, and the others have no --version
# we also don't want to run --version again on stuff we already have tested
- return if !$wm || $wm =~ /^(budgie-wm|gnome-shell)$/ || ($desktop[0] && lc($desktop[0]) eq lc($wm));
+ return if !$wm || $wm =~ /^(budgie-wm|gnome-shell)$/ || ($desktop->[0] && lc($desktop->[0]) eq lc($wm));
my $temp = (split(/\s+/, $wm))[0];
if ($temp){
$temp = (split(/\s+/, $temp))[0];
@@ -25610,8 +26417,8 @@ sub get_wm_version {
my @data = main::program_data($temp,$temp,3);
return if !$data[0];
# print Data::Dumper::Dumper \@data;
- $desktop[5] = $data[0] if $type eq 'manual';
- $desktop[6] = $data[1] if $data[1];
+ $desktop->[5] = $data[0] if $type eq 'manual';
+ $desktop->[6] = $data[1] if $data[1];
}
eval $end if $b_log;
}
@@ -25644,7 +26451,7 @@ sub set_info_data {
}
if (@info){
main::uniq(\@info);
- $desktop[4] = join(', ', @info);
+ $desktop->[4] = join(', ', @info);
}
eval $end if $b_log;
}
@@ -25748,9 +26555,9 @@ sub set {
sub lspci_data {
eval $start if $b_log;
my ($busid_full,$subsystem,$subsystem_id);
- my @data = pci_grabber('lspci');
- # print Data::Dumper::Dumper \@data;
- foreach (@data){
+ my $data = pci_grabber('lspci');
+ # print Data::Dumper::Dumper $data;
+ foreach (@$data){
# print "$_\n";
if ($device){
if ($_ eq '~'){
@@ -25827,12 +26634,12 @@ sub lspci_data {
$device = main::clean($device);
# corrupted lspci truncation bug; and ancient lspci, 2.4 kernels
if (!$vendor_id){
- my @temp = lspci_n_data($busid_full);
- if (@temp){
- $vendor_id = $temp[1];
- $chip_id = $temp[2];
- $type_id = $temp[0] if !$type_id;
- $rev = $temp[3] if !$rev && $temp[3];
+ my $temp = lspci_n_data($busid_full);
+ if (@$temp){
+ $type_id = $temp->[0] if !$type_id;
+ $vendor_id = $temp->[1];
+ $chip_id = $temp->[2];
+ $rev = $temp->[3] if !$rev && $temp->[3];
}
}
$use{'hardware-raid'} = 1 if $type_id eq '0104';
@@ -25853,8 +26660,8 @@ sub lspci_n_data {
$b_lspci_n = 1;
my (@data);
if ($fake{'lspci'}){
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/steve-mint-topaz-lspci-n.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/ben81-hwraid-lspci-n.txt";
+ # my $file = "$fake_data_dir/lspci/steve-mint-topaz-lspci-n.txt";
+ # my $file = "$fake_data_dir/lspci/ben81-hwraid-lspci-n.txt";
# @data = main::reader($file,'strip');
}
else {
@@ -25869,11 +26676,11 @@ sub lspci_n_data {
print Data::Dumper::Dumper \%lspci_n if $dbg[4];
main::log_data('dump','%lspci_n',\%lspci_n) if $b_log;
}
- my @return = ($lspci_n{$bus_id}) ? @{$lspci_n{$bus_id}}: ();
- print Data::Dumper::Dumper \@return if $dbg[4];
- main::log_data('dump','@return',\@return) if $b_log;
+ my $return = ($lspci_n{$bus_id}) ? $lspci_n{$bus_id}: [];
+ print Data::Dumper::Dumper $return if $dbg[50];
+ main::log_data('dump','@$return') if $b_log;
eval $end if $b_log;
- return @return;
+ return $return;
}
# em0@pci0:6:0:0: class=0x020000 card=0x10d315d9 chip=0x10d38086 rev=0x00 hdr=0x00
@@ -25883,8 +26690,8 @@ sub lspci_n_data {
# subclass = ethernet
sub pciconf_data {
eval $start if $b_log;
- my @data = pci_grabber('pciconf');
- foreach (@data){
+ my $data = pci_grabber('pciconf');
+ foreach (@$data){
if ($driver){
if ($_ eq '~'){
$vendor = main::clean($vendor);
@@ -25956,9 +26763,9 @@ sub pciconf_data {
sub pcidump_data {
eval $start if $b_log;
- my @data = pci_grabber('pcidump');
+ my $data = pci_grabber('pcidump');
main::set_dboot_data() if !$loaded{'dboot'};
- foreach (@data){
+ foreach (@$data){
if ($_ eq '~' && $busid && $device){
@temp = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id,
$rev,$port,$driver,$modules,$driver_nu,'','','',$serial);
@@ -26005,9 +26812,9 @@ sub pcidump_driver {
}
sub pcictl_data {
eval $start if $b_log;
- my @data = pci_grabber('pcictl');
- my @data2 = pci_grabber('pcictl-n');
- foreach (@data){
+ my $data = pci_grabber('pcictl');
+ my $data2 = pci_grabber('pcictl-n');
+ foreach (@$data){
if ($_ eq '~' && $busid && $device){
@temp = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id,
$rev,$port,$driver,$modules,$driver_nu);
@@ -26030,7 +26837,7 @@ sub pcictl_data {
$busid = $1;
$busid_nu = $2;
$device = main::clean($3);
- my $working = (grep {/^${busid}:${busid_nu}:\s/} @data2)[0];
+ my $working = (grep {/^${busid}:${busid_nu}:\s/} @$data2)[0];
if ($working &&
$working =~ /^${busid}:${busid_nu}:\s+0x([0-9a-f]{4})([0-9a-f]{4})\s+\(0x([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]+\)/){
$vendor_id = $1;
@@ -26048,62 +26855,63 @@ sub pcictl_data {
sub pci_grabber {
eval $start if $b_log;
my ($program) = @_;
- my ($args,$path,$pattern,@data,@working);
+ my ($args,$path,$pattern,$data);
+ my $working = [];
if ($program eq 'lspci'){
# 2.2.8 lspci did not support -k, added in 2.2.9, but -v turned on -k
$args = ' -nnv';
$path = $alerts{'lspci'}->{'path'};
- $pattern = '^[0-9a-f]+:';
+ $pattern = qr/^[0-9a-f]+:/;
}
elsif ($program eq 'pciconf'){
$args = ' -lv';
$path = $alerts{'pciconf'}->{'path'};
- $pattern = '^([^@]+)\@pci';
+ $pattern = qr/^([^@]+)\@pci/;
}
elsif ($program eq 'pcidump'){
$args = ' -v';
$path = $alerts{'pcidump'}->{'path'};
- $pattern = '^[0-9a-f]+:';
+ $pattern = qr/^[0-9a-f]+:/;
}
elsif ($program eq 'pcictl'){
$args = ' pci0 list -N';
$path = $alerts{'pcictl'}->{'path'};
- $pattern = '^[0-9a-f:]+:';
+ $pattern = qr/^[0-9a-f:]+:/;
}
elsif ($program eq 'pcictl-n'){
$args = ' pci0 list -n';
$path = $alerts{'pcictl'}->{'path'};
- $pattern = '^[0-9a-f:]+:';
+ $pattern = qr/^[0-9a-f:]+:/;
}
if ($fake{'lspci'} || $fake{'pciconf'} || $fake{'pcictl'} || $fake{'pcidump'}){
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/pciconf/pci-freebsd-8.2-2";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/pcidump/pci-openbsd-6.1-vm.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/pcictl/pci-netbsd-9.1-vm.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/racermach-1-knnv.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/rk016013-knnv.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/kot--book-lspci-nnv.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/steve-mint-topaz-lspci-nnkv.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/ben81-hwraid-lspci-nnv.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lspci/gx78b-lspci-nnv.txt";
- # @data = main::reader($file,'strip');
+ # my $file = "$fake_data_dir/pciconf/pci-freebsd-8.2-2";
+ # my $file = "$fake_data_dir/pcidump/pci-openbsd-6.1-vm.txt";
+ # my $file = "$fake_data_dir/pcictl/pci-netbsd-9.1-vm.txt";
+ # my $file = "$fake_data_dir/lspci/racermach-1-knnv.txt";
+ # my $file = "$fake_data_dir/lspci/rk016013-knnv.txt";
+ # my $file = "$fake_data_dir/lspci/kot--book-lspci-nnv.txt";
+ # my $file = "$fake_data_dir/lspci/steve-mint-topaz-lspci-nnkv.txt";
+ # my $file = "$fake_data_dir/lspci/ben81-hwraid-lspci-nnv.txt";
+ # my $file = "$fake_data_dir/lspci/gx78b-lspci-nnv.txt";
+ # $data = main::reader($file,'strip','ref');
}
else {
- @data = main::grabber("$path $args 2>/dev/null",'','strip');
+ $data = main::grabber("$path $args 2>/dev/null",'','strip','ref');
}
- if (@data){
- $use{'pci-tool'} = 1 if scalar @data > 10;
- foreach (@data){
+ if (@$data){
+ $use{'pci-tool'} = 1 if scalar @$data > 10;
+ foreach (@$data){
# this is the group separator and assign trigger
if ($_ =~ /$pattern/i){
- push(@working, '~');
+ push(@$working, '~');
}
- push(@working, $_);
+ push(@$working, $_);
}
- push(@working, '~');
+ push(@$working, '~');
}
- print Data::Dumper::Dumper \@working if $dbg[30];
+ print Data::Dumper::Dumper $working if $dbg[30];
eval $end if $b_log;
- return @working;
+ return $working;
}
sub soc_data {
@@ -26456,18 +27264,18 @@ sub get {
my $id = $_[0];
return if !$id || !%disks_bsd;
$id =~ s|^/dev/||;
- my (%data);
+ my $data = {};
# this handles mainly zfs, which can be either disk or part
if ($disks_bsd{$id}){
- %data = %{$disks_bsd{$id}};
- delete $data{'partitions'} if $data{'partitions'};
+ $data = $disks_bsd{$id};
+ delete $data->{'partitions'} if $data->{'partitions'};
}
else {
OUTER: foreach my $key (keys %disks_bsd){
if ($disks_bsd{$key}->{'partitions'}){
foreach my $part (keys %{$disks_bsd{$key}->{'partitions'}}){
if ($part eq $id){
- %data = %{$disks_bsd{$key}->{'partitions'}{$part}};
+ $data = $disks_bsd{$key}->{'partitions'}{$part};
last OUTER;
}
}
@@ -26475,7 +27283,7 @@ sub get {
}
}
eval $end if $b_log;
- return %data;
+ return $data;
}
sub set_dboot_disks {
eval $start if $b_log;
@@ -26738,7 +27546,8 @@ sub set_gpart_data {
sub get_display_manager {
eval $start if $b_log;
- my (@data,@found,@glob,$link,$path,@temp);
+ my (@data,@glob,$link,$path,@temp);
+ my $found = [];
# ldm - LTSP display manager. Note that sddm does not appear to have a .pid
# extension in Arch. Guessing on cdm, qingy. pcdm uses vt, PCDM-vt9.pid
# Not verified: qingy emptty; greetd.run verified, but alternate:
@@ -26746,8 +27555,8 @@ sub get_display_manager {
# greetd frontends: agreety dlm gtkgreet qtgreet tuigreet wlgreet
# mlogin may be mlogind, not verified
my @dms = qw(brzdm cdm clogin emptty entranced gdm gdm3 greetd kdm kdm3 ldm
- lightdm lxdm ly mdm mlogin nodm pcdm qingy sddm slim tbsm tdm udm wdm xdm
- xenodm xlogin);
+ lightdm lxdm ly mdm mlogin nodm pcdm qingy sddm slim slimski tbsm tdm udm wdm
+ xdm xenodm xlogin);
# these are the only one I know of so far that have version info. xlogin /
# clogin do, -V, brzdm -v, but syntax not verified.
my @dms_version = qw(gdm gdm3 lightdm ly slim);
@@ -26804,29 +27613,29 @@ sub get_display_manager {
if (scalar @dms > 1 && (my $temp = ServiceData::get('status',$dm))){
$dm_info[2] = message('stopped') if $temp && $temp =~ /stopped|disabled/;
}
- push(@found,[@dm_info]);
+ push(@$found,[@dm_info]);
}
- if (!@found){
+ if (!@$found){
# ly does not have a run/pid file
if (grep {$_ eq 'ly'} @ps_gui){
@data = program_data('ly','ly',3);
$dm_info[0] = $data[0];
$dm_info[1] = $data[1];
- $found[0] = [@dm_info];
+ $found->[0] = [@dm_info];
}
elsif (grep {/startx$/} @ps_gui){
- $found[0] = ['startx'];
+ $found->[0] = ['startx'];
}
elsif (grep {$_ eq 'xinit'} @ps_gui){
- $found[0] = ['xinit'];
+ $found->[0] = ['xinit'];
}
}
# might add this in, but the rate of new dm's makes it more likely it's an
# unknown dm, so we'll keep output to N/A
# print Data::Dumper::Dumper \@found;
- log_data('dump','display manager: @found',\@found) if $b_log;
+ log_data('dump','display manager: @$found',$found) if $b_log;
eval $end if $b_log;
- return \@found if @found;
+ return $found;
}
## DistroData
@@ -27499,17 +28308,17 @@ sub generate_data {
my ($content,@data,@working,$type,$handle);
if ($fake{'dmidecode'}){
my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/pci-freebsd-8.2-2";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-loki-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-t41-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-mint-20180106.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-vmware-ram-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-tyan-4408.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ram/dmidecode-speed-configured-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ram/dmidecode-speed-configured-2.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/ram/00srv-dmidecode-mushkin-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-slots-pcix-pcie-1.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/dmidecode/dmidecode-Microknopix-pci-vga-types-5-6-16-17.txt";
+ # $file = "$fake_data_dir/dmidecode/pci-freebsd-8.2-2";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-loki-1.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-t41-1.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-mint-20180106.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-vmware-ram-1.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-tyan-4408.txt";
+ # $file = "$fake_data_dir/ram/dmidecode-speed-configured-1.txt";
+ # $file = "$fake_data_dir/ram/dmidecode-speed-configured-2.txt";
+ # $file = "$fake_data_dir/ram/00srv-dmidecode-mushkin-1.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-slots-pcix-pcie-1.txt";
+ # $file = "$fake_data_dir/dmidecode/dmidecode-Microknopix-pci-vga-types-5-6-16-17.txt";
# open(my $fh, '<', $file) or die "can't open $file: $!";
# chomp(@data = <$fh>);
}
@@ -27590,7 +28399,8 @@ sub get_driver_modules {
# name is different from the driver name, even though it's the same thing.
sub get_gcc_data {
eval $start if $b_log;
- my ($gcc,@data,@gccs,@temp);
+ my ($gcc,@data,@temp);
+ my $gccs = [];
# NOTE: We can't use program_version because we don't yet know where
# the version number is
if (my $program = check_program('gcc')){
@@ -27608,14 +28418,14 @@ sub get_gcc_data {
@temp = globber('/usr/bin/gcc-*');
foreach (@temp){
if (/\/gcc-([0-9.]+)$/){
- push(@gccs, $1);
+ push(@$gccs, $1);
}
}
}
- unshift(@gccs, $gcc);
- log_data('dump','@gccs',\@gccs) if $b_log;
+ unshift(@$gccs, $gcc);
+ log_data('dump','@gccs',$gccs) if $b_log;
eval $end if $b_log;
- return @gccs;
+ return $gccs;
}
## GlabelData - set/get
@@ -27688,19 +28498,30 @@ sub get_init_data {
my (@data);
# this test is pretty solid, if pid 1 is owned by systemd, it is systemd
# otherwise that is 'init', which covers the rest of the init systems.
- # more data may be needed for other init systems.
- if ($comm){
- if ($comm =~ /systemd/){
- $init = 'systemd';
- if ($program = check_program('systemd')){
- $init_version = program_version($program,'^systemd','2','--version',1);
- }
- if (!$init_version && ($program = check_program('systemctl'))){
- $init_version = program_version($program,'^systemd','2','--version',1);
- }
- }
+ # more data may be needed for other init systems.
+ # Some systemd cases no /proc/1/comm exists however :(
+ if (($comm && $comm =~ /systemd/) || -e '/run/systemd/units'){
+ $init = 'systemd';
+ if ($program = check_program('systemd')){
+ $init_version = program_version($program,'^systemd','2','--version',1);
+ }
+ if (!$init_version && ($program = check_program('systemctl'))){
+ $init_version = program_version($program,'^systemd','2','--version',1);
+ }
+ if ($runlevel && $runlevel =~ /^\d$/){
+ my $target = '';
+ if ($runlevel == 1){
+ $target = 'rescue';}
+ elsif ($runlevel > 1 && $runlevel < 5){
+ $target = 'multi-user';}
+ elsif ($runlevel == 5){
+ $target = 'graphical';}
+ $runlevel = "$target ($runlevel)" if $target;
+ }
+ }
+ if (!$init && $comm){
# epoch version == Epoch Init System 1.0.1 "Sage"
- elsif ($comm =~ /epoch/){
+ if ($comm =~ /epoch/){
$init = 'Epoch';
$init_version = program_version('epoch', '^Epoch', '4','version');
}
@@ -27761,16 +28582,15 @@ sub get_init_data {
$runlevel = (grabber("$program -r 2>/dev/null"))[0];
}
}
- my %init = (
+ eval $end if $b_log;
+ return {
'init-type' => $init,
'init-version' => $init_version,
'rc-type' => $rc,
'rc-version' => $rc_version,
'runlevel' => $runlevel,
'default' => $default,
- );
- eval $end if $b_log;
- return %init;
+ };
}
## IpData
@@ -27790,8 +28610,8 @@ sub set {
sub set_ip_addr {
eval $start if $b_log;
my @data = main::grabber($alerts{'ip'}->{'path'} . " addr 2>/dev/null",'\n','strip');
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/if/scope-ipaddr-1.txt";
- # my $file = "$ENV{'HOME'}/bin/scripts/inxi/data/networking/ip-addr-blue-advance.txt";
+ # my $file = "$fake_data_dir/if/scope-ipaddr-1.txt";
+ # my $file = "$fake_data_dir/networking/ip-addr-blue-advance.txt";
# my @data = reader($file,'strip') or die $!;
my ($b_skip,$broadcast,$if,$ip,@ips,$scope,$if_id,$type,@temp,@temp2);
foreach (@data){
@@ -27844,7 +28664,7 @@ sub set_ip_addr {
sub set_ifconfig {
eval $start if $b_log;
my @data = main::grabber($alerts{'ifconfig'}->{'path'} . " 2>/dev/null",'\n','');
- # my @data = reader("$ENV{'HOME'}/bin/scripts/inxi/data/if/vps-ifconfig-1.txt",'') or die $!;
+ # my @data = reader("$fake_data_dir/if/vps-ifconfig-1.txt",'') or die $!;
my ($b_skip,$broadcast,$if,@ips_bsd,$ip,@ips,$scope,$if_id,$type,@temp,@temp2);
my ($state,$speed,$duplex,$mac);
foreach (@data){
@@ -27920,14 +28740,12 @@ sub set_ifconfig {
$scope = $2;
}
$scope = 'link' if $ip =~ /^fe80/;
- @temp = ($type,$ip,$broadcast,$scope,$if_id);
- push(@ips,[@temp]);
+ push(@ips,[$type,$ip,$broadcast,$scope,$if_id]);
# print Data::Dumper::Dumper \@ips;
}
}
if (@ips){
- @temp = ($if,[@ips]);
- push(@ifs,@temp);
+ push(@ifs,($if,[@ips]));
}
if ($mac){
@temp = ($if,[($state,$speed,$duplex,$mac)]);
@@ -27971,25 +28789,25 @@ sub get_kernel_bits {
sub get_kernel_data {
eval $start if $b_log;
my ($ksplice) = ('');
- my @kernel;
+ my $kernel = [];
# Linux; yawn; 4.9.0-3.1-liquorix-686-pae; #1 ZEN SMP PREEMPT liquorix 4.9-4 (2017-01-14); i686
# FreeBSD; siwi.pair.com; 8.2-STABLE; FreeBSD 8.2-STABLE #0: Tue May 31 14:36:14 EDT 2016 erik5@iddhi.pair.com:/usr/obj/usr/src/sys/82PAIRx-AMD64; amd64
if (@uname){
- $kernel[0] = $uname[2];
- if ((my $program = check_program('uptrack-uname')) && $kernel[0]){
+ $kernel->[0] = $uname[2];
+ if ((my $program = check_program('uptrack-uname')) && $kernel->[0]){
$ksplice = qx($program -rm);
$ksplice = trimmer($ksplice);
- $kernel[0] = $ksplice . ' (ksplice)' if $ksplice;
+ $kernel->[0] = $ksplice . ' (ksplice)' if $ksplice;
}
- $kernel[1] = $uname[-1];
+ $kernel->[1] = $uname[-1];
}
# we want these to have values to save validation checks for output
- $kernel[0] ||= 'N/A';
- $kernel[1] ||= 'N/A';
- log_data('data',"kernel: " . join('; ', @kernel) . " ksplice: $ksplice") if $b_log;
+ $kernel->[0] ||= 'N/A';
+ $kernel->[1] ||= 'N/A';
+ log_data('data',"kernel: " . join('; ', $kernel) . " ksplice: $ksplice") if $b_log;
log_data('dump','perl @uname', \@uname) if $b_log;
eval $end if $b_log;
- return \@kernel;
+ return $kernel;
}
## KernelParameters
@@ -28032,15 +28850,15 @@ sub get {
eval $start if $b_log;
my $item = $_[0];
return if !@lsblk;
- my (%device);
+ my $result;
foreach my $device (@lsblk){
if ($device->{'name'} eq $item){
- %device = %$device;
+ $result = $device;
last;
}
}
eval $start if $b_log;
- return %device;
+ return ($result) ? $result : {};
}
sub set {
eval $start if $b_log;
@@ -28139,7 +28957,8 @@ sub full {
eval $start if $b_log;
my ($source) = @_;
my $num = 0;
- my ($memory,@rows);
+ my ($memory);
+ my $row = {};
my ($gpu_ram,$percent,$total,$used) = (0,'','','');
$loaded{'memory'} = 1;
$memory = get('splits');
@@ -28154,12 +28973,12 @@ sub full {
}
}
my $key = ($source eq 'process') ? 'System RAM': 'RAM';
- $rows[0]->{main::key($num++,1,1,$key)} = '';
- $rows[0]->{main::key($num++,0,2,'total')} = $total;
- $rows[0]->{main::key($num++,0,2,'used')} = $used;
- $rows[0]->{main::key($num++,0,2,'gpu')} = $gpu_ram if $gpu_ram;
+ $row->{main::key($num++,1,1,$key)} = '';
+ $row->{main::key($num++,0,2,'total')} = $total;
+ $row->{main::key($num++,0,2,'used')} = $used;
+ $row->{main::key($num++,0,2,'gpu')} = $gpu_ram if $gpu_ram;
eval $end if $b_log;
- return @rows;
+ return $row;
}
sub meminfo_data {
eval $start if $b_log;
@@ -28381,21 +29200,23 @@ sub get_module_version {
# called from either -r or -Ix, -r precedes.
{
package PackageData;
-my ($count,%counts,@list,$num,%output,$program,$type);
+my ($count,%counts,@list,$num,$program,$type);
$counts{'total'} = 0;
sub get {
eval $start if $b_log;
# $num passed by reference to maintain incrementing where requested
($type,$num) = @_;
$loaded{'package-data'} = 1;
+ my $output = {};
package_counts();
appimage_counts();
- create_output();
+ create_output($output);
eval $end if $b_log;
- return %output;
+ return $output;
}
sub create_output {
eval $start if $b_log;
+ my $output = $_[0];
my $total;
if ($counts{'total'}){
$total = $counts{'total'};
@@ -28420,10 +29241,10 @@ sub create_output {
}
$total = '' if !$b_mismatch;
}
- $output{main::key($$num++,1,1,'Packages')} = $total;
+ $output->{main::key($$num++,1,1,'Packages')} = $total;
# if blocked pm secondary, only show if admin
if ($counts{'note'} && (!$counts{'total'} || $b_admin || $total < 100)){
- $output{main::key($$num++,0,2,'note')} = $counts{'note'};
+ $output->{main::key($$num++,0,2,'note')} = $counts{'note'};
}
if ($extra > 1 && %counts){
foreach (sort keys %counts){
@@ -28433,10 +29254,10 @@ sub create_output {
if ($counts{$_}->[0] || $b_admin){
my $key = $_;
$key =~ s/^zzz-//; # get rid of the special sorters for items to show last
- $output{main::key($$num++,$cont,$ind,$key)} = $counts{$_}->[0];
+ $output->{main::key($$num++,$cont,$ind,$key)} = $counts{$_}->[0];
if ($b_admin && $counts{$_}->[1]){
($cont,$ind) = (0,3);
- $output{main::key($$num++,$cont,$ind,'lib')} = $counts{$_}->[1];
+ $output->{main::key($$num++,$cont,$ind,'lib')} = $counts{$_}->[1];
}
}
}
@@ -29249,22 +30070,22 @@ sub get {
eval $start if $b_log;
my $item = $_[0];
return if !@proc_partitions;
- my (@device);
+ my $result;
foreach my $device (@proc_partitions){
if ($device->[3] eq $item){
- @device = @$device;
+ $result = $device;
last;
}
}
eval $start if $b_log;
- return @device;
+ return ($result) ? $result : [];
}
sub proc_data {
eval $start if $b_log;
my $file = $_[0];
if ($fake{'partitions'}){
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/proc-partitions-1.txt";
+ # $file = "$fake_data_dir/proc-partitions-1.txt";
}
my @parts = main::reader($file,'strip');
# print Data::Dumper::Dumper \@parts;
@@ -29380,13 +30201,13 @@ sub get_pcie_data {
sub set_ps_aux {
eval $start if $b_log;
- my ($header,@ps,@temp);
+ my ($header,$ps,@temp);
# note: some ps cut off output based on terminal width
# ww sets width unlimited
$loaded{'ps-aux'} = 1;
- @ps = grabber("ps wwaux 2>/dev/null",'','strip');
- if (@ps){
- $header = shift @ps; # get rid of header row
+ $ps = grabber("ps wwaux 2>/dev/null",'','strip','ref');
+ if (@$ps){
+ $header = shift @$ps; # get rid of header row
# handle busy box, which has 3 columns, regular ps aux has 11
# avoid deprecated implicit split error in older Perls
@temp = split(/\s+/, $header);
@@ -29396,8 +30217,8 @@ sub set_ps_aux {
my $version = qx(ps --version 2>&1);
$b_busybox_ps = 1 if $version =~ /busybox/i;
}
- return if !@ps; # note: mips/openwrt ps has no 'a'
- for (@ps){
+ return if !@$ps; # note: mips/openwrt ps has no 'a'
+ for (@$ps){
next if !$_;
next if $self_name eq 'inxi' && /\/$self_name\b/;
$_ = lc;
@@ -29484,7 +30305,7 @@ sub set_ps_gui {
$wl_compositors = '|' . join('|',qw(asc awc
cage cagebreak cardboard chameleonwm clayland comfc
dwc dwl epd-wm fireplace feathers fenestra glass gamescope greenfield grefson
- hikari hopalong inaban japokwm kiwmi labwc laikawm lipstick liri
+ hikari hopalong hyprland inaban japokwm kiwmi labwc laikawm lipstick liri
mahogany marina maze motorcar newm nucleus orbital perceptia phoc pywm qtile
river rootston rustland simulavr skylight sommelier sway swc swvkc
tabby taiwins tinybox tinywl trinkster velox vimway vivarium
@@ -29492,6 +30313,7 @@ sub set_ps_gui {
weston wio\+? wxr[cd] xuake));
$matches .= $wl_compositors;
}
+ $matches = qr/$matches/;
foreach (@ps_cmd){
if (/^(|[\S]*\/)($matches)(\/|\s|$)/){
$working = $2;
@@ -29509,8 +30331,10 @@ sub get_runlevel_data {
eval $start if $b_log;
my $runlevel = '';
if (my $program = check_program('runlevel')){
+ # variants: N 5; 3 5; unknown
$runlevel = (grabber("$program 2>/dev/null"))[0];
- $runlevel =~ s/[^\d]//g if $runlevel;
+ $runlevel = undef if $runlevel && lc($runlevel) eq 'unknown';
+ $runlevel =~ s/^(\S\s)?(\d)$/$2/ if $runlevel;
# print_line($runlevel . ";;");
}
eval $end if $b_log;
@@ -29524,28 +30348,35 @@ sub get_runlevel_default {
eval $start if $b_log;
my @data;
my $default = '';
- my $b_systemd = 0;
- my $inittab = '/etc/inittab';
- my $systemd = '/etc/systemd/system/default.target';
- my $upstart = '/etc/init/rc-sysinit.conf';
- # note: systemd systems do not necessarily have this link created
- if (-e $systemd){
- $default = readlink($systemd);
- $default =~ s/.*\/// if $default;
- $b_systemd = 1;
- }
- # http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level
- # note that technically default can be changed at boot but for inxi purposes
- # that does not matter, we just want to know the system default
- elsif (-r $upstart){
- # env DEFAULT_RUNLEVEL=2
- @data = reader($upstart);
- $default = awk(\@data,'^env\s+DEFAULT_RUNLEVEL',2,'=');
- }
- # handle weird cases where null but inittab exists
- if (!$default && -r $inittab){
- @data = reader($inittab);
- $default = awk(\@data,'^id.*initdefault',2,':');
+ if (my $program = check_program('systemctl')){
+ # note: systemd systems do not necessarily have this link created
+ my $systemd = '/etc/systemd/system/default.target';
+ # faster to read than run
+ if (-e $systemd){
+ $default = readlink($systemd);
+ $default =~ s/(.*\/|\.target$)//g if $default;
+ }
+ if (!$default){
+ $default = (grabber("$program get-default 2>/dev/null"))[0];
+ $default =~ s/\.target$// if $default;
+ }
+ }
+ if (!$default){
+ # http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level
+ # note that technically default can be changed at boot but for inxi purposes
+ # that does not matter, we just want to know the system default
+ my $upstart = '/etc/init/rc-sysinit.conf';
+ my $inittab = '/etc/inittab';
+ if (-r $upstart){
+ # env DEFAULT_RUNLEVEL=2
+ @data = reader($upstart);
+ $default = awk(\@data,'^env\s+DEFAULT_RUNLEVEL',2,'=');
+ }
+ # handle weird cases where null but inittab exists
+ if (!$default && -r $inittab){
+ @data = reader($inittab);
+ $default = awk(\@data,'^id.*initdefault',2,':');
+ }
}
eval $end if $b_log;
return $default;
@@ -30069,13 +30900,13 @@ sub set_sysctl_data {
}
else {
my $file;
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sysctl/obsd_6.1_sysctl_soekris6501_root.txt";
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sysctl/obsd_6.1sysctl_lenovot500_user.txt";
+ # $file = "$fake_data_dir/sysctl/obsd_6.1_sysctl_soekris6501_root.txt";
+ # $file = "$fake_data_dir/sysctl/obsd_6.1sysctl_lenovot500_user.txt";
## matches: compaq: openbsd-dmesg.boot-1.txt
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sysctl/openbsd-5.6-sysctl-1.txt";
+ # $file = "$fake_data_dir/sysctl/openbsd-5.6-sysctl-1.txt";
## matches: toshiba: openbsd-5.6-dmesg.boot-1.txt
- # $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sysctl/openbsd-5.6-sysctl-2.txt";
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/sysctl/obsd-6.8-sysctl-a-battery-sensor-1.txt";
+ # $file = "$fake_data_dir/sysctl/openbsd-5.6-sysctl-2.txt";
+ $file = "$fake_data_dir/sysctl/obsd-6.8-sysctl-a-battery-sensor-1.txt";
@temp = reader($file);
}
foreach (@temp){
@@ -30621,13 +31452,13 @@ sub usb_grabber {
else {
my $file;
if ($fake{'usbdevs'}){
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/bsd-usbdevs-v-1.txt";
+ $file = "$fake_data_dir/lsusb/bsd-usbdevs-v-1.txt";
}
elsif ($fake{'usbconfig'}){
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/bsd-usbconfig-list-v-1.txt";
+ $file = "$fake_data_dir/lsusb/bsd-usbconfig-list-v-1.txt";
}
else {
- $file = "$ENV{'HOME'}/bin/scripts/inxi/data/lsusb/mdmarmer-lsusb.txt";
+ $file = "$fake_data_dir/lsusb/mdmarmer-lsusb.txt";
}
@data = main::reader($file,'strip');
}
@@ -31110,10 +31941,10 @@ sub get_wakeups {
# Also creates Short, Info, and System items
{
package OutputGenerator;
-
+my ($items,$subs);
sub generate {
eval $start if $b_log;
- my (%row,%checks);
+ my ($item,%checks);
main::set_ps_aux() if !$loaded{'ps-aux'};
main::set_sysctl_data() if $use{'sysctl'};
main::set_dboot_data() if $bsd_type && !$loaded{'dboot'};
@@ -31124,121 +31955,121 @@ sub generate {
main::log_data('dump','@ps_cmd',\@ps_cmd);
}
if ($show{'short'}){
- %row = short_output();
- assign_data(\%row);
+ $item = short_output();
+ assign_data($item);
}
else {
if ($show{'system'}){
- %row = system_item();
- assign_data(\%row);
+ $item = system_item();
+ assign_data($item);
}
if ($show{'machine'}){
DmidecodeData::set(\$checks{'dmi'}) if $use{'dmidecode'} && !$checks{'dmi'};
- %row = item_handler('Machine','machine');
- assign_data(\%row);
+ $item = item_handler('Machine','machine');
+ assign_data($item);
}
if ($show{'battery'}){
DmidecodeData::set(\$checks{'dmi'}) if $use{'dmidecode'} && !$checks{'dmi'};
- %row = item_handler('Battery','battery');
- if (%row || $show{'battery-forced'}){
- assign_data(\%row);
+ $item = item_handler('Battery','battery');
+ if ($item || $show{'battery-forced'}){
+ assign_data($item);
}
}
if ($show{'ram'}){
DmidecodeData::set(\$checks{'dmi'}) if $use{'dmidecode'} && !$checks{'dmi'};
- %row = item_handler('Memory','ram');
- assign_data(\%row);
+ $item = item_handler('Memory','ram');
+ assign_data($item);
}
if ($show{'slot'}){
DmidecodeData::set(\$checks{'dmi'}) if $use{'dmidecode'} && !$checks{'dmi'};
- %row = item_handler('PCI Slots','slot');
- assign_data(\%row);
+ $item = item_handler('PCI Slots','slot');
+ assign_data($item);
}
if ($show{'cpu'} || $show{'cpu-basic'}){
DeviceData::set(\$checks{'device'}) if %risc && !$checks{'device'};
DmidecodeData::set(\$checks{'dmi'}) if $use{'dmidecode'} && !$checks{'dmi'};
my $arg = ($show{'cpu-basic'}) ? 'basic' : 'full' ;
- %row = item_handler('CPU','cpu',$arg);
- assign_data(\%row);
+ $item = item_handler('CPU','cpu',$arg);
+ assign_data($item);
}
if ($show{'graphic'}){
UsbData::set(\$checks{'usb'}) if !$checks{'usb'};
DeviceData::set(\$checks{'device'}) if !$checks{'device'};
- %row = item_handler('Graphics','graphic');
- assign_data(\%row);
+ $item = item_handler('Graphics','graphic');
+ assign_data($item);
}
if ($show{'audio'}){
UsbData::set(\$checks{'usb'}) if !$checks{'usb'};
DeviceData::set(\$checks{'device'}) if !$checks{'device'};
- %row = item_handler('Audio','audio');
- assign_data(\%row);
+ $item = item_handler('Audio','audio');
+ assign_data($item);
}
if ($show{'network'}){
UsbData::set(\$checks{'usb'}) if !$checks{'usb'};
DeviceData::set(\$checks{'device'}) if !$checks{'device'};
IpData::set() if ($show{'ip'} || ($bsd_type && $show{'network-advanced'}));
- %row = item_handler('Network','network');
- assign_data(\%row);
+ $item = item_handler('Network','network');
+ assign_data($item);
}
if ($show{'bluetooth'}){
UsbData::set(\$checks{'usb'}) if !$checks{'usb'};
DeviceData::set(\$checks{'device'}) if !$checks{'device'};
- %row = item_handler('Bluetooth','bluetooth');
- assign_data(\%row);
+ $item = item_handler('Bluetooth','bluetooth');
+ assign_data($item);
}
if ($show{'logical'}){
- %row = item_handler('Logical','logical');
- assign_data(\%row);
+ $item = item_handler('Logical','logical');
+ assign_data($item);
}
if ($show{'raid'}){
DeviceData::set(\$checks{'device'}) if !$checks{'device'};
- %row = item_handler('RAID','raid');
- assign_data(\%row);
+ $item = item_handler('RAID','raid');
+ assign_data($item);
}
if ($show{'disk'} || $show{'disk-basic'} || $show{'disk-total'} || $show{'optical'}){
- %row = item_handler('Drives','disk');
- assign_data(\%row);
+ $item = item_handler('Drives','disk');
+ assign_data($item);
}
if ($show{'partition'} || $show{'partition-full'}){
- %row = item_handler('Partition','partition');
- assign_data(\%row);
+ $item = item_handler('Partition','partition');
+ assign_data($item);
}
if ($show{'swap'}){
- %row = item_handler('Swap','swap');
- assign_data(\%row);
+ $item = item_handler('Swap','swap');
+ assign_data($item);
}
if ($show{'unmounted'}){
- %row = item_handler('Unmounted','unmounted');
- assign_data(\%row);
+ $item = item_handler('Unmounted','unmounted');
+ assign_data($item);
}
if ($show{'usb'}){
UsbData::set(\$checks{'usb'}) if !$checks{'usb'};
- %row = item_handler('USB','usb');
- assign_data(\%row);
+ $item = item_handler('USB','usb');
+ assign_data($item);
}
if ($show{'sensor'}){
- %row = item_handler('Sensors','sensor');
- assign_data(\%row);
+ $item = item_handler('Sensors','sensor');
+ assign_data($item);
}
if ($show{'repo'}){
- %row = item_handler('Repos','repo');
- assign_data(\%row);
+ $item = item_handler('Repos','repo');
+ assign_data($item);
}
if ($show{'process'}){
- %row = item_handler('Processes','process');
- assign_data(\%row);
+ $item = item_handler('Processes','process');
+ assign_data($item);
}
if ($show{'weather'}){
- %row = item_handler('Weather','weather');
- assign_data(\%row);
+ $item = item_handler('Weather','weather');
+ assign_data($item);
}
if ($show{'info'}){
- %row = info_item();
- assign_data(\%row);
+ $item = info_item();
+ assign_data($item);
}
}
if ($output_type ne 'screen'){
- main::output_handler(\%rows);
+ main::output_handler($items);
}
eval $end if $b_log;
}
@@ -31249,20 +32080,20 @@ sub short_output {
my $kernel_os = ($bsd_type) ? 'OS' : 'Kernel';
my ($cpu_string,$speed,$speed_key,$type) = ('','','speed','');
my $memory = MemoryData::get('string');
- my @cpu = CpuItem::get('short');
- if (scalar @cpu > 1){
- $type = ($cpu[2]) ? " (-$cpu[2]-)" : '';
+ my $cpu = CpuItem::get('short');
+ if (ref $cpu eq 'ARRAY' && scalar @$cpu > 1){
+ $type = ($cpu->[2]) ? " (-$cpu->[2]-)" : '';
($speed,$speed_key) = ('','');
- if ($cpu[6]){
- $speed_key = "$cpu[3]/$cpu[5]";
- $speed = "$cpu[4]/$cpu[6] MHz";
+ if ($cpu->[6]){
+ $speed_key = "$cpu->[3]/$cpu->[5]";
+ $speed = "$cpu->[4]/$cpu->[6] MHz";
}
else {
- $speed_key = $cpu[3];
- $speed = "$cpu[4] MHz";
+ $speed_key = $cpu->[3];
+ $speed = "$cpu->[4] MHz";
}
- $cpu[1] ||= main::message('cpu-model-null');
- $cpu_string = $cpu[0] . ' ' . $cpu[1] . $type;
+ $cpu->[1] ||= main::message('cpu-model-null');
+ $cpu_string = $cpu->[0] . ' ' . $cpu->[1] . $type;
}
elsif ($bsd_type){
if ($alerts{'sysctl'}->{'action'}){
@@ -31277,21 +32108,21 @@ sub short_output {
}
}
$speed ||= 'N/A'; # totally unexpected situation, what happened?
- my @disk = DriveItem::get('short');
+ my $disk = DriveItem::get('short');
# print Dumper \@disk;
my $disk_string = 'N/A';
my ($size,$used) = ('','');
my ($size_holder,$used_holder);
- if (@disk){
- $size = ($disk[0]->{'logical-size'}) ? $disk[0]->{'logical-size'} : $disk[0]->{'size'};
+ if (ref $disk eq 'ARRAY' && @$disk){
+ $size = ($disk->[0]{'logical-size'}) ? $disk->[0]{'logical-size'} : $disk->[0]{'size'};
# must be > 0
if ($size && main::is_numeric($size)){
$size_holder = $size;
$size = main::get_size($size,'string');
}
- $used = $disk[0]->{'used'};
- if ($used && main::is_numeric($disk[0]->{'used'})){
- $used_holder = $disk[0]->{'used'};
+ $used = $disk->[0]{'used'};
+ if ($used && main::is_numeric($disk->[0]{'used'})){
+ $used_holder = $disk->[0]{'used'};
$used = main::get_size($used,'string');
}
# in some fringe cases size can be 0 so only assign 'N/A' if no percents etc
@@ -31314,23 +32145,22 @@ sub short_output {
if ($client{'version'}){
$client .= ' ' . $client{'version'};
}
- my @data = ({
- main::key($num++,0,0,'CPU') => $cpu_string,
- main::key($num++,0,0,$speed_key) => $speed,
- main::key($num++,0,0,$kernel_os) => join(' ', @{main::get_kernel_data()}),
- main::key($num++,0,0,'Up') => main::get_uptime(),
- main::key($num++,0,0,'Mem') => $memory,
- main::key($num++,0,0,'Storage') => $disk_string,
- # could make -1 for ps aux itself, -2 for ps aux and self
- main::key($num++,0,0,'Procs') => scalar @ps_aux,
- main::key($num++,0,0,$client_shell) => $client,
- main::key($num++,0,0,$self_name) => main::get_self_version(),
- },);
- my %row = (
- main::key($prefix,1,0,'SHORT') => [(@data),],
- );
- eval $end if $b_log;
- return %row;
+ my $data = [{
+ main::key($num++,0,0,'CPU') => $cpu_string,
+ main::key($num++,0,0,$speed_key) => $speed,
+ main::key($num++,0,0,$kernel_os) => join(' ', @{main::get_kernel_data()}),
+ main::key($num++,0,0,'Up') => main::get_uptime(),
+ main::key($num++,0,0,'Mem') => $memory,
+ main::key($num++,0,0,'Storage') => $disk_string,
+ # could make -1 for ps aux itself, -2 for ps aux and self
+ main::key($num++,0,0,'Procs') => scalar @ps_aux,
+ main::key($num++,0,0,$client_shell) => $client,
+ main::key($num++,0,0,$self_name) => main::get_self_version(),
+ },];
+ eval $end if $b_log;
+ return {
+ main::key($prefix,1,0,'SHORT') => $data,
+ };
}
sub info_item{
eval $start if $b_log;
@@ -31340,25 +32170,25 @@ sub info_item{
my $data_name = main::key($prefix++,1,0,'Info');
my ($b_gcc,$gcc,$index);
my ($gpu_ram,$parent,$percent,$total,$used) = (0,'','','','');
- my @gccs = main::get_gcc_data();
- if (@gccs){
- $gcc = shift @gccs;
- if ($extra > 1 && @gccs){
- $gcc_alt = join('/', @gccs);
+ my $gccs = main::get_gcc_data();
+ if (@$gccs){
+ $gcc = shift @$gccs;
+ if ($extra > 1 && @$gccs){
+ $gcc_alt = join('/', @$gccs);
}
$b_gcc = 1;
}
$gcc ||= 'N/A';
- my %data = (
+ my $data = {
$data_name => [{
main::key($num++,0,1,'Processes') => scalar @ps_aux,
main::key($num++,1,1,'Uptime') => main::get_uptime(),
},],
- );
- $index = scalar(@{$data{$data_name}}) - 1;
+ };
+ $index = scalar(@{$data->{$data_name}}) - 1;
if ($extra > 2){
my $wakeups = main::get_wakeups();
- $data{$data_name}->[$index]{main::key($num++,0,2,'wakeups')} = $wakeups if defined $wakeups;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'wakeups')} = $wakeups if defined $wakeups;
}
if (!$loaded{'memory'}){
my $memory = MemoryData::get('splits');
@@ -31372,36 +32202,36 @@ sub info_item{
$gpu_ram = main::get_size($gpu_ram,'string');
}
}
- $data{$data_name}->[$index]{main::key($num++,1,1,'Memory')} = $total;
- $data{$data_name}->[$index]{main::key($num++,0,2,'used')} = $used;
+ $data->{$data_name}[$index]{main::key($num++,1,1,'Memory')} = $total;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'used')} = $used;
}
if ($gpu_ram){
- $data{$data_name}->[$index]{main::key($num++,0,2,'gpu')} = $gpu_ram;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'gpu')} = $gpu_ram;
}
if ((!$b_display || $force{'display'}) || $extra > 0){
- my %init = main::get_init_data();
- my $init_type = ($init{'init-type'}) ? $init{'init-type'}: 'N/A';
- $data{$data_name}->[$index]{main::key($num++,1,1,'Init')} = $init_type;
+ my $init = main::get_init_data();
+ my $init_type = ($init->{'init-type'}) ? $init->{'init-type'}: 'N/A';
+ $data->{$data_name}[$index]{main::key($num++,1,1,'Init')} = $init_type;
if ($extra > 1){
- my $init_version = ($init{'init-version'}) ? $init{'init-version'}: 'N/A';
- $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $init_version;
+ my $init_version = ($init->{'init-version'}) ? $init->{'init-version'}: 'N/A';
+ $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $init_version;
}
- if ($init{'rc-type'}){
- $data{$data_name}->[$index]{main::key($num++,1,2,'rc')} = $init{'rc-type'};
- if ($init{'rc-version'}){
- $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $init{'rc-version'};
+ if ($init->{'rc-type'}){
+ $data->{$data_name}[$index]{main::key($num++,1,2,'rc')} = $init->{'rc-type'};
+ if ($init->{'rc-version'}){
+ $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $init->{'rc-version'};
}
}
- if ($init{'runlevel'}){
- $data{$data_name}->[$index]{main::key($num++,0,2,'runlevel')} = $init{'runlevel'};
+ if ($init->{'runlevel'}){
+ my $key = ($init->{'init-type'} && $init->{'init-type'} eq 'systemd') ? 'target' : 'runlevel';
+ $data->{$data_name}[$index]{main::key($num++,1,2,$key)} = $init->{'runlevel'};
}
if ($extra > 1){
- if ($init{'default'}){
- my $default = ($init{'init-type'} eq 'systemd' && $init{'default'} =~ /[^0-9]$/) ? 'target' : 'default';
- $data{$data_name}->[$index]{main::key($num++,0,2,$default)} = $init{'default'};
+ if ($init->{'default'}){
+ $data->{$data_name}[$index]{main::key($num++,0,3,'default')} = $init->{'default'};
}
if ($b_admin && (my $tool = ServiceData::get('tool',''))){
- $data{$data_name}->[$index]{main::key($num++,0,2,'tool')} = $tool;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'tool')} = $tool;
undef %service_tool;
}
}
@@ -31415,21 +32245,21 @@ sub info_item{
$b_clang = 1;
}
my $compiler = ($b_gcc || $b_clang) ? '': 'N/A';
- $data{$data_name}->[$index]{main::key($num++,1,1,'Compilers')} = $compiler;
+ $data->{$data_name}[$index]{main::key($num++,1,1,'Compilers')} = $compiler;
if ($b_gcc){
- $data{$data_name}->[$index]{main::key($num++,1,2,'gcc')} = $gcc;
+ $data->{$data_name}[$index]{main::key($num++,1,2,'gcc')} = $gcc;
if ($extra > 1 && $gcc_alt){
- $data{$data_name}->[$index]{main::key($num++,0,3,'alt')} = $gcc_alt;
+ $data->{$data_name}[$index]{main::key($num++,0,3,'alt')} = $gcc_alt;
}
}
if ($b_clang){
- $data{$data_name}->[$index]{main::key($num++,0,2,'clang')} = $clang_version;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'clang')} = $clang_version;
}
}
if ($extra > 0 && !$loaded{'package-data'}){
- my %packages = PackageData::get('inner',\$num);
- for (keys %packages){
- $data{$data_name}->[$index]{$_} = $packages{$_};
+ my $packages = PackageData::get('inner',\$num);
+ for (keys %$packages){
+ $data->{$data_name}[$index]{$_} = $packages->{$_};
}
}
if (!$loaded{'shell-data'} && $ppid && (!$b_irc || !$client{'name-print'})){
@@ -31465,22 +32295,22 @@ sub info_item{
$client .= " ($client{'su-start'})";
}
}
- $data{$data_name}->[$index]{main::key($num++,1,1,$client_shell)} = $client;
+ $data->{$data_name}[$index]{main::key($num++,1,1,$client_shell)} = $client;
if ($extra > 0 && $client{'version'}){
- $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $client{'version'};
+ $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $client{'version'};
}
if (!$b_irc){
if ($extra > 2 && $client{'default-shell'}){
- $data{$data_name}->[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'};
- $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'};
+ $data->{$data_name}[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'};
+ $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'};
}
if ($running_in){
- $data{$data_name}->[$index]{main::key($num++,0,2,'running-in')} = $running_in;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'running-in')} = $running_in;
}
}
- $data{$data_name}->[$index]{main::key($num++,0,1,$self_name)} = main::get_self_version();
+ $data->{$data_name}[$index]{main::key($num++,0,1,$self_name)} = main::get_self_version();
eval $end if $b_log;
- return %data;
+ return $data;
}
sub system_item {
eval $start if $b_log;
@@ -31489,27 +32319,27 @@ sub system_item {
my $data_name = main::key($prefix++,1,0,'System');
my ($desktop,$desktop_info,$desktop_key,$dm_key,$toolkit,$wm) = ('','','Desktop','dm','','');
my (@desktop_data,$desktop_version,$tk_version,$wm_version);
- my %data = (
+ my $data = {
$data_name => [{}],
- );
- $index = scalar(@{$data{$data_name}}) - 1;
+ };
+ $index = scalar(@{$data->{$data_name}}) - 1;
if ($show{'host'}){
- $data{$data_name}->[$index]{main::key($num++,0,1,'Host')} = main::get_hostname();
+ $data->{$data_name}[$index]{main::key($num++,0,1,'Host')} = main::get_hostname();
}
my $kernel_data = main::get_kernel_data();
- $data{$data_name}->[$index]{main::key($num++,1,1,'Kernel')} = $kernel_data->[0];
- $data{$data_name}->[$index]{main::key($num++,0,2,'arch')} = $kernel_data->[1];
- $data{$data_name}->[$index]{main::key($num++,0,2,'bits')} = main::get_kernel_bits();
+ $data->{$data_name}[$index]{main::key($num++,1,1,'Kernel')} = $kernel_data->[0];
+ $data->{$data_name}[$index]{main::key($num++,0,2,'arch')} = $kernel_data->[1];
+ $data->{$data_name}[$index]{main::key($num++,0,2,'bits')} = main::get_kernel_bits();
if ($extra > 0){
- my @compiler = CompilerVersion::get(); # get compiler data
- if (scalar @compiler != 2){
- @compiler = ('N/A', '');
+ my $compiler = CompilerVersion::get(); # get compiler data
+ if (scalar @$compiler != 2){
+ @$compiler = ('N/A', '');
}
- $data{$data_name}->[$index]{main::key($num++,1,2,'compiler')} = $compiler[0];
+ $data->{$data_name}[$index]{main::key($num++,1,2,'compiler')} = $compiler->[0];
# if no compiler, obviously no version, so don't waste space showing.
- if ($compiler[0] ne 'N/A'){
- $compiler[1] ||= 'N/A';
- $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $compiler[1];
+ if ($compiler->[0] ne 'N/A'){
+ $compiler->[1] ||= 'N/A';
+ $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $compiler->[1];
}
}
if ($b_admin && (my $params = KernelParameters::get())){
@@ -31521,28 +32351,28 @@ sub system_item {
if ($use{'filter-uuid'}){
$params = main::filter_partition('system', $params, 'uuid');
}
- $data{$data_name}->[$index]{main::key($num++,0,2,'parameters')} = $params;
- $index = scalar(@{$data{$data_name}});
+ $data->{$data_name}[$index]{main::key($num++,0,2,'parameters')} = $params;
+ $index = scalar(@{$data->{$data_name}});
}
# note: tty can have the value of 0 but the two tools
# return '' if undefined, so we test for explicit ''
if ($b_display){
- my @desktop_data = DesktopEnvironment::get();
- $desktop = $desktop_data[0] if $desktop_data[0];
- $desktop_version = $desktop_data[1] if $desktop_data[1];
- if ($extra > 0 && $desktop_data[3]){
- $toolkit = $desktop_data[2];
- $tk_version = $desktop_data[3];
+ my $desktop_data = DesktopEnvironment::get();
+ $desktop = $desktop_data->[0] if $desktop_data->[0];
+ $desktop_version = $desktop_data->[1] if $desktop_data->[1];
+ if ($extra > 0 && $desktop_data->[3]){
+ $toolkit = $desktop_data->[2];
+ $tk_version = $desktop_data->[3];
}
- if ($extra > 2 && $desktop_data[4]){
- $desktop_info = $desktop_data[4];
+ if ($extra > 2 && $desktop_data->[4]){
+ $desktop_info = $desktop_data->[4];
}
# don't print the desktop if it's a wm and the same
- if ($extra > 1 && $desktop_data[5] &&
- (!$desktop_data[0] || $desktop_data[5] =~ /^(deepin.+|gnome[\s_-]shell|budgie.+)$/i ||
- index(lc($desktop_data[5]),lc($desktop_data[0])) == -1)){
- $wm = $desktop_data[5];
- $wm_version = $desktop_data[6] if $extra > 2 && $desktop_data[6];
+ if ($extra > 1 && $desktop_data->[5] &&
+ (!$desktop_data->[0] || $desktop_data->[5] =~ /^(deepin.+|gnome[\s_-]shell|budgie.+)$/i ||
+ index(lc($desktop_data->[5]),lc($desktop_data->[0])) == -1)){
+ $wm = $desktop_data->[5];
+ $wm_version = $desktop_data->[6] if $extra > 2 && $desktop_data->[6];
}
}
if (!$b_display || (!$desktop && $b_root)){
@@ -31572,53 +32402,53 @@ sub system_item {
$cont_desk = 0;
}
$desktop ||= 'N/A';
- $data{$data_name}->[$index]{main::key($num++,$cont_desk,1,$desktop_key)} = $desktop;
+ $data->{$data_name}[$index]{main::key($num++,$cont_desk,1,$desktop_key)} = $desktop;
if ($desktop_version){
- $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $desktop_version;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $desktop_version;
}
if ($toolkit){
- $data{$data_name}->[$index]{main::key($num++,1,2,'tk')} = $toolkit;
+ $data->{$data_name}[$index]{main::key($num++,1,2,'tk')} = $toolkit;
}
if ($tk_version){
- $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $tk_version;
+ $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $tk_version;
}
if ($extra > 2){
if ($desktop_info){
- $data{$data_name}->[$index]{main::key($num++,0,2,'info')} = $desktop_info;
+ $data->{$data_name}[$index]{main::key($num++,0,2,'info')} = $desktop_info;
}
}
if ($extra > 1){
if ($wm){
- $data{$data_name}->[$index]{main::key($num++,1,2,'wm')} = $wm;
+ $data->{$data_name}[$index]{main::key($num++,1,2,'wm')} = $wm;
if ($wm_version){
- $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $wm_version;
+ $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $wm_version;
}
}
if ($extra > 2 && $b_display && defined $ENV{'XDG_VTNR'}){
- $data{$data_name}->[$index]{main::key($num++,0,2,'vt')} = $ENV{'XDG_VTNR'};
+ $data->{$data_name}[$index]{main::key($num++,0,2,'vt')} = $ENV{'XDG_VTNR'};
}
my $dms = main::get_display_manager();
# note: version only present if proper extra level so no need to test again
- if ($dms || $desktop_key ne 'Console'){
- if ($dms && scalar @{$dms} > 1){
+ if (@$dms || $desktop_key ne 'Console'){
+ if (@$dms && scalar @$dms > 1){
my $i = 0;
- $data{$data_name}->[$index]{main::key($num++,1,$ind_dm,$dm_key)} = '';
+ $data->{$data_name}[$index]{main::key($num++,1,$ind_dm,$dm_key)} = '';
foreach my $dm_data (@{$dms}){
$i++;
- $data{$data_name}->[$index]{main::key($num++,1,($ind_dm + 1),$i)} = $dm_data->[0];
+ $data->{$data_name}[$index]{main::key($num++,1,($ind_dm + 1),$i)} = $dm_data->[0];
if ($dm_data->[1]){
- $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 2),'v')} = $dm_data->[1];
+ $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 2),'v')} = $dm_data->[1];
}
if ($dm_data->[2]){
- $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 2),'note')} = $dm_data->[2];
+ $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 2),'note')} = $dm_data->[2];
}
}
}
else {
my $dm = ($dms && $dms->[0][0]) ? $dms->[0][0] : 'N/A';
- $data{$data_name}->[$index]{main::key($num++,1,$ind_dm,$dm_key)} = $dm;
+ $data->{$data_name}[$index]{main::key($num++,1,$ind_dm,$dm_key)} = $dm;
if ($dms && $dms->[0][1]){
- $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 1),'v')} = $dms->[0][1];
+ $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 1),'v')} = $dms->[0][1];
}
}
@@ -31626,34 +32456,41 @@ sub system_item {
}
# if ($extra > 2 && $desktop_key ne 'Console'){
# my $tty = ShellData::tty_number() if !$loaded{'tty-number'};
- # $data{$data_name}->[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne '';
+ # $data->{$data_name}[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne '';
# }
my $distro_key = ($bsd_type) ? 'OS': 'Distro';
my @distro_data = DistroData::get();
my $distro = $distro_data[0];
$distro ||= 'N/A';
- $data{$data_name}->[$index]{main::key($num++,1,1,$distro_key)} = $distro;
+ $data->{$data_name}[$index]{main::key($num++,1,1,$distro_key)} = $distro;
if ($extra > 0 && $distro_data[1]){
- $data{$data_name}->[$index]{main::key($num++,0,2,'base')} = $distro_data[1];
+ $data->{$data_name}[$index]{main::key($num++,0,2,'base')} = $distro_data[1];
}
eval $end if $b_log;
- return %data;
+ return $data;
}
## Item Processors ##
sub assign_data {
- my ($row) = @_;
- return if ! %$row;
+ return if !$_[0] || ref $_[0] ne 'HASH';
if ($output_type eq 'screen'){
- main::print_data($row);
+ main::print_data($_[0]);
}
else {
- %rows = (%rows,%$row);
+ push(@$items,$_[0]);
}
}
sub item_handler {
eval $start if $b_log;
- my ($key,$sub,$arg) = @_;
- my %subs = (
+ my ($key,$item,$arg) = @_;
+ set_subs() if !$subs;
+ my $rows = $subs->{$item}($arg);
+ eval $end if $b_log;
+ if (ref $rows eq 'ARRAY' && @$rows){
+ return {main::key($prefix++,1,0,$key) => $rows};
+ }
+}
+sub set_subs {
+ $subs = {
'audio' => \&AudioItem::get,
'battery' => \&BatteryItem::get,
'bluetooth' => \&BluetoothItem::get,
@@ -31674,15 +32511,7 @@ sub item_handler {
'unmounted' => \&UnmountedItem::get,
'usb' => \&UsbItem::get,
'weather' => \&WeatherItem::get,
- );
- my (%data);
- my $data_name = main::key($prefix++,1,0,$key);
- my @rows = $subs{$sub}->($arg);
- if (@rows){
- %data = ($data_name => \@rows,);
- }
- eval $end if $b_log;
- return %data;
+ };
}
}
diff --git a/inxi.1 b/inxi.1
index bb01737..3a7e123 100644
--- a/inxi.1
+++ b/inxi.1
@@ -15,7 +15,7 @@
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
-.TH INXI 1 "2022\-05\-19" "inxi" "inxi manual"
+.TH INXI 1 "2022\-06\-13" "inxi" "inxi manual"
.SH NAME
inxi \- Command line system information script for console and IRC
@@ -31,9 +31,9 @@ inxi \- Command line system information script for console and IRC
[\fB\-v NUMBER\fR] [\fB\-W LOCATION\fR]
[\fB\-\-weather\-unit\fR {\fBm\fR|\fBi\fR|\fBmi\fR|\fBim\fR}] [\fB\-y WIDTH\fR]
-\fBinxi\fR [\fB\-\-edid\fR] [\fB\-\-memory\-modules\fR]
-[\fB\-\-memory\-short\fR] [\fB\-\-nvidia\fR] [\fB\-\-recommends\fR]
-[\fB\-\-sensors\-default\fR] [\fB\-\-slots\fR]
+\fBinxi\fR [\fB\-\-edid\fR] [\fB\-\-gpu\fR] [\fB\-\-memory\-modules\fR]
+[\fB\-\-memory\-short\fR] [\fB\-\-recommends\fR] [\fB\-\-sensors\-default\fR]
+[\fB\-\-slots\fR]
\fBinxi\fB [\fB\-x\fR|\fB\-xx\fR|\fB\-xxx\fR|\fB\-a\fR] \fB\-OPTION(s)\fR
@@ -311,6 +311,38 @@ show extra verbose options such as \fB\-d \-f \-i -J \-l \-m \-o \-p \-r \-t \-u
\fBinxi \-Frmxx\fR
.TP
+.B \-\-gpu\fR
+Show advanced gpu data. Triggers \fB\-G\fR and \fB\-a\fR as well. Expands
+existing \fBnon\-free:\fR driver (Linux and Nvidia only), and \fBarch:\fR
+reports (AMD/Intel/Nvidia). Useful to help diagnose driver support issues, shows
+extra data that can help diagnose/debug. Adds \fBcode:\fR item if found and not
+the same as \fBarch:\fR.
+.nf
+\fBinxi \-\-gpu \-y1
+Graphics:
+ Device\-1: NVIDIA NV34 [GeForce FX 5200]
+ driver: nouveau
+ v: kernel
+ non\-free:
+ series: 173.14.xx
+ status: legacy (EOL)
+ last:
+ kernel: 3.12
+ xorg: 1.15
+ release: 173.14.39
+ arch: Rankine
+ code: NV3x
+ process: 130\-150nm
+ built: 2003\-05
+ ports:
+ active: VGA\-1
+ empty: DVI\-I\-1,TV\-1
+ bus\-ID: 01:00.0
+ chip\-ID: 10de:0322
+ class\-ID: 0300
+.fi
+
+.TP
.B \-G \fR, \fB\-\-graphics\fR
Show Graphic device(s) information, including details of device and display
drivers (\fBX:\fR \fBloaded:\fR, and, if applicable: \fBunloaded:\fR,
@@ -354,7 +386,7 @@ Shows both IPv4 and IPv6 link IP addresses.
.B \-I \fR, \fB\-\-info\fR
Show Information: processes, uptime, memory, IRC client (or shell type if run
in shell, not IRC), inxi version. See \fB\-Ix\fR, \fB\-Ixx\fR, and \fB\-Ia\fR
-for extra information (init type/version, runlevel, packages).
+for extra information (init type/version, runlevel/target, packages).
Note: if \fB\-m\fR is used or triggered, the memory item will show in the main
Memory: report of \fB\-m\fR, not in \fB\Info:\fR.
@@ -570,33 +602,8 @@ shows Bus ID, Port number.
.TP
.B \-\-nvidia\fR, \fB\-\-nv\fR
-Show advanced non\-free Nvidia driver data. Triggers \fB\-G\fR and \fB\-a\fR as
-well. Expands existing \fBnon\-free:\fR driver report (Linux and Nvidia only).
-Also shows some basic information if not legacy driver. Useful to help diagnose
-driver support issues, shows extra data that can help diagnose/debug:
-.nf
-\fBinxi \-\-nvidia \-y1
-Graphics:
- Device\-1: NVIDIA NV34 [GeForce FX 5200]
- driver: nouveau
- v: kernel
- non\-free:
- series: 173.14.xx
- status: legacy (EOL)
- last:
- kernel: 3.12
- xorg: 1.15
- release: 173.14.39
- arch: Rankine
- code: NV3x
- process: 130\-150nm
- ports:
- active: VGA\-1
- empty: DVI\-I\-1,TV\-1
- bus\-ID: 01:00.0
- chip\-ID: 10de:0322
- class\-ID: 0300
-.fi
+.br
+See \fB\-\-gpu\fR.
.TP
.B \-o \fR, \fB\-\-unmounted\fR
@@ -785,7 +792,13 @@ See \fB\-J\fR.
.TP
.B \-V\fR, \fB\-\-version\fR
-inxi version information. Prints information then exits.
+inxi full version and license information. Prints information then exits.
+
+.TP
+.B \-\-version\-short\fR, \fB\-\-vs\fR
+inxi single line version information. Prints information if not short form
+(which shows version info already). Does not exit unless used without any other
+options. Can be used with normal line options.
.TP
.B \-v \fR, \fB\-\-verbosity\fR
@@ -839,10 +852,10 @@ of optical drives.
.TP
.B \-v 8
-\- All system data available. Adds Nvidia non\-free driver data
-(\fB\-\-nvidia\fR), advanced EDID data (\fB\-\-edid\fR), Repos (\fB\-r\fR), PCI
-slots (\fB\-\-slots\fR), processes (\fB\-tcm\fR), admin (\fB\-\-admin\fR).
-Useful for testing output and to see what data you can get from your system.
+\- All system data available. Adds extra gpu data (\fB\-\-gpu\fR), advanced EDID
+data (\fB\-\-edid\fR), Repos (\fB\-r\fR), PCI slots (\fB\-\-slots\fR), processes
+(\fB\-tcm\fR), admin (\fB\-\-admin\fR). Useful for testing output and to see
+what data you can get from your system.
.TP
.B \-w \fR, \fB\-\-weather\fR
@@ -1267,7 +1280,7 @@ for each HCI ID.
.TP
.B \-x \-G\fR
-\- Adds GPU micro\-architecture (if Nvidia and found).
+\- Adds GPU micro\-architecture (if AMD/Intel/Nvidia and detected).
\- Adds PCI/USB ID of each device.
@@ -1312,7 +1325,7 @@ With \fB\-xx\fR, shows init/rc version number, if available.
\- Adds default system gcc. With \fB\-xx\fR, also show other installed gcc
versions.
-\- Adds current runlevel (not available with all init systems).
+\- Adds current runlevel/target (not available with all init systems).
\- Adds total packages discovered in system. See \fB\-xx\fR and \fB\-a\fR
for per package manager types output. Moves to \fBRepos\fR if \fB\-rx\fR.
@@ -1545,8 +1558,8 @@ same. Example:
\- Adds other detected installed gcc versions (if present).
-\- Adds system default runlevel, if detected. Supports Systemd/Upstart/SysVinit
-type defaults.
+\- Adds system default runlevel/target, if detected. Supports Systemd / Upstart
+/SysVinit type defaults.
\- Shows \fBPackages:\fR counts by discovered package manager types. In cases
where only 1 type had results, does not show total after \fBPackages:\fR. Does
@@ -1824,6 +1837,11 @@ shown).
.TP
.B \-a \-C\fR
+.br
+\- Adds CPU generation, process node, and built years, if detected. For Intel,
+only will show if Core generation, otherwise the arch value is enough. For AMD,
+only shows Zen generation.
+
\- Adds CPU family, model\-id, and stepping (replaces \fBrev\fR of \fB\-Cx\fR).
Format is \fBhexadecimal (decimal)\fR if greater than 9, otherwise
\fBhexadecimal\fR.
@@ -1917,6 +1935,9 @@ differences shown, like \fBcores:, \fBmin/max:\fR, etc.
bits: 64
type: MT MCP MCM SMP
arch: Zen
+ gen: 1
+ process: GF 14nm
+ built: 2017\-19
family:0x17 (23)
model\-id:1
stepping: 2
@@ -1998,24 +2019,28 @@ non\-driver modules found, shows nothing. NOTE: just because it lists a module
does NOT mean it is available in the system, it's just something the kernel
knows could possibly be used instead.
-\- Adds (if Linux and Nvidia card) non\-free support information (if available).
-This can be useful for forum support people to determine if the card supports
-current active legacy Nvidia driver branches, or if the card nonfree driver is
-EOL or active. Note that if card is current, shows basic series and status.
+\- Adds (AMD/Intel/Nvidia, if available) \fBprocess: [node] built: [years]\fR
+to \fBarch:fR item.
+
+\- Adds (if Linux and Nvidia device) non\-free support information (if
+available). This can be useful for forum support people to determine if the card
+supports current active legacy Nvidia driver branches, or if the card nonfree
+driver is EOL or active. Note that if card is current, shows basic series and
+status.
.nf
\fBinxi \-GIaz
Graphics:
Device\-1: NVIDIA NV34 [GeForce FX 5200] driver: nouveau v: kernel
- non-free: 173.14.xx status: legacy (EOL, try \-\-nv) arch: Rankine
- ports: active: VGA-1 empty: DVI\-I\-1,TV\-1 bus\-ID: 01:00.0
- chip\-ID: 10de:0322 class\-ID: 0300
+ non-free: 173.14.xx status: legacy (EOL, try \-\-gpu) arch: Rankine
+ process: 130\-150nm built: 2003-05 ports: active: VGA-1
+ empty: DVI\-I\-1,TV\-1 bus\-ID: 01:00.0 chip\-ID: 10de:0322
+ class\-ID: 0300
Display: x11 server: X.Org v: 21.1.3 driver: X: loaded: nouveau
unloaded: fbdev,modesetting,vesa alternate: nv,nvidia gpu: nouveau
display\-ID: :0 screens: 1\fR
.fi
-For extended non free Nvidia legacy informatin, use
-\fB\-\-nvidia\fR/\fB\-\-nv\fR.
+For extended non free Nvidia legacy informatin, use \fB\-\-gpu\fR.
\- Adds PCIe generation, and, if different than running PCIe generation, speed
or lanes, \fBlink\-max: gen: speed: lanes:\fR (only items different from primary
@@ -2049,11 +2074,11 @@ Wayland sample, with Sway/swaymsg:
.nf
\fBinxi \aGz
Graphics:
- Device\-1: Advanced Micro Devices [AMD/ATI] Cedar [Radeon HD
- 5000/6000/7350/8350 Series] vendor: XFX Pine
- driver: radeon v: kernel pcie: gen: 2 speed: 5 GT/s lanes: 16 ports:
- active: DVI\-I\-1,VGA\-1 empty: HDMI\-A\-1 bus\-ID: 0a:00.0 chip\-ID: 1002:68f9
- class\-ID: 0300
+ Device\-1: AMD Cedar [Radeon HD 5000/6000/7350/8350 Series] vendor: XFX Pine
+ driver: radeon v: kernel alternate: amdgpu arch: TeraScale 2
+ process: TSMC 32\-40nm pcie: gen: 1 speed: 2.5 GT/s lanes: 16 link\-max:
+ gen: 2 speed: 5 GT/s ports: active: DVI\-I\-1,VGA\-1 empty: HDMI\-A\-1
+ bus\-ID: 0a:00.0 chip\-ID: 1002:68f9 class\-ID: 0300
Display: wayland server: Xwayland v: 21.1.4 compositor: sway v: 1.6.1
driver: gpu: radeon d\-rect: 2560x1024
Monitor-1: DVI\-I\-1 pos: right model: SyncMaster serial: <filter>
@@ -2076,9 +2101,10 @@ packages listed. Moves to \fBRepos\fR if \fB\-ra\fR.
\fBinxi \-aI
Info:
....
- Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 5/6/7/8/9
- Packages: apt: 3681 lib: 2096 rpm: 0 Shell: ksh v: A_2020.0.0 default: Bash
- v: 5.0.16 running\-in: kate inxi: 3.1.04\fR
+ Init: systemd v: 245 target: graphical.target (5) default: graphical.target
+ Compilers: gcc: 9.3.0 alt: 5/6/7/8/9 Packages: apt: 3681 lib: 2096 rpm: 0
+ Shell: ksh v: A_2020.0.0 default: Bash v: 5.0.16 running\-in: kate
+ inxi: 3.1.04\fR
.fi
\- Adds service control tool, tested for in the following order: \fBsystemctl
@@ -2515,6 +2541,11 @@ removes the debug data directory and the tar.gz file.
See \fB\-\-ftp\fR for uploading to alternate locations.
.TP
+.B \-\-fake\-data\-dir\fR
+Developer only: Change default location of $fake_data_dir, which is where files
+are for \fB\-\-fake {item}\fR items.
+
+.TP
.B \-\-ftp [ftp.yoursite.com/incoming]\fR
For alternate ftp upload locations: Example:
@@ -2755,6 +2786,13 @@ X/Wayland).
\fBVIRT_TERM_COLOR_SCHEME\fR Color scheme for virtual terminal output (in
X/Wayland).
+.TP
+.B Developer Options
+These are useful only for developers.
+
+\fBFAKE_DATA_DIR\fR \- change default fake data directory location. See
+\fB\-\-fake\-data\-dir\fR.
+
.SH BUGS
Please report bugs using the following resources.
diff --git a/inxi.changelog b/inxi.changelog
index 534d820..a33b528 100644
--- a/inxi.changelog
+++ b/inxi.changelog
@@ -1,4 +1,340 @@
================================================================================
+Version: 3.3.18
+Patch: 00
+Date: 2022-06-13
+--------------------------------------------------------------------------------
+RELEASE NOTES:
+--------------------------------------------------------------------------------
+
+Bug release, replace 3.3.17 asap, most users will not experience the bug, but if
+they do, inxi stops right before the -D line. Failed to do an if defined test on
+an array ref that could be undefined or an array ref. That makes Perl very
+unhappy!
+
+--------------------------------------------------------------------------------
+KNOWN ISSUES:
+
+1. AMD family F, K8 series, will need more granular treatments to get the data
+to be more accurate and less generic. We got 2 IDs nailed from raw visual data
+confirmations and cpuid values, which leaves many, but good start. We will chip
+away (pardon the pun) at these more ambiguous IDs over time, but don't need to
+get them all done instantly, just eventually. Thanks slackware person linuxdaddy
+for doing really good research and actually looking at the cpu to find dates
+etc.
+
+--------------------------------------------------------------------------------
+BUGS:
+
+1. Bug, fatal, caused by internal hash/array ref refactor of 3.3.17. Thanks
+alaymari github issue #271 for reporting this one.
+
+--------------------------------------------------------------------------------
+FIXES:
+
+1. None except for code fixes to try to avoid the cause of the bug in Bugs 1.
+
+2. Fixed nvidia eol try --gpu, it was showing backwards, with --gpu, not
+without, sigh.
+
+--------------------------------------------------------------------------------
+ENHANCEMENTS:
+
+1. Added slimski dm data. That's a new fork of SLiM. Also guessing that brzdm
+has same version -v output: brzdm version x.xx
+
+--------------------------------------------------------------------------------
+CHANGES:
+
+1. None
+
+--------------------------------------------------------------------------------
+DOCUMENTATION:
+
+1. Refactors of core docs, ongoing, but will list those next release.
+
+--------------------------------------------------------------------------------
+CODE:
+
+1. Cleaned up some array ref handling in subs, returned as: ($var1,$var2) =
+@{block_data(...)}, skipped initializing and creating scalar to hold the ref,
+just use it directly for DiskItem::block_data().
+
+2. Also switched to local ref scalar array in DiskItem::scsi_data(),
+DiskItem::block_data(). Not set local array, set local array ref, to keep it
+clear. Also made DriveItem::drive_speed() return straight ref, not array then
+ref. Same for many other subs, switched to ref assignment so it's the same ref
+all through all the sub and return.
+
+3. Fixed a redundant return \@$data to simply assigning to @$data ref, no return
+needed, in DiskItem::smartctl_data().
+
+4. Tightened some returns of ref so that tests if good test @$ref, not $ref.
+Trying to avoid more cases like issue #271.
+
+5. Going along with array ref local/return, switched all hash refs to local hash
+ref returning ref, and working local with ref. More efficient, avoids creating
+new refs over and over, dugh. This made a particularly large difference in CPU
+because in certain parts, new references were being created over and over, and
+subs were returning like \@arr or \%hash instead of declaring to start:
+my $arr = []; my $hash = {};
+
+Then working with the data from there on as an array or hash reference, to the
+same original reference, rather than creating new ones over and over, which Perl
+then has to track til they expire.
+
+--------------------------------------------------------------------------------
+-- Harald Hope - Mon, 13 Jun 2022 11:22:20 -0700
+
+================================================================================
+Version: 3.3.17
+Patch: 01
+Date: 2022-06-10
+--------------------------------------------------------------------------------
+RELEASE NOTES:
+--------------------------------------------------------------------------------
+
+Rollout of advanced microarchitecture info continues, added AMD/Intel gfx
+devices, CPU built dates, process nodes, generation (in some cases, where it
+makes sense), etc.
+
+Please note: the 3.3.16 > 17 releases require manual matching table updates. If
+you think disk or ram vendor, CPU or GPU process, release date, generation, etc,
+information is not correct:
+
+* FIRST: do the research, confirm it's wrong, using wikichips, techpowerup,
+wikipedia links, but also be aware, sometimes these slightly contradict each-
+other, so research. Don't make me do all your work for you.
+
+* Show the relevant data, like cpu model/stepping, to correct the issue, or
+model name string.
+
+* There are 4 main manually updated matching tables, which use either raw regex
+to generate the match based on the model name (ram, disk vendors), or vendor id
+matching (ram vendors), product id matching (gpu data), or cpu family / model /
+stepping id matching. Each of these has its own matching tool at:
+ inxi-perl/tools/[tool-name].pl
+which is used to generate either raw data used by the functions (ids for gpu
+data), or which contains the master copy of the function used to generate the
+regex matches (cp_cpu_arch/set_ram_vendors/set_disk_vendors).
+
+* Please use pinxi and inxi-perl branch for this data, inxi is only released
+when next stable is done, all development is done in inxi-perl branch. All
+development for the data or functions these tools are made for occurs in the
+tools, not in pinxi, and those results are moved into pinxi from the tools.
+
+* Saying something "doesn't work" is not helpful, provide the required data for
+the feature that needs updating, or ideally, find the correct answer yourself
+and do the research and then provide the updated data for matching.
+
+--------------------------------------------------------------------------------
+KNOWN ISSUES:
+
+1. GPU/CPU process node sizes are marketing, not engineering, terms, but
+work-around is to list the fab too so you at least know which set of marketing
+terms you're dealing with. As of around 7nm, most of the fabs are not using nm
+in their names anymore, TSMC is using n7, Intel 7, for example. While these
+marketing terms do reflect changes from the previous process node, more
+efficient, faster, faster per watt, and so on, and these changes are often quite
+significant, 10-30%, or more, they do not reflect the size of the transistor
+gate like they used to up until about 350nm. Intel will move to A20 for the node
+after 4 or 5, 2nm, meaning 20 angstroms.
+
+Intel suggested million transistors per mm^2 as an objective measure (currently
+around 300+ million!! as of ~7nm), but TSMC didn't take them up on it.
+
+GlobalFoundries (GF) stepped away from these ultra small processes at around
+14nm, so you won't see GF very often in the data. AMD spun off its chip fabs to
+GF aound 2009, so you don't see AMD as foundry after GF was formed. ATI always
+used TSMC so GPU data for AMD/ATI is I think all TSMC. Intel has always been its
+own foundry.
+
+2. Wayland drops all its data and can't be detected if sudo or su is used to run
+inxi. That's unfortunate, but goes along with their dropping support for > 1
+user, which was one of the points of wayland, same reason you can do desktop
+sharing or ssh desktop forwarding etc. This means inxi doesn't show wayland as
+Display protocol, it is just blank, if you use su, or sudo start. This makes
+some internal inxi wayland triggers then fail. Still looking to see if there is
+a fix or workaround for this.
+
+3. In sensors, a new syntax for k10-pci temp, Tctl, which unfortunately is the
+only temp type present for AMD family 17h (zen) and newer cpus, but that is not
+an actual cpu temp, it's:
+https://www.kernel.org/doc/html/v5.12/hwmon/k10temp.html
+
+"Tctl is the processor temperature control value, used by the platform to
+control cooling systems. Tctl is a non-physical temperature on an arbitrary
+scale measured in degrees. It does _not_ represent an actual physical
+temperature like die or case temperature."
+
+Even worse, it replaced Tdie, which was, correctly, temp1_input, and, somewhat
+insanely, the non real cpu temp is now temp1_input, and if present, the real
+Tdie cpu temp is temp2_input. I don't know how to work around this problem.
+
+--------------------------------------------------------------------------------
+BUGS:
+
+1. Fallback test for Intel cpu arch was not doing anything, used wrong variable
+name.
+
+2. A very old bug, thanks mrmazda for spotting this one, runlevel in case of
+init 3 > init 5 showed 35, not 5. Doesn't show on systemd stuff often since it
+doesn't use runlevels in this way, but this bug has been around a really long
+time.
+
+3. SensorItem::gpu_data was always logging its data, missing the if $b_log.
+
+--------------------------------------------------------------------------------
+FIXES:
+
+1. Fixed some disk vendor detection rules.
+
+2. Failing to return default target for systemd/systemctl when no:
+ /etc/systemd/system/default.target
+file exists. Corrected to use systemctl get-default as fallback if file doesn't
+exist.
+
+3. Fixed indentation for default: runlevel, should be child of runlevel: /
+target:
+
+4. Fixed corner case where systemd has no /proc/1/comm file but is still the
+init system. Added fallback check for /run/systemd/units, if that exists, safe
+to assume systemd is running init.
+
+5. Fixed subtle case, -h/--recommends/--version/--version-short should not print
+to -y1 width, but rather to the original or modified widths >= 80 cols.
+Corrected this in print_basic() by using max-cols-basic.
+
+6. Forgot to add --pkg, --edid, and --gpu to debugger run_self() tool.
+
+7. Fixed broken sandisk vendor id.
+
+--------------------------------------------------------------------------------
+ENHANCEMENTS:
+
+1. Added AMD and Intel GPU microarchitecture detections for -Gx. These are not
+as easy as Nvidia because there is no one reliable data source for product ids.
+
+2. Going with the -Ga process: .. built: item, -Ca will show process: [node] and
+built: years and sometimes gen: if available. Geeky, sure, not always perfect,
+or correct, but will generally be close. Due to difficultly in finding reliable
+release > build end years for example, not all cpus have all this data.
+
+Using CPU generation,where that data is available and makes sense. Like AMD
+Zen+ is zen gen: 2, for example,. Because Intel microarch names are often
+marketing driven, not engineering, it's too difficult to assign gen consistently
+based only on model names. Shows for Core intels like: gen: core 3
+
+That will cover most consumer Intel CPU users currently.
+
+3. Added initial Zen 3+ and Zen 4 ids for cp_cpu_arch(). There is very little
+info on these yet, so I'm going on what may prove to be incomplete or wrong
+data.
+
+4. Added GPU process, build years for -Ga.
+
+5. Added fallback test for gpus that we don't have product IDs for yet because
+dbs have not been updated. Only used for cases where it's the newest gpu series
+and no prodoct IDs have been found.
+
+6. Added AMD am386 support to cp_cpu_arch... ok ok, inxi takes 9 minutes to
+execute on that, but there you have it.
+
+7. Added unverified Hyprland wayland compositor detection.
+
+8. By request, added --version-short/--vs, which outputs version info in one
+line if used together with other options and if not short form. With any normal
+line option, will output version (date) info first line, without any other
+option, will output 1 line version info and exit.
+
+9. More disk vendors, ids! Much easier with new tool disk_vendors.pl.
+
+--------------------------------------------------------------------------------
+CHANGES:
+
+1. Deprecated --nvidia/--nv in favor of more consistent --gpu, that's easier to
+work with multiple vendors for advanced gpu architecture. Note for non nvidia,
+--gpu only adds codename, if available and different from arch name. For nvidia,
+it adds a lot more data.
+
+2. Changed inxi-perl/tools tool names to more clearly reflect what function they
+serve.
+
+3. Going with runlevel fixes, changed 'runlevel:' to be 'target:' if systemd.
+Also changed incorrect 'target:' for 'default:'.
+
+--------------------------------------------------------------------------------
+DOCUMENTATION:
+
+1. Updated man, help, docs/inxi-data.txt for new gpu data and tools, and to
+indicate switch to more generic --gpu trigger for advanced gpu data, instead of
+the now deprecated --nvidia/--nv, which probably will go down as the shortest
+lasting option documented, though of course inxi always keeps legacy syntax
+working, behind the scenes, it's just removed from the -h and man page in favor
+of --gpu. Also updated to show AMD/Intel/Nvidia now, since the data now roughly
+works for all three main gpus.
+
+2. Updated pinxi README.txt to reflect the tools and how to use them and what
+they are for.
+
+3. --help, man, updated for target/runlevel, default: changes for init data.
+
+4. Updated configuration html and man for --fake-data-dir.
+
+--------------------------------------------------------------------------------
+CODE:
+
+1. Upgraded tools/gpu_ids.pl to handle nvidia, intel, or amd data, added data
+files in tools/lists/ for amd. First changed name from ids.pl to gpu_ids.pl
+
+2. New data files added for amd/intel pci ids, and a new tool to merge them and
+prep them for gpu_ids.pl -j amd|intel handling. All work. Took a while to get
+these things sorted, but don't want to get stuck in future with manual updates,
+it needs to be automated as much as possible, same as with disk_vendors.pl etc,
+if I'm going to try to maintain this over time.
+
+3. Made all gpu data file names use consistent formats, and made disk data files
+also follow this format.
+
+4. Changed raw_ids.pl to gpu_raw.pl, trying to keep things easy to remember and
+consistent here.
+
+5. Refactored core gpu data logic, now all types use the same sub, and just
+assign various data depending on the type.
+
+6. Changed vendors.pl name to disk_vendors.pl
+
+7. Big redo of array/hash handling in OutputHandler, was partially by reference,
+now is completely by reference. All Items now use and return $rows array ref as
+well, from start to finish, unlike previously, where @rows was copied
+repeatedly.
+
+8. Going along with 7, made most internal passing of hash/arrays use hash/array
+references instead, where it makes sense, and doesn't make the code harder to
+work with.
+
+9. Refactored WeatherItem, split apart the parts from output to be more like
+normal Items in terms of error handling etc.
+
+10. Added 'ref' return option for reader() and grabber(). Only useful for very
+large data sets, added also default 'arr' if no value is provided for that
+argument.
+
+11. Switched some features to use grabber/reader by ref on the off chance that
+will dump some execution time.
+
+12. A few places added qr/.../ precompiled regex, in simple form, for loops,
+maybe it helps a little. I don't know.
+
+13. Added global $fake_data_dir, this can be changed via configuration item:
+FAKE_DATA_DIR or one time by --fake-data-dir.
+
+14. Created data directory, and initial data items. cpu is the fake data used to
+test CPU info. More will be added as data is checked and sanitized.
+
+--------------------------------------------------------------------------------
+-- Harald Hope - Fri, 10 June 2022 13:05:17 -0700
+
+================================================================================
Version: 3.3.16
Patch: 00
Date: 2022-05-19
@@ -83,7 +419,7 @@ Used non-existing $size{'output-block'} instead of correct $use{'output-block'}
they change internal light shells, but all the docs say they use ash, so now
it will show shell: ash (busybox) to make it clear. Hurray!! This means that
tinycore users will get this long awaited feature! Ok, ok, long awaited by
-probably only me, but since I package inxi for busybox, it was on my todo list.
+probably only me, but since I package inxi for TinyCore, it was on my todo list.
7. Cleaned up and re-organized many disk vendor matching rules, made them easier
to read and debug, going along with Code 3, vendors.pl development and release.
@@ -501,6 +837,9 @@ to not break on 1 character length string matches.
concept in terms of adding a new feature during the original inxi 2.9 rewrite,
and was never actually touched after that.
+5. Added option to reader() to return array ref, if expecting a large file can
+be useful.
+
--------------------------------------------------------------------------------
-- Harald Hope - Thu, 24 Mar 2022 12:01:50 -0800
@@ -3464,6 +3803,16 @@ replaced all of them with 'device[s]'.
4. Subtle fix, for debugger data collectors, added -y1 support, which can be
useful at times.
+5. Optimized PATH searches, now inxi only adds things to PATH if they exist in
+the system, not blindly.
+
+6. Added to path test /usr/X11R6/bin to defaults, that is needed, if present, by
+OpenBSD and maybe other BSDs for tools like glxinfo.
+
+7. Corrected missing PCI device data requires root message, that should have
+shown PCI device, not Device, since sometimes there is USB device data also
+next even if no permissions to read PCI device data tool, like in OpenBSD.
+
--------------------------------------------------------------------------------
ENHANCEMENTS: