diff --git a/inxi b/inxi index c48df72..0265d1b 100755 --- a/inxi +++ b/inxi @@ -40,8 +40,8 @@ use POSIX qw(uname strftime ttyname); ## INXI INFO ## my $self_name='inxi'; -my $self_version='3.2.00'; -my $self_date='2020-12-15'; +my $self_version='3.2.01'; +my $self_date='2020-12-17'; my $self_patch='00'; ## END INXI INFO ## @@ -738,9 +738,9 @@ sub set_color_scheme { '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]; + $colors{'c1'} = $color_palette{$scheme[0]}->[$index]; + $colors{'c2'} = $color_palette{$scheme[1]}->[$index]; + $colors{'cn'} = $color_palette{$scheme[2]}->[$index]; # print Dumper \@scheme; # print "$colors{'c1'}here$colors{'c2'} we are!$colors{'cn'}\n"; eval $end if $b_log; @@ -1351,7 +1351,7 @@ package SystemDebugger; my $option = 'main'; my ($data_dir,$debug_dir,$debug_gz,$parse_src,$upload) = ('','','','',''); -my @content = (); +my @content; my $b_debug = 0; my $b_delete_dir = 1; # args: 1 - type @@ -1739,7 +1739,7 @@ sub network_data { } sub perl_modules { print "Collecting Perl module data (this can take a while)...\n"; - my @modules = (); + my @modules; my ($dirname,$holder,$mods,$value) = ('','','',''); my $filename = 'perl-modules.txt'; my @inc; @@ -1894,7 +1894,7 @@ sub system_files { @files = RepoData::get($data_dir); copy_files(\@files, 'repo'); # chdir "/etc"; - @files = main::globber('/etc/*[-_]{[rR]elease,[vV]ersion,issue}*'); + @files = main::globber('/etc/*[-_s[rR]elease,[vV]ersion,issue}*'); push(@files, '/etc/issue'); push(@files, '/etc/lsb-release'); push(@files, '/etc/os-release'); @@ -2081,7 +2081,7 @@ sub directory_ls { elsif ( $depth == 5 ){ "ls -l $exclude /$dir/$include*/*/*/*/ 2>/dev/null" } elsif ( $depth == 6 ){ "ls -l $exclude /$dir/$include*/*/*/*/*/ 2>/dev/null" } }; - my @working = (); + my @working; my $output = ''; my ($type); my $result = qx($cmd); @@ -3217,8 +3217,6 @@ sub make_line { } } - - #### ------------------------------------------------------------------- #### TOOLS #### ------------------------------------------------------------------- @@ -4809,8 +4807,8 @@ sub show_options { it will display a short system summary." ], ['0', '', '', '' ], ['0', '', '', "You can use these options alone or together, - to show or add the item(s) you want to see: A, B, C, D, G, I, J, M, N, P, - R, S, W, d, f, i, j, l, L, m, n, o, p, r, s, t, u, w, --slots. + to show or add the item(s) you want to see: A, B, C, D, G, I, J, L, M, N, P, + R, S, W, d, f, i, j, l, m, n, o, p, r, s, t, u, w, --slots. If you use them with -v [level], -b or -F, $self_name will add the requested lines to the output." ], ['0', '', '', '' ], @@ -4845,8 +4843,6 @@ sub show_options { ['2', '-p,-P', '', "If available: raw size of ${partition_string}s, maj:min, percent available for user, block size of file system (root required)." ], ['2', '-r', '', "Packages, see -Ia." ], - ['2', '-L', '', "Show maj:min, component devices; per component/device: - size, maj:min." ], ['2', '-R', '', "mdraid: device maj:min; per component: size, maj:min, state." ], ['2', '-S', '', "If available: kernel boot parameters." ], ['1', '-A', '--audio', "Audio/sound card(s), driver, sound server." ], @@ -4889,7 +4885,7 @@ sub show_options { ['1', '-l', '--label', "$partition_string_u labels. Triggers -P. For full -p output, use -pl." ], ['1', '-L', '--logical', "Logical devices, LVM (VG, LV), - LUKS, Crypto, bcache, MultiPath. Shows compenents/devices, sizes, etc." ], + LUKS, Crypto, bcache, etc. Shows compenents/devices, sizes, etc." ], ['1', '-m', '--memory', "Memory (RAM) data. Requires root. Numbers of devices (slots) supported and individual memory devices (sticks of memory etc). For devices, shows device locator, size, speed, type (e.g. DDR3). @@ -6447,21 +6443,21 @@ sub card_data { },); if ($extra > 0 && $b_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){ - $rows[$j]{main::key($num++,0,2,'bus ID')} = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]"; + $rows[$j]->{main::key($num++,0,2,'bus ID')} = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]"; } if ($extra > 1){ my $chip_id = 'N/A'; @@ -6471,7 +6467,7 @@ sub card_data { elsif ($row->[6]){ $chip_id = $row->[6]; } - $rows[$j]{main::key($num++,0,2,'chip ID')} = $chip_id; + $rows[$j]->{main::key($num++,0,2,'chip ID')} = $chip_id; } #print "$row->[0]\n"; } @@ -6506,8 +6502,8 @@ sub asound_data { },); 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::row_defaults('pci-advanced-data',''); + $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version; + $rows[$j]->{main::key($num++,0,2,'message')} = main::row_defaults('pci-advanced-data',''); } } } @@ -6555,14 +6551,14 @@ sub usb_data { main::key($num++,0,2,'driver') => $driver, },); 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 && $row->[16]){ - $rows[$j]{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); + $rows[$j]->{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); } } } @@ -6726,7 +6722,7 @@ sub create_output { $volts = "$battery->{$key}{'voltage_now'}/$battery->{$key}{'voltage_min_design'}"; } $volts ||= 'N/A'; - $rows[$j]{main::key($num++,0,2,'volts')} = $volts; + $rows[$j]->{main::key($num++,0,2,'volts')} = $volts; } if ($battery->{$key}{'manufacturer'} || $battery->{$key}{'model_name'}) { if ($battery->{$key}{'manufacturer'} && $battery->{$key}{'model_name'}){ @@ -6742,23 +6738,23 @@ sub create_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::apply_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'}; } } } @@ -6804,13 +6800,13 @@ sub create_output { },); if ($extra > 1){ $serial = main::apply_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; + $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,'rechargeable')} = $upower_data{'rechargeable'}; } - $rows[$j]{main::key($num++,0,2,'status')} = $status; + $rows[$j]->{main::key($num++,0,2,'status')} = $status; } } eval $end if $b_log; @@ -6952,11 +6948,9 @@ sub battery_data_dmi { if ($row->[0] == 22){ $id = "BAT$i"; $i++; - $battery{$id} = ({}); $battery{$id}->{'purpose'} = 'primary'; # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; - foreach my $item (@$row){ + 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] } @@ -7087,52 +7081,52 @@ sub create_output_full { 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::row_defaults('note-check'); + $rows[$j]->{main::key($num++,1,2,'socket')} = $properties{'socket'} . ' (' . $properties{'upgrade'} . ')'; + $rows[$j]->{main::key($num++,0,3,'note')} = main::row_defaults('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 ($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 && defined $cpu{'stepping'} ){ - $rows[$j]{main::key($num++,0,2,'rev')} = $cpu{'stepping'}; + $rows[$j]->{main::key($num++,0,2,'rev')} = $cpu{'stepping'}; } } 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,'stepping')} = hex_and_decimal($cpu{'stepping'}); + $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,'stepping')} = hex_and_decimal($cpu{'stepping'}); if (!$b_arm && !$b_mips && !$b_ppc && $cpu{'type'} ne 'elbrus'){ $cpu{'microcode'} ||= 'N/A'; - $rows[$j]{main::key($num++,0,2,'microcode')} = $cpu{'microcode'}; + $rows[$j]->{main::key($num++,0,2,'microcode')} = $cpu{'microcode'}; } } if ($extra > 1 && $properties{'l1-cache'}){ - $rows[$j]{main::key($num++,0,2,'L1 cache')} = main::get_size($properties{'l1-cache'},'string'); + $rows[$j]->{main::key($num++,0,2,'L1 cache')} = main::get_size($properties{'l1-cache'},'string'); } if (!$b_arm || ($b_arm && $properties{'l2-cache'})){ $properties{'l2-cache'} = ($properties{'l2-cache'}) ? main::get_size($properties{'l2-cache'},'string') : 'N/A'; - $rows[$j]{main::key($num++,0,2,'L2 cache')} = $properties{'l2-cache'}; + $rows[$j]->{main::key($num++,0,2,'L2 cache')} = $properties{'l2-cache'}; } if ($extra > 1 && $properties{'l3-cache'}){ - $rows[$j]{main::key($num++,0,2,'L3 cache')} = main::get_size($properties{'l3-cache'},'string'); + $rows[$j]->{main::key($num++,0,2,'L3 cache')} = main::get_size($properties{'l3-cache'},'string'); } if ($extra > 0 && !$show{'cpu-flag'}){ $j = scalar @rows; @@ -7156,7 +7150,7 @@ sub create_output_full { } if ($extra > 0 && !$bsd_type){ my $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; } $j = scalar @rows; my $core_key = (scalar @speeds > 1) ? 'Core speeds (MHz)' : 'Core speed (MHz)'; @@ -7183,26 +7177,26 @@ sub create_output_full { main::key($num++,0,2,$min_max_key) => $min_max, }); 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 ($extra > 0){ my $boost = get_boost_status(); - $rows[$j]{main::key($num++,0,2,'boost')} = $boost if $boost; + $rows[$j]->{main::key($num++,0,2,'boost')} = $boost if $boost; } if ($extra > 2){ if ($properties{'volts'}){ - $rows[$j]{main::key($num++,0,2,'volts')} = $properties{'volts'} . ' V'; + $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 ($show{'cpu-flag'} && !$b_flags){ @@ -7236,8 +7230,8 @@ sub create_output_full { if (@bugs){ $j = $#rows; foreach my $bug (@bugs){ - $rows[$j]{main::key($num++,1,2,'Type')} = $bug->[0]; - $rows[$j]{main::key($num++,0,3,$bug->[1])} = $bug->[2]; + $rows[$j]->{main::key($num++,1,2,'Type')} = $bug->[0]; + $rows[$j]->{main::key($num++,0,3,$bug->[1])} = $bug->[2]; $j++; } } @@ -7257,14 +7251,14 @@ sub create_output_short { #main::key($num++,0,2,'type') => $cpu->[2], },); if ($extra > 0){ - $data[0]{main::key($num++,1,2,'arch')} = $cpu->[7]; + $data[0]->{main::key($num++,1,2,'arch')} = $cpu->[7]; if ($cpu->[8]){ - $data[0]{main::key($num++,0,3,'note')} = $cpu->[8]; + $data[0]->{main::key($num++,0,3,'note')} = $cpu->[8]; } } - $data[0]{main::key($num++,0,2,$cpu->[3])} = $cpu->[4]; + $data[0]->{main::key($num++,0,2,$cpu->[3])} = $cpu->[4]; if ($cpu->[6]){ - $data[0]{main::key($num++,0,2,$cpu->[5])} = $cpu->[6]; + $data[0]->{main::key($num++,0,2,$cpu->[5])} = $cpu->[6]; } eval $end if $b_log; return @data; @@ -7303,7 +7297,7 @@ sub data_short { } } } - # $cpu{'cur-freq'} = $cpu[0]{'core-id'}[0]{'speed'}; + # $cpu{'cur-freq'} = $cpu[0]->{'core-id'}[0]{'speed'}; if ($type eq 'short' || $type eq 'basic'){ @data = prep_short_data(\%cpu); } @@ -7390,10 +7384,6 @@ sub data_cpuinfo { my ($phys_holder) = (undef); # need to prime for arm cpus, which do not have physical/core ids usually # level 0 is phys id, level 1 is die id, level 2 is core id - #$ids[0] = ([(0)]); - $ids[0] = ([]); - $ids[0][0] = ([]); - # note, there con be a lot of processors, 32 core HT would have 64, for example. foreach (@cpuinfo){ next if /^\s*$/; @@ -7415,7 +7405,7 @@ sub data_cpuinfo { $cpu{'arch'} = $4; $cpu{'model_name'} .= ' ' . $cpu{'arch'} if $cpu{'model_name'} !~ /$cpu{'arch'}/i; } - $cpu{'processors'}[$proc_count] = 0; + $cpu{'processors'}->[$proc_count] = 0; $b_proc_int = 0; $b_first = 1; #print "p0:\n"; @@ -7426,13 +7416,13 @@ sub data_cpuinfo { if ($line[1] =~ /^\d+$/){ $b_proc_int = 1; $b_first = 1; - $cpu{'processors'}[$proc_count] = 0; + $cpu{'processors'}->[$proc_count] = 0; $proc_count++; #print "p1: $proc_count\n"; } else { if (!$b_proc_int){ - $cpu{'processors'}[$proc_count] = 0; + $cpu{'processors'}->[$proc_count] = 0; $proc_count++; #print "p2a: $proc_count\n"; } @@ -7490,7 +7480,7 @@ sub data_cpuinfo { $cpu{'arch'} = $4; $cpu{'model_name'} .= ' ' . $cpu{'arch'} if $cpu{'model_name'} !~ /$cpu{'arch'}/i; } - #$cpu{'processors'}[$proc_count] = 0; + #$cpu{'processors'}->[$proc_count] = 0; } } elsif ($b_mips || $line[1] =~ /mips/i){ @@ -7500,8 +7490,8 @@ sub data_cpuinfo { } elsif ( $line[0] eq 'cpu mhz' || $line[0] eq 'clock' ){ $speed = speed_cleaner($line[1]); - $cpu{'processors'}[$proc_count-1] = $speed; - #$ids[$phys_id][$die_id] = ([($speed)]); + $cpu{'processors'}->[$proc_count-1] = $speed; + #$ids[$phys_id]->[$die_id] = ([($speed)]); } elsif (!$cpu{'siblings'} && $line[0] eq 'siblings' ){ $cpu{'siblings'} = $line[1]; @@ -7516,8 +7506,6 @@ sub data_cpuinfo { # only increment if not in array counter push(@phys_cpus, $line[1]) if ! grep {/$line[1]/} @phys_cpus; $phys_holder = $line[1]; - $ids[$phys_holder] = ([]) if ! exists $ids[$phys_holder]; - $ids[$phys_holder][$die_id] = ([]) if ! exists $ids[$phys_holder][$die_id]; #print "pid: $line[1] ph: $phys_holder did: $die_id\n"; $die_id = 0; #$die_holder = 0; @@ -7539,7 +7527,7 @@ sub data_cpuinfo { $die_id++ if ($cpu{'type'} ne 'intel' && $cpu{'type'} ne 'amd' ); } $phys_holder = 0 if ! defined $phys_holder; - $ids[$phys_holder][$die_id][$line[1]] = $speed; + $ids[$phys_holder]->[$die_id][$line[1]] = $speed; #print "ph: $phys_holder did: $die_id l1: $line[1] s: $speed\n"; } if (!$cpu{'type'} && $line[0] eq 'vendor_id' ){ @@ -7635,7 +7623,7 @@ sub data_cpuinfo { #print "$cpu{'type'},$cpu{'family'},$cpu{'model_id'},$cpu{'arch'}\n"; } if (!$speeds{'cur-freq'}){ - $cpu{'cur-freq'} = $cpu{'processors'}[0]; + $cpu{'cur-freq'} = $cpu{'processors'}->[0]; $speeds{'min-freq'} = 0; $speeds{'max-freq'} = 0; } @@ -7744,10 +7732,10 @@ sub data_sysctl { my @temp = split(/\s+/, $line[1]); my $count = scalar @temp; $count-- if $count > 0; - $cpu{'processors'}[$count] = 0; + $cpu{'processors'}->[$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' ) { @@ -7762,7 +7750,7 @@ sub data_sysctl { $phys_id++; $phys_holder = $line[1]; $ids[$phys_id] = ([(0)]); - $ids[$phys_id][$die_id] = ([(0)]); + $ids[$phys_id]->[$die_id] = ([(0)]); } } elsif ( $line[0] eq 'hw.cpu_topology.cpu0.core_id' ){ @@ -7774,7 +7762,7 @@ sub data_sysctl { $die_id++ ; $die_holder = $line[1]; } - $ids[$phys_id][$die_id][$line[1]] = $speed; + $ids[$phys_id]->[$die_id][$line[1]] = $speed; $cpu{'dies'} = $die_id; } } @@ -7812,7 +7800,7 @@ sub cpu_properties { $b_elbrus = 1; } } - #my @dies = $phys[0][0]; + #my @dies = $phys[0]->[0]; my @phys = @{$cpu->{'ids'}}; my $phyical_count = 0; #my $phyical_count = scalar @phys; @@ -8089,9 +8077,8 @@ sub cpu_dmi_data { last if $item->[0] > 7; if ($item->[0] == 7){ # skip first three row, we don't need that data - splice @$item, 0, 3; ($id,$amount) = ('',0); - foreach my $value (@$item){ + foreach my $value (@$item[3 .. $#$item]){ next if $value =~ /~/; # variants: L3 - Cache; L3 Cache; L3-cache; CPU Internal L1 if ($value =~ /^Socket Designation:.* (L[1-3])\b/){ @@ -8116,9 +8103,8 @@ sub cpu_dmi_data { # Older dmidecode appear to have unreliable Upgrade outputs elsif ($item->[0] == 4){ # skip first three row, we don't need that data - splice @$item, 0, 3; ($socket,$upgrade) = (undef); - foreach my $value (@$item){ + foreach my $value (@$item[3 .. $#$item]){ next if $value =~ /~/; # note: on single cpu systems, Socket Designation shows socket type, # but on multi, shows like, CPU1; CPU Socket #2; Socket 0; so check values a bit. @@ -8909,32 +8895,32 @@ sub create_output { #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; if ($smartctl_missing){ $j = scalar @rows; - $rows[$j]{main::key($num++,0,1,'SMART Message')} = $smartctl_missing; + $rows[$j]->{main::key($num++,0,1,'SMART Message')} = $smartctl_missing; } if ($show{'disk'} && @$disks){ @$disks = sort { $a->{'id'} cmp $b->{'id'} } @$disks; @@ -8948,66 +8934,66 @@ sub create_output { $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'}; + $rows[$j]->{main::key($num++,0,1,'SMART Message')} = $row->{'smart-permissions'}; $j = scalar @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->{'rotation'}){ - $rows[$j]{main::key($num++,0,2,'rotation')} = $row->{'rotation'}; + $rows[$j]->{main::key($num++,0,2,'rotation')} = $row->{'rotation'}; } if ($extra > 1){ my $serial = main::apply_filter($row->{'serial'}); - $rows[$j]{main::key($num++,0,2,'serial')} = $serial; + $rows[$j]->{main::key($num++,0,2,'serial')} = $serial; if ($row->{'drive-serial'}){ - $rows[$j]{main::key($num++,0,2,'drive serial')} = main::apply_filter($row->{'drive-serial'}); + $rows[$j]->{main::key($num++,0,2,'drive serial')} = main::apply_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'; } # 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; @@ -9016,31 +9002,31 @@ sub create_output { if ($row->{$smart_basic[$i][0]}){ if (!$b_smart){ my $support = ($row->{'smart'}) ? $row->{'smart'}: $row->{'smart-error'}; - $rows[$j]{main::key($num++,1,2,$smart_basic[$i][1])} = $support; + $rows[$j]->{main::key($num++,1,2,$smart_basic[$i][1])} = $support; $b_smart = 1; next; } - $rows[$j]{main::key($num++,0,3,$smart_basic[$i][1])} = $row->{$smart_basic[$i][0]}; + $rows[$j]->{main::key($num++,0,3,$smart_basic[$i][1])} = $row->{$smart_basic[$i][0]}; } } ## Old-Age errors ## for (my $i = 0; $i < scalar @smart_age;$i++){ if ($row->{$smart_age[$i][0]}){ if (!$b_oldage){ - $rows[$j]{main::key($num++,1,3,'Old-Age')} = ''; + $rows[$j]->{main::key($num++,1,3,'Old-Age')} = ''; $b_oldage = 1; } - $rows[$j]{main::key($num++,0,4,$smart_age[$i][1])} = $row->{$smart_age[$i][0]}; + $rows[$j]->{main::key($num++,0,4,$smart_age[$i][1])} = $row->{$smart_age[$i][0]}; } } ## Pre-Fail errors ## for (my $i = 0; $i < scalar @smart_fail;$i++){ if ($row->{$smart_fail[$i][0]}){ if (!$b_prefail){ - $rows[$j]{main::key($num++,1,3,'Pre-Fail')} = ''; + $rows[$j]->{main::key($num++,1,3,'Pre-Fail')} = ''; $b_prefail = 1; } - $rows[$j]{main::key($num++,0,4,$smart_fail[$i][1])} = $row->{$smart_fail[$i][0]}; + $rows[$j]->{main::key($num++,0,4,$smart_fail[$i][1])} = $row->{$smart_fail[$i][0]}; } } } @@ -9334,28 +9320,27 @@ sub dmesg_boot_data { } # no dots, note: ada2: 2861588MB BUT: ada2: 600.000MB/s if (! exists $drives[$i]){ - $drives[$i] = ({}); - $drives[$i]{'id'} = $row[0]; - $drives[$i]{'firmware'} = ''; - $drives[$i]{'temp'} = ''; - $drives[$i]{'type'} = ''; - $drives[$i]{'vendor'} = ''; + $drives[$i]->{'id'} = $row[0]; + $drives[$i]->{'firmware'} = ''; + $drives[$i]->{'temp'} = ''; + $drives[$i]->{'type'} = ''; + $drives[$i]->{'vendor'} = ''; } #print "$i\n"; if ($bsd_type eq 'openbsd'){ if ($row[1] =~ /(^|,\s*)([0-9\.]+[MGTPE][B]?),.*\ssectors$|^{'size'} = $working; } if ($row[2] && $row[2] =~ /<([^>]+)>/){ - $drives[$i]{'model'} = $1 if $1; - $drives[$i]{'type'} = 'removable' if $_ =~ /removable$/; + $drives[$i]->{'model'} = $1 if $1; + $drives[$i]->{'type'} = 'removable' if $_ =~ /removable$/; # - my $count = ($drives[$i]{'model'} =~ tr/,//); + my $count = ($drives[$i]->{'model'} =~ tr/,//); if ($count && $count > 1){ - @temp = split(/,\s*/, $drives[$i]{'model'}); - $drives[$i]{'model'} = $temp[1]; + @temp = split(/,\s*/, $drives[$i]->{'model'}); + $drives[$i]->{'model'} = $temp[1]; } } # print "openbsd\n"; @@ -9364,26 +9349,26 @@ sub dmesg_boot_data { if ($row[1] =~ /^([0-9]+[KMGTPE][B]?)\s/){ $working = main::translate_size($1); $size += $working if $working; - $drives[$i]{'size'} = $working; + $drives[$i]->{'size'} = $working; } if ($row[1] =~ /device$|^]*)>\s(.*)/; - $drives[$i]{'model'} = $1 if $1; - $drives[$i]{'spec'} = $2 if $2; + $drives[$i]->{'model'} = $1 if $1; + $drives[$i]->{'spec'} = $2 if $2; } if ($row[1] =~ /^Serial\sNumber\s(.*)/){ - $drives[$i]{'serial'} = $1; + $drives[$i]->{'serial'} = $1; } if ($row[1] =~ /^([0-9\.]+[MG][B]?\/s)/){ - $drives[$i]{'speed'} = $1; - $drives[$i]{'speed'} =~ s/\.[0-9]+// if $drives[$i]{'speed'}; + $drives[$i]->{'speed'} = $1; + $drives[$i]->{'speed'} =~ s/\.[0-9]+// if $drives[$i]->{'speed'}; } } - $drives[$i]{'model'} = main::disk_cleaner($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]; + $drives[$i]->{'model'} = main::disk_cleaner($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]; } if (!$size){ $size = main::row_defaults('data-bsd'); @@ -9911,7 +9896,7 @@ sub disk_data_by_id { foreach (@by_id){ if ($device eq Cwd::abs_path($_)){ my @data = split('_', $_); - my @device_data = (); + my @device_data; last if scalar @data < 2; # scsi-3600508e000000000876995df43efa500 $serial = pop @data if @data; # usb-PNY_USB_3.0_FD_3715202280-0:0 @@ -10587,23 +10572,23 @@ sub card_data { },); if ($extra > 0 && $b_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 ($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){ - $rows[$j]{main::key($num++,0,2,'bus ID')} = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]"; + $rows[$j]->{main::key($num++,0,2,'bus ID')} = (!$row->[2] && !$row->[3]) ? 'N/A' : "$row->[2].$row->[3]"; } if ($extra > 1){ - $rows[$j]{main::key($num++,0,2,'chip ID')} = ($row->[5]) ? "$row->[5]:$row->[6]" : $row->[6]; + $rows[$j]->{main::key($num++,0,2,'chip ID')} = ($row->[5]) ? "$row->[5]:$row->[6]" : $row->[6]; } #print "$row->[0]\n"; } @@ -10641,14 +10626,14 @@ sub usb_data { main::key($num++,0,2,'driver') => $driver, },); 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 && $row->[16]){ - $rows[$j]{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); + $rows[$j]->{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); } } } @@ -10715,9 +10700,9 @@ sub display_data(){ main::key($num++,0,2,'server') => $server_string, }); if ($graphics{'compositor'}){ - $row[0]{main::key($num++,0,2,'compositor')} = $graphics{'compositor'}; + $row[0]->{main::key($num++,0,2,'compositor')} = $graphics{'compositor'}; if ($graphics{'compositor-version'}){ - $row[0]{main::key($num++,0,3,'v')} = $graphics{'compositor-version'}; + $row[0]->{main::key($num++,0,3,'v')} = $graphics{'compositor-version'}; } } # note: if no xorg log, and if wayland, there will be no xorg drivers, @@ -10744,34 +10729,34 @@ sub display_data(){ $driver = $drivers[0]; } $driver ||= 'N/A'; - $row[0]{main::key($num++,0,2,'driver')} = $driver; + $row[0]->{main::key($num++,0,2,'driver')} = $driver; if ($driver_missing){ - $row[0]{main::key($num++,0,3,'note')} = $driver_missing; + $row[0]->{main::key($num++,0,3,'note')} = $driver_missing; } if ($drivers[2]){ - $row[0]{main::key($num++,0,3,'FAILED')} = $drivers[2]; + $row[0]->{main::key($num++,0,3,'FAILED')} = $drivers[2]; } if ($drivers[1]){ - $row[0]{main::key($num++,0,3,'unloaded')} = $drivers[1]; + $row[0]->{main::key($num++,0,3,'unloaded')} = $drivers[1]; } if ($extra > 1 && $drivers[3]){ - $row[0]{main::key($num++,0,3,'alternate')} = $drivers[3]; + $row[0]->{main::key($num++,0,3,'alternate')} = $drivers[3]; } } if ($b_admin ){ if (defined $graphics{'display-id'}){ - $row[0]{main::key($num++,0,2,'display ID')} = $graphics{'display-id'}; + $row[0]->{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'}; + $row[0]->{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'}; + $row[0]->{main::key($num++,0,2,'default screen')} = $graphics{'display-default-screen'}; } } if ($graphics{'no-xdpyinfo'}){ - $row[0]{main::key($num++,0,2,'resolution')} = $graphics{'no-xdpyinfo'}; + $row[0]->{main::key($num++,0,2,'resolution')} = $graphics{'no-xdpyinfo'}; } elsif ($graphics{'screens'}){ my ($diag,$dpi,$hz,$size); @@ -10784,21 +10769,21 @@ sub display_data(){ $row_key++ if !$show{'graphic-basic'}; if ( !$show{'graphic-basic'} || $m_count == 0 ){ if ( !$show{'graphic-basic'} && defined $main->{'screen'} ){ - $row[$row_key]{main::key($num++,1,2,'Screen')} = $main->{'screen'}; + $row[$row_key]->{main::key($num++,1,2,'Screen')} = $main->{'screen'}; } $resolution = $main->{'res-x'} . 'x' . $main->{'res-y'} if $main->{'res-x'} && $main->{'res-y'}; $resolution .= '~' . $main->{'hz'} . 'Hz' if $show{'graphic-basic'} && $main->{'hz'} && $resolution; $resolution ||= 'N/A'; if ($s_count == 1 || !$show{'graphic-basic'}){ - $row[$row_key]{main::key($num++,0,3,'s-res')} = $resolution; + $row[$row_key]->{main::key($num++,0,3,'s-res')} = $resolution; } elsif ($show{'graphic-basic'}) { - $row[$row_key]{main::key($num++,0,3,'s-res')} = '' if $screen_count == 1; - $row[$row_key]{main::key($num++,0,3,$screen_count)} = $resolution; + $row[$row_key]->{main::key($num++,0,3,'s-res')} = '' if $screen_count == 1; + $row[$row_key]->{main::key($num++,0,3,$screen_count)} = $resolution; } $resolution = ''; if ($main->{'s-dpi'} && (!$show{'graphic-basic'} || $extra > 1)){ - $row[$row_key]{main::key($num++,0,3,'s-dpi')} = $main->{'s-dpi'}; + $row[$row_key]->{main::key($num++,0,3,'s-dpi')} = $main->{'s-dpi'}; } if ( !$show{'graphic-basic'} ){ if ($main->{'size-x'} && $main->{'size-y'}){ @@ -10806,12 +10791,12 @@ sub display_data(){ 'mm ('. $main->{'size-x-i'} . 'x' . $main->{'size-y-i'} . '")'; } $size ||= ''; - $row[$row_key]{main::key($num++,0,3,'s-size')} = $size if $size; + $row[$row_key]->{main::key($num++,0,3,'s-size')} = $size if $size; if ($main->{'diagonal'}){ $diag = $main->{'diagonal-m'} . 'mm ('. $main->{'diagonal'} . '")'; } $diag ||= ''; - $row[$row_key]{main::key($num++,0,3,'s-diag')} = $diag if $diag; + $row[$row_key]->{main::key($num++,0,3,'s-diag')} = $diag if $diag; } } if ($main->{'monitors'}){ @@ -10828,47 +10813,47 @@ sub display_data(){ $resolution .= '~' . $monitor->{'hz'} . 'Hz' if $monitor->{'hz'} && $resolution; $resolution ||= 'N/A'; if ($basic_count == 1 && $m_count == 1){ - $row[$row_key]{main::key($num++,0,2,'resolution')} = $resolution; + $row[$row_key]->{main::key($num++,0,2,'resolution')} = $resolution; } else { - $row[$row_key]{main::key($num++,1,2,'resolution')} = '' if $basic_count == 1; - $row[$row_key]{main::key($num++,0,3,$basic_count)} = $resolution; + $row[$row_key]->{main::key($num++,1,2,'resolution')} = '' if $basic_count == 1; + $row[$row_key]->{main::key($num++,0,3,$basic_count)} = $resolution; } if ($m_count == $basic_count){ - $row[$row_key]{main::key($num++,0,2,'s-dpi')} = $dpi if $dpi; + $row[$row_key]->{main::key($num++,0,2,'s-dpi')} = $dpi if $dpi; } next; } $row_key++; - $row[$row_key]{main::key($num++,0,3,'Monitor')} = $monitor->{'monitor'}; + $row[$row_key]->{main::key($num++,0,3,'Monitor')} = $monitor->{'monitor'}; if ($monitor->{'res-x'} && $monitor->{'res-y'}){ $resolution = $monitor->{'res-x'} . 'x' . $monitor->{'res-y'}; } $resolution ||= 'N/A'; - $row[$row_key]{main::key($num++,0,4,'res')} = $resolution; + $row[$row_key]->{main::key($num++,0,4,'res')} = $resolution; $hz = ($monitor->{'hz'}) ? $monitor->{'hz'} : ''; - $row[$row_key]{main::key($num++,0,4,'hz')} = $hz if $hz; + $row[$row_key]->{main::key($num++,0,4,'hz')} = $hz if $hz; $dpi = ($monitor->{'dpi'}) ? $monitor->{'dpi'} : ''; - $row[$row_key]{main::key($num++,0,4,'dpi')} = $dpi if $dpi; + $row[$row_key]->{main::key($num++,0,4,'dpi')} = $dpi if $dpi; #print "$dpi :: $main->{'s-dpi'}\n"; if ($monitor->{'size-x'} && $monitor->{'size-y'}){ $size = $monitor->{'size-x'} . 'x' . $monitor->{'size-y'} . 'mm ('. $monitor->{'size-x-i'} . 'x' . $monitor->{'size-y-i'} . '")'; } $size ||= ''; - $row[$row_key]{main::key($num++,0,4,'size')} = $size if $size; + $row[$row_key]->{main::key($num++,0,4,'size')} = $size if $size; if ($monitor->{'diagonal'}){ $diag = $monitor->{'diagonal-m'} . 'mm ('. $monitor->{'diagonal'} . '")'; } $diag ||= ''; - $row[$row_key]{main::key($num++,0,4,'diag')} = $diag if $diag; + $row[$row_key]->{main::key($num++,0,4,'diag')} = $diag if $diag; } } } } else { $graphics{'tty'} ||= 'N/A'; - $row[0]{main::key($num++,0,2,'tty')} = $graphics{'tty'}; + $row[0]->{main::key($num++,0,2,'tty')} = $graphics{'tty'}; } } eval $end if $b_log; @@ -11015,7 +11000,7 @@ sub x_display_data { if ($working[1] =~ /\*/){ $working[1] =~ s/\*|\+//g; $working[1] = sprintf("%.0f",$working[1]); - $monitors[scalar @monitors - 1]{'hz'} = $working[1] if @monitors; + $monitors[scalar @monitors - 1]->{'hz'} = $working[1] if @monitors; ($diagonal,$dpi) = ('',''); # print Data::Dumper::Dumper \@monitors; } @@ -11029,7 +11014,7 @@ sub x_display_data { foreach my $screens (@xrandr_screens){ # print "d: " . Data::Dumper::Dumper $screens; if ($screens->[0]{'screen'} eq $main->{'screen'}){ - ${$graphics{'screens'}}[$i]{'monitors'} = $screens; + $graphics{'screens'}->[$i]{'monitors'} = $screens; last; } } @@ -11211,10 +11196,10 @@ sub gl_data(){ 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; + $row[0]->{main::key($num++,0,2,'compat-v')} = $compat_version; } if ($extra > 0){ - $row[0]{main::key($num++,0,2,'direct render')} = $direct_render; + $row[0]->{main::key($num++,0,2,'direct render')} = $direct_render; } } else { @@ -11539,13 +11524,13 @@ sub create_output_general { }); 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; create_components_output('general',\$j,\$num,\@rows,\@{$item->{'components'}},\$b_fake); } @@ -11569,30 +11554,30 @@ sub create_output_lvm { 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; 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'}; + $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; } create_components_output('lvm',\$j,\$num,\@rows,\@{$lvm_data->{$vg}{'lvs'}{$lv}{'components'}},\$b_raid); @@ -11613,8 +11598,8 @@ sub create_components_output { elsif ($type eq 'lvm'){ ($l1) = (3); } - my $status = (!@$components) ? 'N/A':'' ; - $$rows[$$j]{main::key($$num++,1,$l1,'Components')} = $status; + my $status = (!@$components) ? 'N/A': ''; + $$rows[$$j]->{main::key($$num++,1,$l1,'Components')} = $status; create_recursive_components($type,$j,$num,$rows,$components,0,'c','p'); } sub create_recursive_components { @@ -11640,13 +11625,13 @@ sub create_recursive_components { $id = $p . '-' . $l; $l++; } - $$rows[$$j]{main::key($$num++,1,$l2,$id)} = $component->[0][0]; + $$rows[$$j]->{main::key($$num++,1,$l2,$id)} = $component->[0][0]; if ($extra > 1){ if ($b_admin){ - $$rows[$$j]{main::key($$num++,0,$l3,'maj-min')} = $component->[0][1]; - $$rows[$$j]{main::key($$num++,0,$l3,'mapped')} = $component->[0][3] if $component->[0][3]; + $$rows[$$j]->{main::key($$num++,0,$l3,'maj-min')} = $component->[0][1]; + $$rows[$$j]->{main::key($$num++,0,$l3,'mapped')} = $component->[0][3] if $component->[0][3]; $size = main::get_size($component->[0][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 = 1; $i < scalar @$component; $i++){ @@ -11709,7 +11694,7 @@ sub general_data { } } main::log_data('dump','luks @general_data', \@general_data); - print Data::Dumper::Dumper \@general_data if $test[22]; + print Data::Dumper::Dumper \@general_data if $test[23]; eval $end if $b_log; return @general_data; } @@ -11903,21 +11888,24 @@ sub create_output { # foreach my $key (keys %data){ # print "$key: $data->{$key}\n"; # } - if (!$data->{'sys_vendor'} || ($data->{'board_vendor'} && - $data->{'sys_vendor'} eq $data->{'board_vendor'} && !$data->{'product_name'} && - !$data->{'product_version'} && !$data->{'product_serial'})){ + if (!$data->{'sys_vendor'} || + ($data->{'board_vendor'} && $data->{'sys_vendor'} eq $data->{'board_vendor'} && + !$data->{'product_name'} && !$data->{'product_version'} && !$data->{'product_serial'})){ $b_skip_system = 1; } + # The goal here is to not show laptop/mobile devices # found a case of battery existing but having nothing in it on desktop mobo # not all laptops show the first. /proc/acpi/battery is deprecated. elsif ( !glob('/proc/acpi/battery/*') && !glob('/sys/class/power_supply/*') ){ # ibm / ibm can be true; dell / quantum is false, so in other words, only do this # in case where the vendor is the same and the version is the same and not null, # otherwise the version information is going to be different in all cases I think - if ( ($data->{'sys_vendor'} && $data->{'sys_vendor'} eq $data->{'board_vendor'} ) && - ( ($data->{'product_version'} && $data->{'product_version'} eq $data->{'board_version'} ) || - (!$data->{'product_version'} && $data->{'product_name'} && $data->{'board_name'} && - $data->{'product_name'} eq $data->{'board_name'} ) ) ){ + if ( ($data->{'sys_vendor'} && $data->{'board_vendor'} && + $data->{'sys_vendor'} eq $data->{'board_vendor'}) && + (($data->{'product_version'} && $data->{'board_version'} && + $data->{'product_version'} eq $data->{'board_version'}) || + (!$data->{'product_version'} && $data->{'product_name'} && $data->{'board_name'} && + $data->{'product_name'} eq $data->{'board_name'})) ){ $b_skip_system = 1; } } @@ -11932,10 +11920,10 @@ sub create_output { $product_name = ($data->{'product_name'}) ? $data->{'product_name'}:'N/A'; $product_version = ($data->{'product_version'}) ? $data->{'product_version'}:'N/A'; $product_serial = main::apply_filter($data->{'product_serial'}); - $rows[$j]{main::key($num++,1,1,'System')} = $system_vendor; - $rows[$j]{main::key($num++,0,2,'product')} = $product_name; - $rows[$j]{main::key($num++,0,2,'v')} = $product_version; - $rows[$j]{main::key($num++,0,2,'serial')} = $product_serial; + $rows[$j]->{main::key($num++,1,1,'System')} = $system_vendor; + $rows[$j]->{main::key($num++,0,2,'product')} = $product_name; + $rows[$j]->{main::key($num++,0,2,'v')} = $product_version; + $rows[$j]->{main::key($num++,0,2,'serial')} = $product_serial; # no point in showing chassis if system isn't there, it's very unlikely that # would be correct if ($extra > 1){ @@ -11957,14 +11945,14 @@ sub create_output { $chassis_serial = main::apply_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 @@ -11992,23 +11980,23 @@ sub create_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++,0,2,'model')} = $mobo_model; + $rows[$j]->{main::key($num++,1,1,'Mobo')} = $mobo_vendor; + $rows[$j]->{main::key($num++,0,2,'model')} = $mobo_model; if ($mobo_version){ - $rows[$j]{main::key($num++,0,2,'v')} = $mobo_version; + $rows[$j]->{main::key($num++,0,2,'v')} = $mobo_version; } - $rows[$j]{main::key($num++,0,2,'serial')} = $mobo_serial; + $rows[$j]->{main::key($num++,0,2,'serial')} = $mobo_serial; if ($extra > 2 && $data->{'board_uuid'}){ - $rows[$j]{main::key($num++,0,2,'uuid')} = $data->{'board_uuid'}; + $rows[$j]->{main::key($num++,0,2,'uuid')} = $data->{'board_uuid'}; } - $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; @@ -12024,28 +12012,28 @@ sub create_output_soc { if ($b_arm){$key = 'ARM Device'} elsif ($b_mips){$key = 'MIPS Device'} elsif ($b_ppc){$key = 'PowerPC Device'} - $rows[$j]{main::key($num++,0,1,'Type')} = $key; + $rows[$j]->{main::key($num++,0,1,'Type')} = $key; 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'}; } # 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::apply_filter($soc_machine{'serial'}); + $rows[$j]->{main::key($num++,0,2,'serial')} = main::apply_filter($soc_machine{'serial'}); } eval $end if $b_log; return @rows; @@ -12061,7 +12049,7 @@ sub machine_data_sys { product_name product_serial product_uuid product_version sys_vendor ); if ($extra > 1){ - splice @sys_files, 0, 0, qw( chassis_serial chassis_vendor chassis_version); + splice(@sys_files, 0, 0, qw(chassis_serial chassis_vendor chassis_version)); } $data{'firmware'} = 'BIOS'; # print Data::Dumper::Dumper \@sys_files; @@ -12216,16 +12204,23 @@ sub machine_data_dmi { # bios/firmware if ($row->[0] == 0){ # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; - foreach my $item (@$row){ + foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Release Date') {$data{'bios_date'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Vendor') {$data{'bios_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') {$data{'bios_version'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'ROM Size') {$data{'bios_romsize'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'BIOS Revision') {$data{'bios_rev'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] =~ /^UEFI is supported/) {$data{'firmware'} = 'UEFI';} + if ($value[0] eq 'Release Date') { + $data{'bios_date'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Vendor') { + $data{'bios_vendor'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Version') { + $data{'bios_version'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'ROM Size') { + $data{'bios_romsize'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'BIOS Revision') { + $data{'bios_rev'} = main::dmi_cleaner($value[1]) } + } + else { + if ($item eq '~UEFI is supported') { + $data{'firmware'} = 'UEFI';} } } next; @@ -12233,15 +12228,19 @@ sub machine_data_dmi { # system information elsif ($row->[0] == 1){ # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; - foreach my $item (@$row){ + foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Product Name') {$data{'product_name'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') {$data{'product_version'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Serial Number') {$data{'product_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') {$data{'sys_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'UUID') {$data{'sys_uuid'} = main::dmi_cleaner($value[1]) } + if ($value[0] eq 'Product Name') { + $data{'product_name'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Version') { + $data{'product_version'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Serial Number') { + $data{'product_serial'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Manufacturer') { + $data{'sys_vendor'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'UUID') { + $data{'sys_uuid'} = main::dmi_cleaner($value[1]) } } } next; @@ -12249,13 +12248,17 @@ sub machine_data_dmi { # baseboard information elsif ($row->[0] == 2){ # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; - foreach my $item (@$row){ + foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Product Name') {$data{'board_name'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Serial Number') {$data{'board_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') {$data{'board_vendor'} = main::dmi_cleaner($value[1]) } + if ($value[0] eq 'Product Name') { + $data{'board_name'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Serial Number') { + $data{'board_serial'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Manufacturer') { + $data{'board_vendor'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Version') { + $data{'board_version'} = main::dmi_cleaner($value[1]) } } } next; @@ -12263,14 +12266,17 @@ sub machine_data_dmi { # chassis information elsif ($row->[0] == 3){ # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; - foreach my $item (@$row){ + foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Serial Number') {$data{'chassis_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Type') {$data{'chassis_type'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') {$data{'chassis_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') {$data{'chassis_version'} = main::dmi_cleaner($value[1]) } + if ($value[0] eq 'Serial Number') { + $data{'chassis_serial'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Type') { + $data{'chassis_type'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Manufacturer') { + $data{'chassis_vendor'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Version') { + $data{'chassis_version'} = main::dmi_cleaner($value[1]) } } } if ( $data{'chassis_type'} && $data{'chassis_type'} ne 'Other' ){ @@ -12282,7 +12288,6 @@ sub machine_data_dmi { # processor information: check for hypervisor elsif ($row->[0] == 4){ # skip first three row, we don't need that data - splice @$row, 0, 3 if @$row; if (!$data{'device'}){ if (grep {/hypervisor/i} @$row){ $data{'device'} = 'virtual-machine'; @@ -12302,6 +12307,7 @@ sub machine_data_dmi { # foreach (keys %data){ # print "$_: $data{$_}\n"; # } + #print Data::Dumper::Dumper \%data; main::log_data('dump','%data',\%data) if $b_log; my @rows = create_output(\%data); eval $end if $b_log; @@ -12557,12 +12563,12 @@ sub card_data { },); if ($extra > 0 && $b_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 @@ -12573,19 +12579,19 @@ sub card_data { 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'; # 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 ($show{'network-advanced'}){ my @data; @@ -12641,13 +12647,13 @@ sub usb_data { },); $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){ - $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 && $row->[16]){ - $rows[$j]{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); + $rows[$j]->{main::key($num++,0,2,'serial')} = main::apply_filter($row->[16]); } if ($show{'network-advanced'}){ my @data; @@ -12691,7 +12697,7 @@ sub advanced_data_sys { } @paths = grep {!/\/lo$/} @paths; if ( $count > 0 && $count < scalar @paths ){ - @paths = splice @paths, $count, scalar @paths; + @paths = splice(@paths, $count, scalar @paths); } if ($vendor eq 'check'){ $b_check = 1; @@ -12758,10 +12764,10 @@ 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,'speed')} = $speed; + $row[0]->{main::key($num++,0,$ind_if,'duplex')} = $duplex; } - $row[0]{main::key($num++,0,$ind_if,'mac')} = $mac; + $row[0]->{main::key($num++,0,$ind_if,'mac')} = $mac; if ($b_check){ push(@rows,@row); } @@ -12828,10 +12834,10 @@ sub advanced_data_bsd { 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,'speed')} = $speed; + $row[0]->{main::key($num++,0,$ind_if,'duplex')} = $duplex; } - $row[0]{main::key($num++,0,$ind_if,'mac')} = $mac; + $row[0]->{main::key($num++,0,$ind_if,'mac')} = $mac; } push(@rows, @row); if ($show{'ip'} && $if){ @@ -12923,7 +12929,7 @@ sub if_ip { } if ($extra > 1 && $data2->[2]){ $broadcast = main::apply_filter($data2->[2]); - $rows[$j]{main::key($num++,0,$ind_ip,'broadcast')} = $broadcast; + $rows[$j]->{main::key($num++,0,$ind_ip,'broadcast')} = $broadcast; } } } @@ -13136,13 +13142,13 @@ sub create_output { if ($extra > 0){ my $rev = $devices{$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 && $devices{$key}->{'serial'}){ - $rows[$j]{ main::key($num++,0,2,'serial')} = main::apply_filter($devices{$key}->{'serial'}); + $rows[$j]->{ main::key($num++,0,2,'serial')} = main::apply_filter($devices{$key}->{'serial'}); } my $links = (@{$devices{$key}->{'links'}}) ? join(',', sort @{$devices{$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; my $speed = $devices{$key}->{'speed'}; @@ -13185,7 +13191,7 @@ sub create_output { if ($extra > 0 ){ my $state = $devices{$key}->{'state'}; $state ||= 'N/A'; - $rows[$j]{ main::key($num++,0,3,'state')} = $state; + $rows[$j]->{ main::key($num++,0,3,'state')} = $state; } } } @@ -13455,42 +13461,42 @@ sub create_output { 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'}; } if ($show{'label'}){ $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, '') if $use{'filter-label'}; - $rows[$j]{main::key($num++,0,2,'label')} = ($row->{'label'}) ? $row->{'label'}: 'N/A'; + $rows[$j]->{main::key($num++,0,2,'label')} = ($row->{'label'}) ? $row->{'label'}: 'N/A'; } if ($show{'uuid'}){ $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, '') if $use{'filter-uuid'}; - $rows[$j]{main::key($num++,0,2,'uuid')} = ($row->{'uuid'}) ? $row->{'uuid'}: 'N/A'; + $rows[$j]->{main::key($num++,0,2,'uuid')} = ($row->{'uuid'}) ? $row->{'uuid'}: 'N/A'; } } eval $end if $b_log; @@ -14137,7 +14143,7 @@ sub cpu_processes { $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; + @rows = splice(@rows,0,$count); $j = scalar @rows; # $cpu_mem = ' - Memory: MiB / % used' if $extra > 0; @@ -14162,15 +14168,15 @@ sub cpu_processes { },); push(@processes,@data); if ($command[1]) { - $processes[$j]{main::key($num++,0,4,'started by')} = $command[1]; + $processes[$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; + $processes[$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; + $processes[$j]->{main::key($num++,0,3,'mem')} = $mem; } #print Data::Dumper::Dumper \@processes, "i: $i; j: $j "; } @@ -14194,7 +14200,7 @@ sub mem_processes { @rows = @ps_aux; $pid_col = 0 if $ps_cols == 2; } - @rows = splice @rows,0,$count; + @rows = splice(@rows,0,$count); #print Data::Dumper::Dumper \@rows; @processes = main::get_memory_data_full('process') if !$b_mem; $j = scalar @rows; @@ -14227,13 +14233,13 @@ sub mem_processes { },); push(@processes,@data); if ($command[1]) { - $processes[$j]{main::key($num++,0,4,'started by')} = $command[1]; + $processes[$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; + $processes[$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; + $processes[$j]->{main::key($num++,0,3,'cpu')} = $cpu; } #print Data::Dumper::Dumper \@processes, "i: $i; j: $j "; } @@ -14331,25 +14337,25 @@ sub create_output_hw { 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; + $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){ my $driver_version = ($row->{'driver-version'}) ? $row->{'driver-version'}: 'N/A' ; - $rows[$j]{main::key($num++,0,3,'v')} = $driver_version; + $rows[$j]->{main::key($num++,0,3,'v')} = $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 = (defined $row->{'vendor-id'} && defined $row->{'chip-id'}) ? "$row->{'vendor-id'}.$row->{'chip-id'}": 'N/A' ; - $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){ my $rev= (defined $row->{'rev'} && $row->{'rev'}) ? $row->{'rev'}: 'N/A' ; - $rows[$j]{main::key($num++,0,2,'rev')} = $rev; + $rows[$j]->{main::key($num++,0,2,'rev')} = $rev; } } eval $end if $b_log; @@ -14367,36 +14373,36 @@ sub create_output_lvm { 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; $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'}} : (); @components_good = (); @@ -14410,7 +14416,7 @@ sub create_output_lvm { } } $j = scalar @rows; - $rows[$j]{main::key($num++,1,2,'Components')} = ''; + $rows[$j]->{main::key($num++,1,2,'Components')} = ''; my $b_bump; create_components_output('lvm','Online',\@rows,\@components_good,\$j,\$num,\$b_bump); create_components_output('lvm','Meta',\@rows,\@components_meta,\$j,\$num,\$b_bump); @@ -14439,13 +14445,13 @@ sub create_output_md { 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'); @@ -14453,33 +14459,33 @@ sub create_output_md { else { $size = (!$b_root && !@lsblk) ? main::row_defaults('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; $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'}; } } } @@ -14500,7 +14506,7 @@ sub create_output_md { } } $j = scalar @rows; - $rows[$j]{main::key($num++,1,2,'Components')} = ''; + $rows[$j]->{main::key($num++,1,2,'Components')} = ''; my $b_bump; create_components_output('mdraid','Online',\@rows,\@components_good,\$j,\$num,\$b_bump); create_components_output('mdraid','FAILED',\@rows,\@failed,\$j,\$num,\$b_bump); @@ -14512,16 +14518,16 @@ sub create_output_md { 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'}; } } } @@ -14555,23 +14561,23 @@ sub create_output_zfs { @arrays = @{$row->{'arrays'}}; @arrays = grep {defined $_} @arrays; @arrays_holder = @arrays; - if (!defined $arrays[0]{'level'} ){ + if (!defined $arrays[0]->{'level'} ){ $level = 'no-raid'; - $rows[$j]{main::key($num++,0,2,'level')} = $level; + $rows[$j]->{main::key($num++,0,2,'level')} = $level; } if ($size){ #print "here 0\n"; - $rows[$j]{main::key($num++,0,2,'size')} = $size; + $rows[$j]->{main::key($num++,0,2,'size')} = $size; $size = ''; $b_row_1_sizes = 1; } if ($available){ - $rows[$j]{main::key($num++,0,2,'free')} = $available; + $rows[$j]->{main::key($num++,0,2,'free')} = $available; $available = ''; $b_row_1_sizes = 1; } if ($allocated){ - $rows[$j]{main::key($num++,0,2,'allocated')} = $allocated; + $rows[$j]->{main::key($num++,0,2,'allocated')} = $allocated; $allocated = ''; } my $count = scalar @arrays; @@ -14595,12 +14601,12 @@ sub create_output_zfs { #print "here $count\n"; $size = ($row2->{'size'}) ? main::get_size($row2->{'size'},'string') : 'N/A'; $available = ($row2->{'free'}) ? main::get_size($row2->{'free'},'string') : 'N/A'; - $rows[$j]{main::key($num++,0,2,'size')} = $size; - $rows[$j]{main::key($num++,0,2,'free')} = $available; + $rows[$j]->{main::key($num++,0,2,'size')} = $size; + $rows[$j]->{main::key($num++,0,2,'free')} = $available; if ($extra > 2){ $allocated = ($row->{'allocated'}) ? main::get_size($row2->{'allocated'},'string') : ''; if ($allocated){ - $rows[$j]{main::key($num++,0,2,'allocated')} = $allocated; + $rows[$j]->{main::key($num++,0,2,'allocated')} = $allocated; } } } @@ -14623,7 +14629,7 @@ sub create_output_zfs { } } $j = scalar @rows; - $rows[$j]{main::key($num++,1,3,'Components')} = ''; + $rows[$j]->{main::key($num++,1,3,'Components')} = ''; my $b_bump; create_components_output('zfs','Online',\@rows,\@components_good,\$j,\$num,\$b_bump); create_components_output('zfs','FAILED',\@rows,\@failed,\$j,\$num,\$b_bump); @@ -14658,7 +14664,7 @@ sub create_components_output { $$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; + $$rows_ref[$$j_ref]->{main::key($$num_ref++,1,$l1,$item)} = $good; foreach my $device (@$array_ref){ next if ref $device ne 'ARRAY'; if ($b_admin && $device->[$f1] && $device->[$f2]){ @@ -14667,22 +14673,22 @@ sub create_components_output { $$num_ref = 1; } $key1 = (defined $k1) ? $device->[$k1] : $k++; - $$rows_ref[$$j_ref]{main::key($$num_ref++,1,$l2,$key1)} = $device->[0]; + $$rows_ref[$$j_ref]->{main::key($$num_ref++,1,$l2,$key1)} = $device->[0]; if ($b_admin && $device->[$f2]){ $$rows_ref[$$j_ref]{main::key($$num_ref++,0,$l3,'maj-min')} = $device->[$f2]; } if ($b_admin && $device->[$f1]){ my $size = ($device->[$f1]) ? main::get_size($device->[$f1],'string') : 'N/A'; - $$rows_ref[$$j_ref]{main::key($$num_ref++,0,$l3,'size')} = $size; + $$rows_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,'size')} = $size; } if ($b_admin && $device->[$f3]){ - $$rows_ref[$$j_ref]{main::key($$num_ref++,0,$l3,'state')} = $device->[$f3]; + $$rows_ref[$$j_ref]->{main::key($$num_ref++,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_ref[$$j_ref]->{main::key($$num_ref++,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_ref[$$j_ref]->{main::key($$num_ref++,0,$l3,$extra2)} = $device->[$f5]; } } eval $end if $b_log; @@ -14906,38 +14912,38 @@ sub md_data { } #print "$_\n"; if ($_ =~ /^([0-9]+)\sblocks/){ - $mdraid[$j]{'blocks'} = $1; + $mdraid[$j]->{'blocks'} = $1; } if ($_ =~ /super\s([0-9\.]+)\s/){ - $mdraid[$j]{'super-block'} = $1; + $mdraid[$j]->{'super-block'} = $1; } if ($_ =~ /algorithm\s([0-9\.]+)\s/){ - $mdraid[$j]{'algorithm'} = $1; + $mdraid[$j]->{'algorithm'} = $1; } if ($_ =~ /\[([0-9]+\/[0-9]+)\]\s\[([U_]+)\]/){ - $mdraid[$j]{'report'} = $1; - $mdraid[$j]{'u-data'} = $2; + $mdraid[$j]->{'report'} = $1; + $mdraid[$j]->{'u-data'} = $2; } if ($_ =~ /resync=([\S]+)/){ - $mdraid[$j]{'resync'} = $1; + $mdraid[$j]->{'resync'} = $1; } if ($_ =~ /([0-9]+[km])\schunk/i){ - $mdraid[$j]{'chunk-size'} = $1; + $mdraid[$j]->{'chunk-size'} = $1; } if ($_ =~ /(\[[=]*>[\.]*\]).*(resync|recovery)\s*=\s*([0-9\.]+%)?(\s\(([0-9\/]+)\))?/){ - $mdraid[$j]{'progress-bar'} = $1; - $mdraid[$j]{'recovery-percent'} = $3 if $3; - $mdraid[$j]{'sectors-recovered'} = $5 if $5; + $mdraid[$j]->{'progress-bar'} = $1; + $mdraid[$j]->{'recovery-percent'} = $3 if $3; + $mdraid[$j]->{'sectors-recovered'} = $5 if $5; } if ($_ =~ /finish\s*=\s*([\S]+)\s+speed\s*=\s*([\S]+)/){ - $mdraid[$j]{'recovery-finish'} = $1; - $mdraid[$j]{'recovery-speed'} = $2; + $mdraid[$j]->{'recovery-finish'} = $1; + $mdraid[$j]->{'recovery-speed'} = $2; } #print 'mdraid loop: ', Data::Dumper::Dumper \@mdraid; } if (@mdraid){ - $mdraid[0]{'system-supported'} = $system if $system; - $mdraid[0]{'unused'} = $unused if $unused; + $mdraid[0]->{'system-supported'} = $system if $system; + $mdraid[0]->{'unused'} = $unused if $unused; } #print Data::Dumper::Dumper \@mdraid; eval $end if $b_log; @@ -15075,15 +15081,15 @@ sub zfs_data { if ($row[1] =~ /raid|mirror/){ $row[1] =~ s/^raid1/mirror/; #$row[1] =~ s/^raid/raid-/; # need to match in zpool status - $k = scalar @{$zfs[$j]{'arrays'}}; - $zfs[$j]{'arrays'}[$k]{'level'} = $row[1]; + $k = scalar @{$zfs[$j]->{'arrays'}}; + $zfs[$j]->{'arrays'}[$k]{'level'} = $row[1]; $i = 0; $size_logical = $size = ($row[2] && $row[2] ne '-') ? main::translate_size($row[2]) : ''; $size_holder = 0; $raw_logical[0] += $size if $size; - $zfs[$j]{'arrays'}[$k]{'size'} = $size; - $zfs[$j]{'arrays'}[$k]{'allocated'} = ($row[3] && $row[3] ne '-') ? main::translate_size($row[3]) : ''; - $zfs[$j]{'arrays'}[$k]{'free'} = ($row[4] && $row[4] ne '-') ? main::translate_size($row[4]) : ''; + $zfs[$j]->{'arrays'}[$k]{'size'} = $size; + $zfs[$j]->{'arrays'}[$k]{'allocated'} = ($row[3] && $row[3] ne '-') ? main::translate_size($row[3]) : ''; + $zfs[$j]->{'arrays'}[$k]{'free'} = ($row[4] && $row[4] ne '-') ? main::translate_size($row[4]) : ''; } # https://blogs.oracle.com/eschrock/entry/zfs_hot_spares elsif ($row[1] =~ /spares/){ @@ -15107,19 +15113,19 @@ sub zfs_data { # data since they have no array row, but they might show it in # component row: # ada0s2 25.9G 19.6G 6.25G - 0% 75% - if (!$zfs[$j]{'size'} && $row[2] && $row[2] ne '-') { + if (!$zfs[$j]->{'size'} && $row[2] && $row[2] ne '-') { $size_logical = $size = ($row[2])? main::translate_size($row[2]): ''; $size_holder = 0; - $zfs[$j]{'arrays'}[$k]{'size'} = $size; + $zfs[$j]->{'arrays'}[$k]{'size'} = $size; $raw_logical[0] += $size if $size; } - if (!$zfs[$j]{'allocated'} && $row[3] && $row[3] ne '-') { + if (!$zfs[$j]->{'allocated'} && $row[3] && $row[3] ne '-') { $allocated = ($row[3])? main::translate_size($row[3]): ''; - $zfs[$j]{'arrays'}[$k]{'allocated'} = $allocated; + $zfs[$j]->{'arrays'}[$k]{'allocated'} = $allocated; } - if (!$zfs[$j]{'free'} && $row[4] && $row[4] ne '-') { + if (!$zfs[$j]->{'free'} && $row[4] && $row[4] ne '-') { $free = ($row[4])? main::translate_size($row[4]): ''; - $zfs[$j]{'arrays'}[$k]{'free'} = $free; + $zfs[$j]->{'arrays'}[$k]{'free'} = $free; } if ((!$maj_min || !$part_size) && @lsblk){ my @part = main::get_proc_partition($working); @@ -15134,7 +15140,7 @@ sub zfs_data { $part_size = $data{'size'}; } $raw_logical[1] += $part_size if $part_size; - $zfs[$j]{'arrays'}[$k]{'components'}[$i] = [$working,$part_size,$maj_min,$state]; + $zfs[$j]->{'arrays'}[$k]{'components'}[$i] = [$working,$part_size,$maj_min,$state]; $i++; } } @@ -15145,7 +15151,7 @@ sub zfs_data { foreach my $row (@zfs){ my @arrays = (ref $row->{'arrays'} eq 'ARRAY' ) ? @{$row->{'arrays'}} : (); @arrays = grep {defined $_} @arrays; - $zfs[$j]{'arrays'} = \@arrays; + $zfs[$j]->{'arrays'} = \@arrays; $j++; } @zfs = zfs_status($zpool,\@zfs); @@ -15275,24 +15281,24 @@ sub create_output { 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 > 2 && $item->{'voltage'}){ - $rows[$j]{main::key($num++,0,2,'voltage')} = $item->{'voltage'}; + $rows[$j]->{main::key($num++,0,2,'voltage')} = $item->{'voltage'}; } } else { @@ -15320,15 +15326,15 @@ sub create_output { }); next if ($mod->{'size'} =~ /\D/); 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'}; } 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'}){ @@ -15341,32 +15347,32 @@ sub create_output { $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'}; } if ($extra > 0 ){ $mod->{'device-type'} ||= 'N/A'; - $rows[$j]{main::key($num++,0,3,'type')} = $mod->{'device-type'}; + $rows[$j]->{main::key($num++,0,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,3,'detail')} = $mod->{'device-type-detail'}; + $rows[$j]->{main::key($num++,0,3,'detail')} = $mod->{'device-type-detail'}; } } if ($extra > 2 ){ $mod->{'data-width'} ||= 'N/A'; - $rows[$j]{main::key($num++,0,3,'bus width')} = $mod->{'data-width'}; + $rows[$j]->{main::key($num++,0,3,'bus width')} = $mod->{'data-width'}; $mod->{'total-width'} ||= 'N/A'; - $rows[$j]{main::key($num++,0,3,'total')} = $mod->{'total-width'}; + $rows[$j]->{main::key($num++,0,3,'total')} = $mod->{'total-width'}; } if ($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 ($extra > 2 ){ $mod->{'serial'} = main::apply_filter($mod->{'serial'}); - $rows[$j]{main::key($num++,0,3,'serial')} = $mod->{'serial'}; + $rows[$j]->{main::key($num++,0,3,'serial')} = $mod->{'serial'}; } } } @@ -15392,35 +15398,35 @@ sub dmidecode_data { 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 $check = main::row_defaults('note-check'); + #print Data::Dumper::Dumper \@dmi; foreach my $entry (@dmi){ ## NOTE: do NOT reset these values, that causes failures # ($derived_module_size,$max_cap_5,$max_cap_16,$max_module_size) = (0,0,0,0); if ($entry->[0] == 5){ - $ram[$k] = ({}) if !$ram[$k]; foreach my $item (@$entry){ @temp = split(/:\s*/, $item, 2); 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.*$//; - $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; } @@ -15435,8 +15441,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\)?//; @@ -15466,7 +15472,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, @@ -15480,38 +15486,37 @@ sub dmidecode_data { $handle = $entry->[1]; $ram[$handle] = $ram[$k] if $ram[$k]; $ram[$k] = undef; - $ram[$handle] = ({}) if !$ram[$handle]; # ($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 set_dmidecode_data, 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,$data_width) = ('','','',''); @@ -15589,9 +15594,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. @@ -15606,21 +15611,21 @@ sub dmidecode_data { $data_width = $total_width; $total_width = $temp_width; } - $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]{'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]->{'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]{'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; $i++ } elsif ($entry->[0] < 17 ){ @@ -15901,7 +15906,7 @@ sub get { my %packages = PackageData::get('main',\$num); my @data; for (keys %packages){ - $rows_p[0]{$_} = $packages{$_}; + $rows_p[0]->{$_} = $packages{$_}; } $b_pkg = 1; } @@ -16720,35 +16725,35 @@ sub create_output { 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; } - $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 == 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; } } $j = scalar @rows; @@ -16758,71 +16763,71 @@ sub create_output { 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 && 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'; + $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){ # 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'}; } } } @@ -16833,23 +16838,23 @@ sub create_output { $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 == 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'}; } } eval $end if $b_log; @@ -16954,8 +16959,7 @@ sub ipmi_data { } # note: can be cpu fan:, cpu fan speed:, etc. elsif ($row[$i_key] =~ /^(CPU|Processor)[\s_]Fan/i) { - $sensors{'fan-main'} = () if !$sensors{'fan-main'}; - $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 @@ -16966,13 +16970,13 @@ sub ipmi_data { $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; } } } @@ -17126,54 +17130,47 @@ sub lm_sensors_data { $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'} = () if !$sensors{'fan-main'}; - $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'} = () if !$sensors{'fan-main'}; - $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'} = () if !$sensors{'fan-main'}; - $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'} = () if !$sensors{'fan-main'}; - $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 # note: cpu/mobo/ps/sodimm are 1/2/3/4 elsif ($_ =~ /^F?(AUX|CASE|CHASSIS|FRONT|REAR).*:([0-9]+)[\s]RPM/i) { $temp_working = $2; - $sensors{'fan-main'} = () if !$sensors{'fan-main'}; 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'} = () if !$sensors{'fan-default'}; - $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; - $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; } } } @@ -17600,31 +17597,30 @@ sub gpu_data { main::log_data('cmd',$cmd) if $b_log; push(@data,@data2); $j = scalar @gpudata; - $gpudata[$j] = ({}); 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; + $gpudata[$j]->{'type'} = 'nvidia'; + $gpudata[$j]->{'speed-unit'} = '%'; + $gpudata[$j]->{'screen'} = $screen; + if (!$gpudata[$j]->{'temp'} && $attribute eq 'GPUCoreTemp'){ + $gpudata[$j]->{'temp'} = $value; } - elsif (!$gpudata[$j]{'ram'} && $attribute eq 'VideoRam'){ - $gpudata[$j]{'ram'} = $value; + elsif (!$gpudata[$j]->{'ram'} && $attribute eq 'VideoRam'){ + $gpudata[$j]->{'ram'} = $value; } - elsif (!$gpudata[$j]{'clock'} && $attribute eq 'GPUCurrentClockFreqs'){ - $gpudata[$j]{'clock'} = $value; + elsif (!$gpudata[$j]->{'clock'} && $attribute eq 'GPUCurrentClockFreqs'){ + $gpudata[$j]->{'clock'} = $value; } - elsif (!$gpudata[$j]{'bus'} && $attribute eq 'PCIBus'){ - $gpudata[$j]{'bus'} = $value; + elsif (!$gpudata[$j]->{'bus'} && $attribute eq 'PCIBus'){ + $gpudata[$j]->{'bus'} = $value; } - elsif (!$gpudata[$j]{'bus-id'} && $attribute eq 'PCIDevice'){ - $gpudata[$j]{'bus-id'} = $value; + elsif (!$gpudata[$j]->{'bus-id'} && $attribute eq 'PCIDevice'){ + $gpudata[$j]->{'bus-id'} = $value; } - elsif (!$gpudata[$j]{'fan-speed'} && $attribute eq 'GPUCurrentFanSpeed'){ - $gpudata[$j]{'fan-speed'} = $value; + elsif (!$gpudata[$j]->{'fan-speed'} && $attribute eq 'GPUCurrentFanSpeed'){ + $gpudata[$j]->{'fan-speed'} = $value; } } } @@ -17636,10 +17632,9 @@ sub gpu_data { foreach (@data){ if (/Sensor [^0-9]*([0-9\.]+) /){ $j = scalar @gpudata; - $gpudata[$j] = ({}); my $value = $1; - $gpudata[$j]{'type'} = 'amd'; - $gpudata[$j]{'temp'} = $value; + $gpudata[$j]->{'type'} = 'amd'; + $gpudata[$j]->{'temp'} = $value; } } } @@ -17647,32 +17642,32 @@ sub gpu_data { #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/; + $gpudata[$j]->{'type'} = $adapter; + $gpudata[$j]->{'type'} =~ s/^(amdgpu|intel|nouveau|radeon)-.*/$1/; # print "ad: $adapter\n"; 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; + $gpudata[$j]->{'temp-mem'} = $1; + $gpudata[$j]->{'unit'} = $2; # print "temp: $_\n"; } elsif (/^[^:]+:([0-9\.]+).*\b(C|F)\b/i){ - $gpudata[$j]{'temp'} = $1; - $gpudata[$j]{'unit'} = $2; + $gpudata[$j]->{'temp'} = $1; + $gpudata[$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; + $gpudata[$j]->{'fan-speed'} = $1; # NOTE: we test for nvidia %, everything else stays with nothing - $gpudata[$j]{'speed-unit'} = ''; + $gpudata[$j]->{'speed-unit'} = ''; } elsif (/^[^:]+:([0-9\.]+)\s+W\s/i){ - $gpudata[$j]{'watts'} = $1; + $gpudata[$j]->{'watts'} = $1; } elsif (/^[^:]+:([0-9\.]+)\s+mV\s/i){ - $gpudata[$j]{'mvolts'} = $1; + $gpudata[$j]->{'mvolts'} = $1; } } } @@ -17720,9 +17715,8 @@ sub slot_data { if ($entry->[0] == 9){ my ($designation,$id,$length,$type,$usage) = ('','','','',''); # skip first two row, we don't need that data - splice @$entry, 0, 2 if @$entry; my $j = scalar @rows; - foreach my $item (@$entry){ + foreach my $item (@$entry[2 .. $#$entry]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); if ($value[0] eq 'Type'){ @@ -17757,7 +17751,7 @@ sub slot_data { main::key($num++,0,2,'status') => $usage, },); if ($extra > 1 ){ - $rows[$j]{main::key($num++,0,2,'length')} = $length; + $rows[$j]->{main::key($num++,0,2,'length')} = $length; } } } @@ -17809,16 +17803,16 @@ 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::row_defaults('swap-admin'); + $rows[$j]->{main::key($num++,0,1,'Message')} = main::row_defaults('swap-admin'); } } $j = scalar @rows; @@ -17830,38 +17824,38 @@ 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') ){ $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, '') if $use{'filter-label'}; - $rows[$j]{main::key($num++,0,2,'label')} = ($row->{'label'}) ? $row->{'label'}: 'N/A'; + $rows[$j]->{main::key($num++,0,2,'label')} = ($row->{'label'}) ? $row->{'label'}: 'N/A'; } if ($show{'uuid'} && ($row->{'uuid'} || $row->{'swap-type'} eq 'partition' )){ $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, '') if $use{'filter-uuid'}; - $rows[$j]{main::key($num++,0,2,'uuid')} = ($row->{'uuid'}) ? $row->{'uuid'}: 'N/A'; + $rows[$j]->{main::key($num++,0,2,'uuid')} = ($row->{'uuid'}) ? $row->{'uuid'}: 'N/A'; } } eval $end if $b_log; @@ -17931,15 +17925,15 @@ sub create_output { 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'}; } - $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,'label')} = $row->{'label'}; - $rows[$j]{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; + $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,'label')} = $row->{'label'}; + $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; } eval $end if $b_log; return @rows; @@ -18143,30 +18137,30 @@ sub usb_data { $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 > 2 && 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 > 1){ - $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 (!$b_hub && $extra > 2){ if ($serial){ - $rows[$j]{main::key($num++,0,$ind_sc,'serial')} = main::apply_filter($serial); + $rows[$j]->{main::key($num++,0,$ind_sc,'serial')} = main::apply_filter($serial); } } } @@ -18243,41 +18237,41 @@ sub create_output { my $pressure = unit_output($weather{'pressure'},$weather{'pressure-mb'},'mb',$weather{'pressure-in'},'in'); my $wind = wind_output($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; + $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'} . '%'; + $rows[$j]->{main::key($num++,0,2,'cloud cover')} = $weather{'cloud-cover'} . '%'; } if ($weather{'precip-1h-mm'} && defined $weather{'precip-1h-in'} ){ $value = unit_output('',$weather{'precip-1h-mm'},'mm',$weather{'precip-1h-in'},'in'); - $rows[$j]{main::key($num++,0,2,'precipitation')} = $value; + $rows[$j]->{main::key($num++,0,2,'precipitation')} = $value; } if ($weather{'rain-1h-mm'} && defined $weather{'rain-1h-in'} ){ $value = unit_output('',$weather{'rain-1h-mm'},'mm',$weather{'rain-1h-in'},'in'); - $rows[$j]{main::key($num++,0,2,'rain')} = $value; + $rows[$j]->{main::key($num++,0,2,'rain')} = $value; } if ($weather{'snow-1h-mm'} && defined $weather{'snow-1h-in'} ){ $value = unit_output('',$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,'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 = unit_output($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,'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 = unit_output($weather{'heat-index'},$weather{'heat-index-c'},'C',$weather{'heat-index-f'},'F'); - $rows[$j]{main::key($num++,0,2,'heat index')} = $value; + $rows[$j]->{main::key($num++,0,2,'heat index')} = $value; } if ($weather{'windchill'} || (defined $weather{'windchill-c'} && defined $weather{'windchill-f'})){ $value = unit_output($weather{'windchill'},$weather{'windchill-c'},'C',$weather{'windchill-f'},'F'); - $rows[$j]{main::key($num++,0,2,'wind chill')} = $value; + $rows[$j]->{main::key($num++,0,2,'wind chill')} = $value; } if ($extra > 2){ if ($weather{'forecast'}){ @@ -18297,26 +18291,26 @@ sub create_output { main::key($num++,1,1,'Locale') => $location, },); if ($extra > 2 && !$use{'filter'} && ($weather{'elevation-m'} || $weather{'elevation-ft'} )){ - $rows[$j]{main::key($num++,0,2,'altitude')} = elevation_output($weather{'elevation-m'},$weather{'elevation-ft'}); + $rows[$j]->{main::key($num++,0,2,'altitude')} = elevation_output($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'}; + $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'}; + $rows[$j]->{main::key($num++,0,2,'sunrise')} = $weather{'sunrise'}; } if ($weather{'sunset'}){ - $rows[$j]{main::key($num++,0,2,'sunset')} = $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; + $rows[$j]->{main::key($num++,0,2,'moonphase')} = $value; } } if ($weather{'api-source'}){ - $rows[$j]{main::key($num++,0,1,'Source')} = $weather{'api-source'}; + $rows[$j]->{main::key($num++,0,1,'Source')} = $weather{'api-source'}; } eval $end if $b_log; return @rows; @@ -20422,10 +20416,10 @@ sub get_memory_data_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; + $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; $b_mem = 1; } eval $end if $b_log; @@ -21825,7 +21819,7 @@ sub set_dmidecode_data { # but we do want to preserve the indentation. Empty lines # won't matter, they will be skipped, so no need to handle them. # some dmidecodes do not use empty line separators - splice @data, 0, 5 if @data; + splice(@data, 0, 5) if @data; my $j = 0; my $b_skip = 1; foreach (@data){ @@ -21862,9 +21856,7 @@ sub set_dmidecode_data { } if (@working && $working[0] != 32 && $working[0] != 127){ $j = scalar @dmi; - $dmi[$j] = ( - [@working], - ); + $dmi[$j] = \@working; } # last by not least, sort it by dmi type, now we don't have to worry # about random dmi type ordering in the data, which happens. Also sort @@ -22438,12 +22430,12 @@ sub usbdevs_data { $working[17] = ''; $working[18] = ''; $usb[$j] = ([@working],); - ${$usb[$k]}[10] = $ports; + $usb[$k]->[10] = $ports; @working = (); } elsif (/^\s+port\s([0-9]+)\spowered/){ $ports++; - ${$usb[$k]}[10] = $ports; + $usb[$k]->[10] = $ports; } } if (@working){ @@ -22526,25 +22518,25 @@ sub sys_data { $configuration = sys_item("$_/configuration"); if ($source eq 'lsusb'){ for ($i = 0; $i < scalar @usb; $i++){ - if (${$usb[$i]}[0] eq $bus_id && ${$usb[$i]}[1] == $device_id){ + if ($usb[$i]->[0] eq $bus_id && $usb[$i]->[1] == $device_id){ #print $type,"\n"; - ${$usb[$i]}[0] = $bus_id_alpha; - ${$usb[$i]}[2] = $path_id; - ${$usb[$i]}[3] = $_; - ${$usb[$i]}[4] = $class_id; - ${$usb[$i]}[5] = $subclass_id; - ${$usb[$i]}[6] = $protocol_id; - ${$usb[$i]}[8] = $usb_version; - ${$usb[$i]}[9] = $interfaces; - ${$usb[$i]}[10] = $ports if $ports; - if ($type && $b_hub && (!${$usb[$i]}[13] || ${$usb[$i]}[13] =~ /^linux foundation/i )){ - ${$usb[$i]}[13] = "$type"; + $usb[$i]->[0] = $bus_id_alpha; + $usb[$i]->[2] = $path_id; + $usb[$i]->[3] = $_; + $usb[$i]->[4] = $class_id; + $usb[$i]->[5] = $subclass_id; + $usb[$i]->[6] = $protocol_id; + $usb[$i]->[8] = $usb_version; + $usb[$i]->[9] = $interfaces; + $usb[$i]->[10] = $ports if $ports; + if ($type && $b_hub && (!$usb[$i]->[13] || $usb[$i]->[13] =~ /^linux foundation/i )){ + $usb[$i]->[13] = "$type"; } - ${$usb[$i]}[14] = $type if ($type && !$b_hub); - ${$usb[$i]}[15] = $driver if $driver; - ${$usb[$i]}[16] = $serial if $serial; - ${$usb[$i]}[17] = $speed if $speed; - ${$usb[$i]}[18] = $configuration; + $usb[$i]->[14] = $type if ($type && !$b_hub); + $usb[$i]->[15] = $driver if $driver; + $usb[$i]->[16] = $serial if $serial; + $usb[$i]->[17] = $speed if $speed; + $usb[$i]->[18] = $configuration; #print join("\n",@{$usb[$i]}),"\n\n";# if !$b_hub; last; } @@ -22579,25 +22571,25 @@ sub sys_data { # $name = ($name) ? "$name $configuration" : $configuration; #} $type = 'Hub' if $b_hub; - ${$usb[$i]}[0] = $bus_id_alpha; - ${$usb[$i]}[1] = $device_id; - ${$usb[$i]}[2] = $path_id; - ${$usb[$i]}[3] = $_; - ${$usb[$i]}[4] = $class_id; - ${$usb[$i]}[5] = $subclass_id; - ${$usb[$i]}[6] = $protocol_id; - ${$usb[$i]}[7] = "$vendor_id:$chip_id"; - ${$usb[$i]}[8] = $usb_version; - ${$usb[$i]}[9] = $interfaces; - ${$usb[$i]}[10] = $ports; - ${$usb[$i]}[11] = $vendor; - ${$usb[$i]}[12] = $product; - ${$usb[$i]}[13] = $name; - ${$usb[$i]}[14] = $type; - ${$usb[$i]}[15] = $driver; - ${$usb[$i]}[16] = $serial; - ${$usb[$i]}[17] = $speed; - ${$usb[$i]}[18] = $configuration; + $usb[$i]->[0] = $bus_id_alpha; + $usb[$i]->[1] = $device_id; + $usb[$i]->[2] = $path_id; + $usb[$i]->[3] = $_; + $usb[$i]->[4] = $class_id; + $usb[$i]->[5] = $subclass_id; + $usb[$i]->[6] = $protocol_id; + $usb[$i]->[7] = "$vendor_id:$chip_id"; + $usb[$i]->[8] = $usb_version; + $usb[$i]->[9] = $interfaces; + $usb[$i]->[10] = $ports; + $usb[$i]->[11] = $vendor; + $usb[$i]->[12] = $product; + $usb[$i]->[13] = $name; + $usb[$i]->[14] = $type; + $usb[$i]->[15] = $driver; + $usb[$i]->[16] = $serial; + $usb[$i]->[17] = $speed; + $usb[$i]->[18] = $configuration; $i++; } #print "$path_id ids: $bus_id:$device_id driver: $driver ports: $ports\n==========\n"; # if $test[6];; @@ -22962,15 +22954,15 @@ sub generate_short_data { my ($size,$used) = ('',''); my ($size_holder,$used_holder); if (@disk){ - $size = ($disk[0]{'logical-size'}) ? $disk[0]{'logical-size'} : $disk[0]{'size'}; + $size = ($disk[0]->{'logical-size'}) ? $disk[0]->{'logical-size'} : $disk[0]->{'size'}; # must be > 0 if ($size && is_numeric($size) ){ $size_holder = $size; $size = get_size($size,'string'); } - $used = $disk[0]{'used'}; - if ($used && is_numeric($disk[0]{'used'}) ){ - $used_holder = $disk[0]{'used'}; + $used = $disk[0]->{'used'}; + if ($used && is_numeric($disk[0]->{'used'}) ){ + $used_holder = $disk[0]->{'used'}; $used = get_size($used,'string'); } # in some fringe cases size can be 0 so only assign 'N/A' if no percents etc @@ -23037,7 +23029,7 @@ sub generate_info_data { $index = scalar(@{ $data{$data_name} } ) - 1; if ($extra > 2){ my $wakeups = 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 (!$b_mem){ my $memory = get_memory_data('splits'); @@ -23051,33 +23043,33 @@ sub generate_info_data { $gpu_ram = 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 || $b_force_display) || $extra > 0 ){ my %init = 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; + $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; + $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'}; + $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'}; + $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'}; + $data{$data_name}->[$index]{main::key($num++,0,2,'runlevel')} = $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'}; + $data{$data_name}->[$index]{main::key($num++,0,2,$default)} = $init{'default'}; } } } @@ -23090,21 +23082,21 @@ sub generate_info_data { $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 && !$b_pkg){ my %packages = PackageData::get('inner',\$num); for (keys %packages){ - $data{$data_name}[$index]{$_} = $packages{$_}; + $data{$data_name}->[$index]{$_} = $packages{$_}; } $b_pkg = 1; } @@ -23130,18 +23122,18 @@ sub generate_info_data { if ($extra > 2 && $client{'su-start'}){ $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 ($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)} = &get_self_version(); + $data{$data_name}->[$index]{main::key($num++,0,1,$self_name)} = &get_self_version(); eval $end if $b_log; return %data; @@ -23160,20 +23152,20 @@ sub generate_system_data { ); $index = scalar(@{ $data{$data_name} } ) - 1; if ($show{'host'}){ - $data{$data_name}[$index]{main::key($num++,0,1,'Host')} = get_hostname(); + $data{$data_name}->[$index]{main::key($num++,0,1,'Host')} = get_hostname(); } - $data{$data_name}[$index]{main::key($num++,1,1,'Kernel')} = get_kernel_data(); - $data{$data_name}[$index]{main::key($num++,0,2,'bits')} = get_kernel_bits(); + $data{$data_name}->[$index]{main::key($num++,1,1,'Kernel')} = get_kernel_data(); + $data{$data_name}->[$index]{main::key($num++,0,2,'bits')} = get_kernel_bits(); if ($extra > 0){ my @compiler = get_compiler_version(); # 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]; + $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $compiler[1]; } } if ($b_admin && (my $params = get_kernel_parameters())){ @@ -23181,7 +23173,7 @@ sub generate_system_data { #print "$params\n"; $params = apply_partition_filter('system', $params, 'label') if $use{'filter-label'}; $params = apply_partition_filter('system', $params, 'uuid') if $use{'filter-uuid'}; - $data{$data_name}[$index]{main::key($num++,0,2,'parameters')} = $params; + $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 @@ -23223,34 +23215,34 @@ sub generate_system_data { $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 ($toolkit){ - $data{$data_name}[$index]{main::key($num++,0,2,'tk')} = $toolkit; + $data{$data_name}->[$index]{main::key($num++,0,2,'tk')} = $toolkit; } 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){ - $data{$data_name}[$index]{main::key($num++,0,2,'wm')} = $wm if $wm; + $data{$data_name}->[$index]{main::key($num++,0,2,'wm')} = $wm if $wm; my $dms = get_display_manager(); if ($dms || $desktop_key ne 'Console'){ $dms ||= 'N/A'; - $data{$data_name}[$index]{main::key($num++,0,$ind_dm,$dm_key)} = $dms; + $data{$data_name}->[$index]{main::key($num++,0,$ind_dm,$dm_key)} = $dms; } } #if ($extra > 2 && $desktop_key ne 'Console'){ # my $tty = get_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; diff --git a/inxi.1 b/inxi.1 index f4937d9..822e29b 100644 --- a/inxi.1 +++ b/inxi.1 @@ -1,4 +1,4 @@ -.TH INXI 1 "2020\-12\-15" inxi "inxi manual" +.TH INXI 1 "2020\-12\-17" inxi "inxi manual" .SH NAME inxi \- Command line system information script for console and IRC @@ -296,7 +296,7 @@ use: \fB\-pl\fR. .TP .B \-L\fR, \fB\-\-logical\fR -Show Logical volume information, for LVM, LUKS, bcache, MultiPath, etc. Shows +Show Logical volume information, for LVM, LUKS, bcache, etc. Shows size, free space (for LVM VG). For LVM, shows \fBDevice\-[xx]: VG:\fR (Volume Group) size/free, \fBLV\-[xx]\fR (Logical Volume). LV shows type, size, and components. Note that components are made up of either containers @@ -364,10 +364,9 @@ devices (p\-1) sdj2 and sdk2. size: 12.79 GiB\fR .fi -Other types of logical block handling like LUKS, bcache, multipath, -show as: +Other types of logical block handling like LUKS, bcache show as: -\fBDevice\-[xx] [name/id] type: [LUKS|Crypto|bcache|MultiPath]:\fR +\fBDevice\-[xx] [name/id] type: [LUKS|Crypto|bcache]:\fR .TP .B \-m\fR,\fB \-\-memory\fR @@ -402,7 +401,7 @@ are different, you will see this instead: \fBspeed: spec: [specified speed] MT/S actual: [actual] MT/S\fR -Also, if DDR, and speed in MHz, will change to: \fBspeed: [speed] MT/S ([speed] MHz\fR +Also, if DDR, and speed in MHz, will change to: \fBspeed: [speed] MT/S ([speed] MHz)\fR If the detected speed is logically absurd, like 1 MT/s or 69910 MT/s, adds: \fBnote: check\fR. Sample: diff --git a/inxi.changelog b/inxi.changelog index 739e38e..2b1e107 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,60 @@ +===================================================================================== +Version: 3.2.01 +Patch: 00 +Date: 2020-12-17 +----------------------------------- +Changes: +----------------------------------- + +Bug Fixes!!! Continuing internal refactor!! + +This bug report came in right after 3.2.00 went out live, but I would never have +found it myself in testing so better found than not found! + +Bugs: + +1. A bug was introduced to dmidecode data handlers in 3.2.00 resulted in the +dmidecode data array basically eating itself up until errors appear. Quite difficult +to trigger, but babydr from Slackware forums figured it out, using -F --dmidecode +to force dmidecode use for all features that support it triggered thee bug always. +This was a result of the refactor, previously inxi had worked on copies of referenced +arrays, but in this case, it was working on the original array of arrays, subtle, +but obvious. This method was only used on dmidecode arrays. + +2. A second bug was exposed almost by accident, for -M --dmidecode data, there was +a missing field and also a missing is set test on that field that led to an error +of using undefined value in string comparison. This was strictly speaking 2 bugs, +both very old, from 2.9 first rewrite, one failing to set/get the value, and the +other failing to test if the value was set before using it. + +Fixes: + +1. There were a few glitches in help menu and man page related to -L option, those +are corrected. + + +INTERNAL CODE CHANGES: +1. removed bug inducing splice use in some cases, and added parens to splice to make +it fit the new way of with perl builtins, when taking 2 or more arguments, use parens. + +2. Found many more instances to add -> dereferencing operator. I have to say, not +doing that consistently made the code much harder to read, and created situations +where it's somewhat ambiguous what item belongs to what, with everything consistently +-> operator run, the code is more clear and obvious, and some of the hacks I'd added +because of the lack of clarity were also removed. + +3. Removed explicit setting of hash references with null value, that was done out +of failure to use -> operators which clearly indicate to Perl and coder what is +happening, so those crutches were removed. Also got rid of unnecessary array +priming like: my @array = (); Some of these habits came from other languages, +but in Perl, declaring my @array means it's an array that is null, and you don't +need to do a further (). @array = () is obviously fine for resetting arrays in +loops or whatever, but not in the initial declaration. + + +----------------------------------- +-- Harald Hope - Thu, 17 Dec 2020 14:27:13 -0800 + ===================================================================================== Version: 3.2.00 Patch: 00