From f571b4597311411306140ed5957d2b488d39363d Mon Sep 17 00:00:00 2001 From: Harald Hope Date: Wed, 21 Jul 2021 20:30:58 -0700 Subject: [PATCH] New version! Fixes!! Bug fixes! More bug fixes!! Cleanups! Most of these were exposed by issue #251 filed by LukasNickel, then further revealed via his debugger data set, which showed two more bugs. Well, bugs, changed syntaxes, same difference to end users. -------------------------------------------------------------------------------- KNOWN ISSUES: 1. Work is ongoing to add btrfs support to -R (similar to softraid or zfs), basic stubs and debuggers added, but reporting tools are not as robust (and often require sudo/root for reasons that escape me) as I would have hoped, so it's slow. One of these days... Normally would not release with working stubs, but there were enough real issues/bugs to warrant just getting 3.3.06 out the door, then going on with the btrfs feature for -R. But so far I view the reporting tools as inadequate, unfortunately. -------------------------------------------------------------------------------- BUGS: 1. As initially discovered in issue #251 there are alternate syntaxes which had never been seen before for remote mounts, fuse mounts, etc. In this case, it was fuse.sshfs that was not removed from the Disk total:... used: leading to silly 1000+% used percentage. Note that while technically inxi could try to be clever about reporting impossible percentages, so far those have led to bugs getting reported, then fixed, so I think it worth leaving it as is. 2. When --swap/-j is used with no other arguments, failed to show uuid or label. Discovered this while testing fix 2. 3. Bug which is not a bug but will appear as such to users, nvme temps were failing in -Dx due to a change in how those values are located in /sys. See fix 3. -------------------------------------------------------------------------------- FIXES: 1. Going along with Bug 1, and considering that only in 3.3.05 was the nfs4 remote fs failure to identify/exclude, the entire section involving remote/ fuse etc file systems was refactored, and extended to add many more previously non-handled remote and fuse type file systems. Significant extension of known remote filesystem types, distributed file systems, overlay file systems, all to try to avoid having more distributed/remote/fuse file system issues. Also added test to support fuse. or fuseblk. type prefixes for any of these. Hopefully there will be fewer issues related to distributed and remote and overlay type file systems in the future. 2. Made all label/uuid triggers global, that is, -ol shows unmounted with labels, -ju shows swap with uuid, and so on. This may require a bit more tweaks to get exactly right, but in general, this is a purely cosmetic fix, that is, try not to show label/uuid for partition/mounts that probably can't have those values. 3. There was a change in the way nvme /sys temperature paths were handled, an actually understandable, albeit as always annoying, one, because inxi actually had to do a sort of convoluted hack to get the nvme block devices temperatore paths before, now that hack is not required for newer kernels (5.12+), though for kernels that had the old paths (5,8, 5.9 at least, don't know when paths changed) left in the old method. Now tests are more granular, and inxi should find temperatures regardless of which method is used for nvme and sd type drives. 4. Another somewhat irksome random change, again, understandable since the new syntax is more consistent in output than the previous one, but still breaks all existing parsers that use the changed field names. Lsblk did NOT change the -o input field names, but DID change the output field names, which broke the internal inxi parser, and led to null lsblk data. Changes were - or : separators in input values are output as _ always. that is, MAJ:MIN becomes MAJ_MIN. Also corrected the debugger lsblk to use the same output fields for -P -o as the actual lsblk parser uses internally so these failures can be spotted more readily, as it was, it was literally only because someone submitted the debugger dataset, and was running lsblk 2.37, where I believe this behavior change happened. Solution was to just use regex patterns instead, [:_-], in the parser. Big fear now is that they will randomly stop supporting the -o input field names that contain - or : and change that too without any real warning or deprecation notice. -------------------------------------------------------------------------------- ENHANCEMENTS: 1. Going with bug and fix 1, added avfs, afs, archivemount, avfs, ceph, gfs, glusterfs, gmailfs, hdfs, ipfs, kosmos/kfs, lafs, mergerfs, mhddfs, moosefs, ocfs, openafs, orangefs, overlayfs, pvfs, s3fs, sheepdog, vmfs, and several others to the exclude list for disk used and show label/uuids for partitions. 2. A smattering of disk vendors added. -------------------------------------------------------------------------------- CHANGES: 1. Going with fix 2, -l and -u no longer will trigger -P by default, now if -l or -u are used without -j, -o, -p, -P, an error will explain that you must use one of those together with -l or -u. This was the only way to get the -l and -u switches to turn off/on label/uuid reports in swap, unmounted, and partitions consistently. Triggering -P was really a legacy behavior from when the only options were -p or -P, and --swap and --unmounted did not exist. I found it increasingly odd that unmounted would show label/uuid always but partitions only with -l/-u. 2. This was a pet peeve, sometimes field names just bug me (like 'Topology: did for CPU, now corrected to Info:), the Drive: rotation: was one such annoyance. I had recycled that to indicate SSD, which was a feature request, but that was always a sloppy solution, and made no sense, since SSD isn't a rotation speed. Now it reports a much more logical: ID-1:...... type: HDD rpm: 7200 or ID-1:...... type: SSD or ID-1:...... type: N/A This also corresponds to the intended meaning much better. The HDD type was always present internally if rotation speed is detected, but was not used. Now will also show type: N/A if reliable type detection failed, which will also be more consistent. -------------------------------------------------------------------------------- DOCUMENTATION: 1. Brought most of inxi.changelog (this file) into a consistent state, re whitespaces, readability, consistent use of various header / section names. Ideally while I don't expect anyone to ever sit down and read this changelog, it will be now much easier to scan to find whatever interests you. This change goes along with ongoing changes in docs to in general try to be usually 80 columns wide. 2. inxi-resources.txt, inxi-data.txt are updated with more raid, partition, file system values and data to go along with bug, fix, enhancement 1. 3. Man and help updated to indicate -u and -l no longer trigger -P by default. -------------------------------------------------------------------------------- CODE: 1. Ongoing refactors, bringing the codebase to the point that matches current coding styles. Removed remainder of whitespaces in conditions and for/while loops, for example: if ( condition ) { becomes: if (condition){ and if ( ( test set 1 ) && ( test set 2 ) ) { becomes: if ((test set 1) && (test set 2)){ and so on. That dropped over 2 KiB of whitespaces. This went along with fixes that have been ongoing to change to this whitespace use style, but previously it was only being done when that situation was hit in a local block, now it's been completed globally. This continues the style refactor that has been ongoing for a while now, to bring inxi into a consistent state, since when it started, it was more pressing to get the bash/gawk mess translated to Perl than it was to get the Perl itself to be as good/consistent as possible, so now those issues are being slowly unravelled, and hopefully will set inxi on course for its next 10 years. It was starting to get annoying, because some parts of inxi used those spaces, and all newer ones didn't in general. Now it's one behavior throughout the whole program file. 2. Refactored the entire fs exclude for disk used data, and integrated those values into a global tool that is used either to exclude file systems from disk used totals, or to not show uuid/labels for the excluded remote/distributed/overlay type file systems, which in general don't have uuid or labels. --- inxi | 2496 +++++++++++++++++++++++++----------------------- inxi.1 | 46 +- inxi.changelog | 181 ++++ 3 files changed, 1528 insertions(+), 1195 deletions(-) diff --git a/inxi b/inxi index 6bc9eaa..8358388 100755 --- a/inxi +++ b/inxi @@ -5,7 +5,7 @@ ## Further fixes (listed as known): Horst Tritremmel ## Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch ## Jarett.Stevens - dmidecode -M patch for older systems without /sys machine -## +## ## License: GNU GPL v3 or greater ## ## You should have received a copy of the GNU General Public License @@ -46,8 +46,8 @@ use POSIX qw(ceil uname strftime ttyname); ## INXI INFO ## my $self_name='inxi'; -my $self_version='3.3.05'; -my $self_date='2021-07-11'; +my $self_version='3.3.06'; +my $self_date='2021-07-21'; my $self_patch='00'; ## END INXI INFO ## @@ -79,8 +79,8 @@ my (@app,@dmi,@gpudata,@ifs,@ifs_bsd,@paths,@ps_aux,@ps_cmd,@ps_gui, @sensors_exclude,@sensors_use,@uname); ## Disk/Logical/Partition/RAID arrays -my (@glabel,@labels,@lsblk,@lvm,@lvm_raid,@md_raid,@partitions,@proc_partitions, -@raw_logical,@soft_raid,@swaps,@uuids,@zfs_raid); +my (@btrfs_raid,@glabel,@labels,@lsblk,@lvm,@lvm_raid,@md_raid,@partitions, +@proc_partitions,@raw_logical,@soft_raid,@swaps,@uuids,@zfs_raid); ## Debuggers my %debugger = ('level' => 0); @@ -127,7 +127,7 @@ my $prefix = 0; # for the primiary row hash key prefix # these assign a separator to non irc states. Important! Using ':' can # trigger stupid emoticon. Note: SEP1/SEP2 from short form not used anymore. # behaviors in output on IRC, so do not use those. -my %sep = ( +my %sep = ( 's1-irc' => ':', 's1-console' => ':', 's2-irc' => '', @@ -171,7 +171,7 @@ sub main { # my $ob_start = StartClient->new(); #$ob_start->get_client_data(); StartClient::set(); - # print_line( Dumper \%client); + # print_line(Dumper \%client); OptionsHandler::get(); set_debugger(); # right after so it's set CheckTools::set(); @@ -209,15 +209,15 @@ sub set { eval $start if $b_log; set_commands(); my ($action,$program,$message,@data); - foreach my $test ( keys %commands ){ + foreach my $test (keys %commands){ ($action,$program) = ('use',''); $message = main::row_defaults('tool-present'); if ($commands{$test}->[1] && ( - ($commands{$test}->[1] eq 'linux' && $os ne 'linux' ) || - ($commands{$test}->[1] eq 'bsd' && $os eq 'linux' ) ) ){ + ($commands{$test}->[1] eq 'linux' && $os ne 'linux') || + ($commands{$test}->[1] eq 'bsd' && $os eq 'linux'))){ $action = 'platform'; } - elsif ($program = main::check_program($test)) { + elsif ($program = main::check_program($test)){ # > 0 means error in shell # my $cmd = "$program $commands{$test} >/dev/null"; # print "$cmd\n"; @@ -260,7 +260,7 @@ sub set { sub set_dmidecode { my ($data) = @_; my $action = 'use'; - if ($b_root) { + if ($b_root){ foreach (@$data){ # don't need first line or scanning /dev/mem lines if (/^(# dmi|Scanning)/){ @@ -305,7 +305,7 @@ sub set_commands { # note: gnu/linux has sysctl so it may be used that for something if present # there is lspci for bsds so doesn't hurt to check it if (!$bsd_type){ - if ($use{'pci'} ){ + if ($use{'pci'}){ $commands{'lspci'} = ['exec-sys','','-n']; } if ($use{'logical'}){ @@ -357,6 +357,9 @@ sub set_commands { $commands{'blockdev'} = ['missing','linux','','']; $commands{'lsblk'} = ['missing','linux','','']; } + if ($use{'btrfs'}){ + $commands{'btrfs'} = ['missing','linux','','']; + } if ($use{'mdadm'}){ $commands{'mdadm'} = ['missing','linux','','']; } @@ -418,7 +421,7 @@ sub set_basics { $ENV{'LC_ALL'}='C'; # remember, perl uses the opposite t/f return as shell!!! # some versions of busybox do not have tty, like openwrt - $b_irc = (check_program('tty') && system('tty >/dev/null') ) ? 1 : 0; + $b_irc = (check_program('tty') && system('tty >/dev/null')) ? 1 : 0; # print "birc: $b_irc\n"; $b_display = ($ENV{'DISPLAY'}) ? 1 : 0; $b_root = $< == 0; # root UID 0, all others > 0 @@ -448,7 +451,7 @@ sub set_display_width { if ($width eq 'live'){ ## sometimes tput will trigger an error (mageia) if irc client if (!$b_irc){ - if (my $program = check_program('tput')) { + if (my $program = check_program('tput')){ # Arch urxvt: 'tput: unknown terminal "rxvt-unicode-256color"' # trips error if use qx(); in FreeBSD, if you use 2>/dev/null # it makes default value 80x24, who knows why? @@ -496,9 +499,9 @@ sub set_os { $os = lc($uname[0]); $cpu_arch = lc($uname[-1]); if ($cpu_arch =~ /arm|aarch/){$b_arm = 1;} - elsif ($cpu_arch =~ /mips/) {$b_mips = 1} - elsif ($cpu_arch =~ /power|ppc/) {$b_ppc = 1} - elsif ($cpu_arch =~ /sparc/) {$b_sparc = 1} + elsif ($cpu_arch =~ /mips/){$b_mips = 1} + elsif ($cpu_arch =~ /power|ppc/){$b_ppc = 1} + elsif ($cpu_arch =~ /sparc/){$b_sparc = 1} # aarch32 mips32 intel/amd handled in cpu if ($cpu_arch =~ /(armv[1-7]|32|sparc_v9)/){ $bits_sys = 32; @@ -534,8 +537,8 @@ sub set_path { @path = split(':', $ENV{'PATH'}) if $ENV{'PATH'}; # print "paths: @paths\nPATH: $ENV{'PATH'}\n"; # Create a difference of $PATH and $extra_paths and add that to $PATH: - foreach my $id (@path) { - if ( !(grep { /^$id$/ } @paths) && $id !~ /(game)/ ){ + foreach my $id (@path){ + if (!(grep { /^$id$/ } @paths) && $id !~ /(game)/){ push(@paths, $id); } } @@ -543,9 +546,9 @@ sub set_path { } sub set_sep { - if ( $b_irc ){ + if ($b_irc){ # too hard to read if no colors, so force that for users on irc - if ($colors{'scheme'} == 0 ){ + if ($colors{'scheme'} == 0){ $sep{'s1'} = $sep{'s1-console'}; $sep{'s2'} = $sep{'s2-console'}; } @@ -571,7 +574,7 @@ sub set_sudo { if (!$force{'no-doas'} && ($path = check_program('doas'))){ $sudoas = "$path -n "; } - elsif (!$force{'no-sudo'} && ($path = check_program('sudo'))) { + elsif (!$force{'no-sudo'} && ($path = check_program('sudo'))){ my @data = program_data('sudo'); $data[1] =~ s/^([0-9]+\.[0-9]+).*/$1/; # print "sudo v: $data[1]\n"; @@ -603,13 +606,12 @@ sub set_system_files { } sub set_user_paths { - my ( $b_conf, $b_data ); + my ($b_conf,$b_data); # this needs to be set here because various options call the parent # initialize function directly. $self_path = $0; $self_path =~ s/[^\/]+$//; # print "0: $0 sp: $self_path\n"; - if (defined $ENV{'XDG_CONFIG_HOME'} && $ENV{'XDG_CONFIG_HOME'}){ $user_config_dir=$ENV{'XDG_CONFIG_HOME'}; $b_conf=1; @@ -678,14 +680,14 @@ sub set_xorg_log { if ($src_info){ $x_mtime = $src_info->mtime; # print $_ . ": $x_time" . "\n"; - if ($x_mtime > $time_holder ){ + if ($x_mtime > $time_holder){ $time_holder = $x_mtime; $file_holder = $_; } } } } - if ( !$file_holder && check_program('xset') ){ + if (!$file_holder && check_program('xset')){ my $data = qx(xset q 2>/dev/null); foreach (split('\n', $data)){ if ($_ =~ /Log file/i){ @@ -713,44 +715,44 @@ sub get_color_scheme { my ($type) = @_; eval $start if $b_log; my @color_schemes = ( - [qw(EMPTY EMPTY EMPTY )], - [qw(NORMAL NORMAL NORMAL )], + [qw(EMPTY EMPTY EMPTY)], + [qw(NORMAL NORMAL NORMAL)], # for dark OR light backgrounds [qw(BLUE NORMAL NORMAL)], - [qw(BLUE RED NORMAL )], - [qw(CYAN BLUE NORMAL )], + [qw(BLUE RED NORMAL)], + [qw(CYAN BLUE NORMAL)], [qw(DCYAN NORMAL NORMAL)], - [qw(DCYAN BLUE NORMAL )], - [qw(DGREEN NORMAL NORMAL )], - [qw(DYELLOW NORMAL NORMAL )], - [qw(GREEN DGREEN NORMAL )], - [qw(GREEN NORMAL NORMAL )], + [qw(DCYAN BLUE NORMAL)], + [qw(DGREEN NORMAL NORMAL)], + [qw(DYELLOW NORMAL NORMAL)], + [qw(GREEN DGREEN NORMAL)], + [qw(GREEN NORMAL NORMAL)], [qw(MAGENTA NORMAL NORMAL)], [qw(RED NORMAL NORMAL)], # for light backgrounds [qw(BLACK DGREY NORMAL)], - [qw(DBLUE DGREY NORMAL )], + [qw(DBLUE DGREY NORMAL)], [qw(DBLUE DMAGENTA NORMAL)], - [qw(DBLUE DRED NORMAL )], + [qw(DBLUE DRED NORMAL)], [qw(DBLUE BLACK NORMAL)], - [qw(DGREEN DYELLOW NORMAL )], + [qw(DGREEN DYELLOW NORMAL)], [qw(DYELLOW BLACK NORMAL)], [qw(DMAGENTA BLACK NORMAL)], [qw(DCYAN DBLUE NORMAL)], # for dark backgrounds [qw(WHITE GREY NORMAL)], [qw(GREY WHITE NORMAL)], - [qw(CYAN GREY NORMAL )], - [qw(GREEN WHITE NORMAL )], - [qw(GREEN YELLOW NORMAL )], - [qw(YELLOW WHITE NORMAL )], - [qw(MAGENTA CYAN NORMAL )], + [qw(CYAN GREY NORMAL)], + [qw(GREEN WHITE NORMAL)], + [qw(GREEN YELLOW NORMAL)], + [qw(YELLOW WHITE NORMAL)], + [qw(MAGENTA CYAN NORMAL)], [qw(MAGENTA YELLOW NORMAL)], [qw(RED CYAN NORMAL)], - [qw(RED WHITE NORMAL )], + [qw(RED WHITE NORMAL)], [qw(BLUE WHITE NORMAL)], # miscellaneous - [qw(RED BLUE NORMAL )], + [qw(RED BLUE NORMAL)], [qw(RED DBLUE NORMAL)], [qw(BLACK BLUE NORMAL)], [qw(BLACK DBLUE NORMAL)], @@ -762,10 +764,10 @@ sub get_color_scheme { [qw(MAGENTA DBLUE NORMAL)], ); eval $end if $b_log; - if ($type eq 'count' ){ + if ($type eq 'count'){ return scalar @color_schemes; } - if ($type eq 'full' ){ + if ($type eq 'full'){ return @color_schemes; } else { @@ -778,7 +780,7 @@ sub set_color_scheme { eval $start if $b_log; my ($scheme) = @_; $colors{'scheme'} = $scheme; - my $index = ( $b_irc ) ? 1 : 0; # defaults to non irc + my $index = ($b_irc) ? 1 : 0; # defaults to non irc # NOTE: qw(...) kills the escape, it is NOT the same as using # Literal "..", ".." despite docs saying it is. @@ -832,14 +834,14 @@ sub set_colors { $color_scheme = $colors{'global'}; } else { - if ( $b_irc ){ + if ($b_irc){ if (defined $colors{'irc-virt-term'} && $b_display && $client{'console-irc'}){ $color_scheme = $colors{'irc-virt-term'}; } elsif (defined $colors{'irc-console'} && !$b_display){ $color_scheme = $colors{'irc-console'}; } - elsif ( defined $colors{'irc-gui'}) { + elsif (defined $colors{'irc-gui'}){ $color_scheme = $colors{'irc-gui'}; } } @@ -853,7 +855,7 @@ sub set_colors { } } # force 0 for | or > output, all others prints to irc or screen - if (!$b_irc && ! -t STDOUT ){ + if (!$b_irc && ! -t STDOUT){ $color_scheme = 0; } set_color_scheme($color_scheme); @@ -881,7 +883,7 @@ sub select_schema { set_status(); start_selector(); create_color_selections(); - if (! $b_irc ){ + if (!$b_irc){ Configs::check_file(); get_selection(); } @@ -928,7 +930,7 @@ sub assign_selectors { } sub start_selector { my $whoami = getpwuid($<) || "unknown???"; - if ( ! $b_irc ){ + if (!$b_irc){ @data = ( [ 0, '', '', "Welcome to $self_name! Please select the default $configs{'selection'} color scheme."], @@ -944,7 +946,7 @@ sub start_selector { 3-dark^backgrounds; 4-miscellaneous"], [ 0, '', '', ""], ); - if ( ! $b_irc ){ + if (!$b_irc){ push(@data, [ 0, '', '', "Please note that this will set the $configs{'selection'} preferences only for user: $whoami"], @@ -963,7 +965,7 @@ sub create_color_selections { if ($i > 9){ $spacer = '^'; } - if ($configs{'selection'} =~ /^(global|irc-gui|irc-console|irc-virt-term)$/ && $i > $safe_color_count ){ + if ($configs{'selection'} =~ /^(global|irc-gui|irc-console|irc-virt-term)$/ && $i > $safe_color_count){ last; } main::set_color_scheme($i); @@ -1002,7 +1004,7 @@ sub get_selection { @data = (); my $response = ; chomp($response); - if (!main::is_int($response) || $response > ($count + 3) ){ + if (!main::is_int($response) || $response > ($count + 3)){ @data = ( [0, '', '', "Error - Invalid Selection. You entered this: $response. Hit to continue."], [0, '', '', "$line1"], @@ -1023,7 +1025,7 @@ sub get_selection { } sub process_selection { my $response = shift; - if ($response == ($count + 3) ){ + if ($response == ($count + 3)){ @data = ( [0, '', '', "Ok, exiting $self_name now. You can set the colors later."], ); @@ -1036,10 +1038,10 @@ sub process_selection { [0, '', '', "$line1"], ); main::print_basic(\@data); - if ( defined $colors{'console'} && !$b_display ){ + if (defined $colors{'console'} && !$b_display){ main::set_color_scheme($colors{'console'}); } - if ( defined $colors{'virt-term'} ){ + if (defined $colors{'virt-term'}){ main::set_color_scheme($colors{'virt-term'}); } else { @@ -1073,9 +1075,9 @@ sub process_selection { } sub delete_all_colors { my @file_lines = main::reader($user_config_file); - open( $w_fh, '>', $user_config_file ) or main::error_handler('open', $user_config_file, $!); - foreach ( @file_lines ) { - if ( $_ !~ /^(CONSOLE_COLOR_SCHEME|GLOBAL_COLOR_SCHEME|IRC_COLOR_SCHEME|IRC_CONS_COLOR_SCHEME|IRC_X_TERM_COLOR_SCHEME|VIRT_TERM_COLOR_SCHEME)/){ + open($w_fh, '>', $user_config_file) or main::error_handler('open', $user_config_file, $!); + foreach (@file_lines){ + if ($_ !~ /^(CONSOLE_COLOR_SCHEME|GLOBAL_COLOR_SCHEME|IRC_COLOR_SCHEME|IRC_CONS_COLOR_SCHEME|IRC_X_TERM_COLOR_SCHEME|VIRT_TERM_COLOR_SCHEME)/){ print {$w_fh} "$_"; } } @@ -1083,9 +1085,9 @@ sub delete_all_colors { } sub delete_global_color { my @file_lines = main::reader($user_config_file); - open( $w_fh, '>', $user_config_file ) or main::error_handler('open', $user_config_file, $!); - foreach ( @file_lines ) { - if ( $_ !~ /^GLOBAL_COLOR_SCHEME/){ + open($w_fh, '>', $user_config_file) or main::error_handler('open', $user_config_file, $!); + foreach (@file_lines){ + if ($_ !~ /^GLOBAL_COLOR_SCHEME/){ print {$w_fh} "$_"; } } @@ -1095,15 +1097,15 @@ sub set_config_color_scheme { my $value = shift; my @file_lines = main::reader($user_config_file); my $b_found = 0; - open( $w_fh, '>', $user_config_file ) or main::error_handler('open', $user_config_file, $!); - foreach ( @file_lines ) { - if ( $_ =~ /^$configs{'variable'}/ ){ + open($w_fh, '>', $user_config_file) or main::error_handler('open', $user_config_file, $!); + foreach (@file_lines){ + if ($_ =~ /^$configs{'variable'}/){ $_ = "$configs{'variable'}=$value"; $b_found = 1; } print $w_fh "$_\n"; } - if (! $b_found ){ + if (!$b_found){ print $w_fh "$configs{'variable'}=$value\n"; } close $w_fh; @@ -1150,9 +1152,9 @@ sub set { } # Config files should be passed in an array as a param to this function. # Default intended use: global @CONFIGS; - foreach (@config_files) { + foreach (@config_files){ next unless open(my $fh, '<', "$_"); - while (<$fh>) { + while (<$fh>){ chomp; s/#.*//; s/^\s+//; @@ -1174,66 +1176,66 @@ sub set { # args: 0: key; 1: value sub process_item { my ($key,$val) = @_; - if ($key eq 'ALLOW_UPDATE' || $key eq 'B_ALLOW_UPDATE') { + if ($key eq 'ALLOW_UPDATE' || $key eq 'B_ALLOW_UPDATE'){ $use{'update'} = $val if main::is_int($val)} - elsif ($key eq 'ALLOW_WEATHER' || $key eq 'B_ALLOW_WEATHER') { + elsif ($key eq 'ALLOW_WEATHER' || $key eq 'B_ALLOW_WEATHER'){ $use{'weather'} = $val if main::is_int($val)} - elsif ($key eq 'CPU_SLEEP') { + elsif ($key eq 'CPU_SLEEP'){ $cpu_sleep = $val if main::is_numeric($val)} - elsif ($key eq 'DL_TIMEOUT') { + elsif ($key eq 'DL_TIMEOUT'){ $dl_timeout = $val if main::is_int($val)} - elsif ($key eq 'DOWNLOADER') { + elsif ($key eq 'DOWNLOADER'){ if ($val =~ /^(curl|fetch|ftp|perl|wget)$/){ # this dumps all the other data and resets %dl for only the # desired downloader. $val = main::set_perl_downloader($val); %dl = ('dl' => $val, $val => 1); }} - elsif ($key eq 'FILTER_STRING') { + elsif ($key eq 'FILTER_STRING'){ $filter_string = $val} - elsif ($key eq 'LANGUAGE') { + elsif ($key eq 'LANGUAGE'){ $language = $val if $val =~ /^(en)$/} - elsif ($key eq 'LIMIT') { + elsif ($key eq 'LIMIT'){ $limit = $val if main::is_int($val)} - elsif ($key eq 'OUTPUT_TYPE') { + elsif ($key eq 'OUTPUT_TYPE'){ $output_type = $val if $val =~ /^(json|screen|xml)$/} - elsif ($key eq 'NO_DIG') { + elsif ($key eq 'NO_DIG'){ $force{'no-dig'} = $val if main::is_int($val)} - elsif ($key eq 'NO_DOAS') { + elsif ($key eq 'NO_DOAS'){ $force{'no-doas'} = $val if main::is_int($val)} - elsif ($key eq 'NO_HTML_WAN') { + elsif ($key eq 'NO_HTML_WAN'){ $force{'no-html-wan'} = $val if main::is_int($val)} - elsif ($key eq 'NO_SUDO') { + elsif ($key eq 'NO_SUDO'){ $force{'no-sudo'} = $val if main::is_int($val)} - elsif ($key eq 'PARTITION_SORT') { + elsif ($key eq 'PARTITION_SORT'){ if ($val =~ /^(dev-base|fs|id|label|percent-used|size|uuid|used)$/){ $show{'partition-sort'} = $val; }} - elsif ($key eq 'PS_COUNT') { + elsif ($key eq 'PS_COUNT'){ $ps_count = $val if main::is_int($val) } - elsif ($key eq 'SENSORS_CPU_NO') { + elsif ($key eq 'SENSORS_CPU_NO'){ $sensors_cpu_nu = $val if main::is_int($val)} - elsif ($key eq 'SENSORS_EXCLUDE') { + elsif ($key eq 'SENSORS_EXCLUDE'){ @sensors_exclude = split(/\s*,\s*/, $val) if $val} - elsif ($key eq 'SENSORS_USE') { + elsif ($key eq 'SENSORS_USE'){ @sensors_use = split(/\s*,\s*/, $val) if $val} - elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST') { + elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST'){ if (main::is_int($val)){ $show{'host'} = $val; $show{'no-host'} = 1 if !$show{'host'}; } } - elsif ($key eq 'USB_SYS') { + elsif ($key eq 'USB_SYS'){ $force{'usb-sys'} = $val if main::is_int($val)} - elsif ($key eq 'WAN_IP_URL') { + elsif ($key eq 'WAN_IP_URL'){ if ($val =~ /^(ht|f)tp[s]?:\//i){ $wan_url = $val; $force{'no-dig'} = 1; } } - elsif ($key eq 'WEATHER_SOURCE') { + elsif ($key eq 'WEATHER_SOURCE'){ $weather_source = $val if main::is_int($val)} - elsif ($key eq 'WEATHER_UNIT') { + elsif ($key eq 'WEATHER_UNIT'){ $val = lc($val) if $val; if ($val && $val =~ /^(c|f|cf|fc|i|m|im|mi)$/){ my %units = ('c'=>'m','f'=>'i','cf'=>'mi','fc'=>'im'); @@ -1242,45 +1244,45 @@ sub process_item { } } # layout - elsif ($key eq 'CONSOLE_COLOR_SCHEME') { + elsif ($key eq 'CONSOLE_COLOR_SCHEME'){ $colors{'console'} = $val if main::is_int($val)} - elsif ($key eq 'GLOBAL_COLOR_SCHEME') { + elsif ($key eq 'GLOBAL_COLOR_SCHEME'){ $colors{'global'} = $val if main::is_int($val)} - elsif ($key eq 'IRC_COLOR_SCHEME') { + elsif ($key eq 'IRC_COLOR_SCHEME'){ $colors{'irc-gui'} = $val if main::is_int($val)} - elsif ($key eq 'IRC_CONS_COLOR_SCHEME') { + elsif ($key eq 'IRC_CONS_COLOR_SCHEME'){ $colors{'irc-console'} = $val if main::is_int($val)} - elsif ($key eq 'IRC_X_TERM_COLOR_SCHEME') { + elsif ($key eq 'IRC_X_TERM_COLOR_SCHEME'){ $colors{'irc-virt-term'} = $val if main::is_int($val)} - elsif ($key eq 'VIRT_TERM_COLOR_SCHEME') { + elsif ($key eq 'VIRT_TERM_COLOR_SCHEME'){ $colors{'virt-term'} = $val if main::is_int($val)} # note: not using the old short SEP1/SEP2 - elsif ($key eq 'SEP1_IRC') { + elsif ($key eq 'SEP1_IRC'){ $sep{'s1-irc'} = $val} - elsif ($key eq 'SEP1_CONSOLE') { + elsif ($key eq 'SEP1_CONSOLE'){ $sep{'s1-console'} = $val} - elsif ($key eq 'SEP2_IRC') { + elsif ($key eq 'SEP2_IRC'){ $sep{'s2-irc'} = $val} - elsif ($key eq 'SEP2_CONSOLE') { + elsif ($key eq 'SEP2_CONSOLE'){ $sep{'s2-console'} = $val} # size - elsif ($key eq 'COLS_MAX_CONSOLE') { + elsif ($key eq 'COLS_MAX_CONSOLE'){ $size{'console'} = $val if main::is_int($val)} - elsif ($key eq 'COLS_MAX_IRC') { + elsif ($key eq 'COLS_MAX_IRC'){ $size{'irc'} = $val if main::is_int($val)} - elsif ($key eq 'COLS_MAX_NO_DISPLAY') { + elsif ($key eq 'COLS_MAX_NO_DISPLAY'){ $size{'no-display'} = $val if main::is_int($val)} - elsif ($key eq 'INDENT') { + elsif ($key eq 'INDENT'){ $size{'indent'} = $val if main::is_int($val)} - elsif ($key eq 'WRAP_MAX' || $key eq 'INDENT_MIN') { + elsif ($key eq 'WRAP_MAX' || $key eq 'INDENT_MIN'){ $size{'wrap-max'} = $val if main::is_int($val)} # print "mc: key: $key val: $val\n"; # print Dumper (keys %size) . "\n"; } sub check_file { $user_config_file = "$user_config_dir/$self_name.conf"; - if ( ! -f $user_config_file ){ - open( my $fh, '>', $user_config_file ) or + if (! -f $user_config_file){ + open(my $fh, '>', $user_config_file) or main::error_handler('create', $user_config_file, $!); } } @@ -1306,9 +1308,9 @@ sub begin_logging { my $now = strftime "%Y-%m-%d %H:%M:%S", localtime; return if $debugger{'timers'}; # do the rotation if logfile exists - if ( -f $log_file ){ + if (-f $log_file){ # copy if present second to third - if ( -f $log_file_2 ){ + if (-f $log_file_2){ rename $log_file_2, $log_file_3 or error_handler('rename', "$log_file_2 -> $log_file_3", "$!"); } # then copy initial to second @@ -1338,12 +1340,12 @@ sub begin_logging { # arg: $one type (fs/fe/cat/dump/raw) or logged data; # [$two is function name; [$three - function args]] sub log_data { - return if ! $b_log; + return if !$b_log; my ($one, $two, $three) = @_; my ($args,$data,$timer) = ('','',''); my $spacer = ' '; # print "1: $one 2: $two 3: $three\n"; - if ($one eq 'fs') { + if ($one eq 'fs'){ if (ref $three eq 'ARRAY'){ # print Data::Dumper::Dumper $three; $args = "\n${spacer}Args: " . joiner($three, '; ', 'unset'); @@ -1359,7 +1361,7 @@ sub log_data { $spacer=''; $timer = $data if $debugger{'timers'}; } - elsif ( $one eq 'fe') { + elsif ($one eq 'fe'){ # print 'timer:', Time::HiRes::tv_interval(\@t0, [Time::HiRes::gettimeofday()]),"\n"; #$t3 = tv_interval ($t0, [gettimeofday]); eval '$t3 = Time::HiRes::tv_interval(\@t0, [Time::HiRes::gettimeofday()])' if $b_hires; @@ -1368,10 +1370,10 @@ sub log_data { $spacer=''; $timer = $data if $debugger{'timers'}; } - elsif ( $one eq 'cat') { - if ( $b_log_full ){ + elsif ($one eq 'cat'){ + if ($b_log_full){ foreach my $file ($two){ - my $contents = do { local( @ARGV, $/ ) = $file; <> }; # or: qx(cat $file) + my $contents = do { local(@ARGV, $/) = $file; <> }; # or: qx(cat $file) $data = "$data${line3}Full file data: $file\n\n$contents\n$line3\n"; } $spacer=''; @@ -1384,7 +1386,7 @@ sub log_data { elsif ($one eq 'data'){ $data = "$two\n"; } - elsif ( $one eq 'dump') { + elsif ($one eq 'dump'){ $data = "$two:\n"; if (ref $three eq 'HASH'){ $data .= Data::Dumper::Dumper $three; @@ -1399,8 +1401,8 @@ sub log_data { $data .= "\n"; # print $data; } - elsif ( $one eq 'raw') { - if ( $b_log_full ){ + elsif ($one eq 'raw'){ + if ($b_log_full){ $data = "\n${line3}Raw System Data:\n\n$two\n$line3"; $spacer=''; } @@ -1419,7 +1421,7 @@ sub log_data { sub set_debugger { user_debug_test_1() if $debugger{'test-1'}; - if ( $debugger{'level'} >= 20){ + if ($debugger{'level'} >= 20){ error_handler('not-in-irc', 'debug data generator') if $b_irc; my $option = ($debugger{'level'} > 22) ? 'main-full' : 'main'; $debugger{'gz'} = 1 if ($debugger{'level'} == 22 || $debugger{'level'} == 24); @@ -1518,10 +1520,10 @@ sub run_debugger { if (!$b_debug){ # note: android has unreadable /sys, but -x and -r tests pass # main::globber('/sys/*') && - if ( $debugger{'sys'} && main::count_dir_files('/sys') ){ + if ($debugger{'sys'} && main::count_dir_files('/sys')){ build_tree('sys'); # kernel crash, not sure what creates it, for ppc, as root - sys_traverse_data() if ($debugger{'sys'} && ($debugger{'sys-force'} || !$b_root || !$b_ppc )) ; + sys_traverse_data() if ($debugger{'sys'} && ($debugger{'sys-force'} || !$b_root || !$b_ppc)) ; } else { print "Skipping /sys data collection.\n"; @@ -1529,7 +1531,7 @@ sub run_debugger { print $line3; # note: proc has some files that are apparently kernel processes, I've tried # filtering them out but more keep appearing, so only run proc debugger if not root - if ( !$debugger{'no-proc'} && (!$b_root || $debugger{'proc'} ) && -d '/proc' && main::count_dir_files('/proc') ){ + if (!$debugger{'no-proc'} && (!$b_root || $debugger{'proc'}) && -d '/proc' && main::count_dir_files('/proc')){ build_tree('proc'); proc_traverse_data(); } @@ -1552,30 +1554,30 @@ sub create_debug_directory { my ($sec,$min,$hour,$mday,$mon,$year) = localtime; $year = $year+1900; $mon += 1; - if (length($sec) == 1) {$sec = "0$sec";} - if (length($min) == 1) {$min = "0$min";} - if (length($hour) == 1) {$hour = "0$hour";} - if (length($mon) == 1) {$mon = "0$mon";} - if (length($mday) == 1) {$mday = "0$mday";} + if (length($sec) == 1){$sec = "0$sec";} + if (length($min) == 1){$min = "0$min";} + if (length($hour) == 1){$hour = "0$hour";} + if (length($mon) == 1){$mon = "0$mon";} + if (length($mday) == 1){$mday = "0$mday";} my $today = "$year-$mon-${mday}_$hour$min$sec"; # my $date = strftime "-%Y-%m-%d_", localtime; if ($b_root){ $root_string = '-root'; } $bsd_string = "-BSD-$bsd_type" if $bsd_type; - my $id = ($debugger{'id'} ) ? '-' . $debugger{'id'}: ''; - if ($b_arm ){$alt_string = '-ARM'} - elsif ($b_mips) {$alt_string = '-MIPS'} - elsif ($b_ppc) {$alt_string = '-PPC'} - elsif ($b_sparc) {$alt_string = '-SPARC'} + my $id = ($debugger{'id'}) ? '-' . $debugger{'id'}: ''; + if ($b_arm){$alt_string = '-ARM'} + elsif ($b_mips){$alt_string = '-MIPS'} + elsif ($b_ppc){$alt_string = '-PPC'} + elsif ($b_sparc){$alt_string = '-SPARC'} $debug_dir = "$self_name$alt_string$bsd_string-$host$id-$today$root_string-$self_version-$self_patch"; $debug_gz = "$debug_dir.tar.gz"; $data_dir = "$user_data_dir/$debug_dir"; - if ( -d $data_dir ){ + if (-d $data_dir){ unlink $data_dir or main::error_handler('remove', "$data_dir", "$!"); } mkdir $data_dir or main::error_handler('mkdir', "$data_dir", "$!"); - if ( -e "$user_data_dir/$debug_gz" ){ + if (-e "$user_data_dir/$debug_gz"){ #rmdir "$user_data_dir$debug_gz" or main::error_handler('remove', "$user_data_dir/$debug_gz", "$!"); print "Failed removing leftover directory:\n$user_data_dir$debug_gz error: $?" if system('rm','-rf',"$user_data_dir$debug_gz"); } @@ -1588,7 +1590,7 @@ sub compress_dir { print "Removing $data_dir...\n"; #rmdir $data_dir or print "failed removing: $data_dir error: $!\n"; return 1 if !$b_delete_dir; - if (system('rm','-rf',$data_dir) ){ + if (system('rm','-rf',$data_dir)){ print "Failed removing: $data_dir\nError: $?\n"; } else { @@ -1669,6 +1671,7 @@ sub disk_data { copy_files(\@files, 'disk'); my @cmds = ( ['blockdev', '--report'], + ['btrfs', 'fi show'], ['btrfs', 'filesystem show'], ['btrfs', 'filesystem show --mounted'], # ['btrfs', 'filesystem show --all-devices'], @@ -1713,8 +1716,11 @@ sub disk_data { ['lsblk', '-r'], ['lsblk', '-r --output NAME,PKNAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS'], ['lsblk', '-rb --output NAME,PKNAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS'], + ['lsblk', '-rb --output NAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,SERIAL,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS,MAJ:MIN,PKNAME'], ['lsblk', '-Pb --output NAME,PKNAME,TYPE,RM,FSTYPE,SIZE'], ['lsblk', '-Pb --output NAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,SERIAL,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS'], + # this should always be the live command used internally: + ['lsblk', '-bP --output NAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,SERIAL,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS,MAJ:MIN,PKNAME'], ['lvdisplay', '-c'], ['lvdisplay', '-cv'], ['lvdisplay', '-cv --segments'], @@ -1784,16 +1790,16 @@ sub disk_data { sub display_data { my (%data,@files,@files2); my $working = ''; - if ( ! $b_display ){ + if (!$b_display){ print "Warning: only some of the data collection can occur if you are not in X\n"; main::toucher("$data_dir/display-data-warning-user-not-in-x"); } - if ( $b_root ){ + if ($b_root){ print "Warning: only some of the data collection can occur if you are running as Root user\n"; main::toucher("$data_dir/display-data-warning-root-user"); } print "Collecting Xorg log and xorg.conf files...\n"; - if ( -d "/etc/X11/xorg.conf.d/" ){ + if (-d "/etc/X11/xorg.conf.d/"){ @files = main::globber("/etc/X11/xorg.conf.d/*"); } else { @@ -1907,7 +1913,7 @@ sub perl_modules { foreach (@modules){ my $dir = $_; $dir =~ s/[^\/]+$//; - if (!$holder || $holder ne $dir ){ + if (!$holder || $holder ne $dir){ $holder = $dir; $value = "DIR: $dir\n"; $_ =~ s/^$dir//; @@ -2104,7 +2110,7 @@ sub copy_files { my ($absent,$error,$good,$name,$unreadable); my $directory = ($alt_dir) ? $alt_dir : $data_dir; my $working = ($type ne 'proc') ? "$type-file-": ''; - foreach (@$files_ref) { + foreach (@$files_ref){ $name = $_; $name =~ s/^\///; $name =~ s/\//~/g; @@ -2115,7 +2121,7 @@ sub copy_files { $error = $name . '-error'; $unreadable = $name . '-unreadable'; # proc have already been tested for readable/exists - if ($type eq 'proc' || -e $_ ) { + if ($type eq 'proc' || -e $_){ print "F:$_\n" if $type eq 'proc' && $debugger{'proc-print'}; if ($type eq 'proc' || -r $_){ copy($_,"$good") or main::toucher($error); @@ -2162,14 +2168,14 @@ sub run_commands { sub write_data { my ($data_ref, $type) = @_; my ($empty,$error,$fh,$good,$name,$undefined,$value); - foreach (keys %$data_ref) { + foreach (keys %$data_ref){ $value = $data_ref->{$_}; $name = "$data_dir/$type-data-$_"; $good = $name . '.txt'; $empty = $name . '-empty'; $error = $name . '-error'; $undefined = $name . '-undefined'; - if (defined $value) { + if (defined $value){ if ($value || $value eq '0'){ open($fh, '>', $good) or main::toucher($error); print $fh "$value"; @@ -2186,7 +2192,7 @@ sub write_data { ## TOOLS FOR DIRECTORY TREE/LS/TRAVERSE; UPLOADER sub build_tree { my ($which) = @_; - if ( $which eq 'sys' && main::check_program('tree') ){ + if ($which eq 'sys' && main::check_program('tree')){ print "Constructing /$which tree data...\n"; my $dirname = '/sys'; my $cmd; @@ -2208,7 +2214,7 @@ sub build_tree { directory_ls($which,3); directory_ls($which,4); } - elsif ($which eq 'proc') { + elsif ($which eq 'proc'){ directory_ls('proc',1); directory_ls('proc',2,'[a-z]'); # don't want the /proc/self or /proc/thread-self directories, those are @@ -2220,31 +2226,31 @@ sub build_tree { # include is basic regex for ls path syntax, like [a-z] sub directory_ls { - my ( $dir,$depth,$include) = @_; + my ($dir,$depth,$include) = @_; $include ||= ''; my ($exclude) = (''); # wd do NOT want to see anything in self or thread-self!! # $exclude = 'I self -I thread-self' if $dir eq 'proc'; my $cmd = do { - if ( $depth == 1 ){ "ls -l $exclude /$dir/$include 2>/dev/null" } - elsif ( $depth == 2 ){ "ls -l $exclude /$dir/$include*/ 2>/dev/null" } - elsif ( $depth == 3 ){ "ls -l $exclude /$dir/$include*/*/ 2>/dev/null" } - elsif ( $depth == 4 ){ "ls -l $exclude /$dir/$include*/*/*/ 2>/dev/null" } - elsif ( $depth == 5 ){ "ls -l $exclude /$dir/$include*/*/*/*/ 2>/dev/null" } - elsif ( $depth == 6 ){ "ls -l $exclude /$dir/$include*/*/*/*/*/ 2>/dev/null" } + if ($depth == 1){ "ls -l $exclude /$dir/$include 2>/dev/null" } + elsif ($depth == 2){ "ls -l $exclude /$dir/$include*/ 2>/dev/null" } + elsif ($depth == 3){ "ls -l $exclude /$dir/$include*/*/ 2>/dev/null" } + elsif ($depth == 4){ "ls -l $exclude /$dir/$include*/*/*/ 2>/dev/null" } + 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 $output = ''; my ($type); my $result = qx($cmd); open(my $ch, '<', \$result) or main::error_handler('open-data',"$cmd", "$!"); - while ( my $line = <$ch> ){ + while (my $line = <$ch>){ chomp($line); $line =~ s/^\s+|\s+$//g; @working = split(/\s+/, $line); $working[0] ||= ''; - if ( scalar @working > 7 ){ - if ($working[0] =~ /^d/ ){ + if (scalar @working > 7){ + if ($working[0] =~ /^d/){ $type = "d - "; } elsif ($working[0] =~ /^l/){ @@ -2257,7 +2263,7 @@ sub directory_ls { $working[10] ||= ''; $output = $output . " $type$working[8] $working[9] $working[10]\n"; } - elsif ( $working[0] !~ /^total/ ){ + elsif ($working[0] !~ /^total/){ $output = $output . $line . "\n"; } } @@ -2312,7 +2318,7 @@ sub process_sys_traverse { open($fh, '<', $_) or $b_fh = 0; # needed for removing -T test and root if ($b_fh){ - while ($row = <$fh>) { + while ($row = <$fh>){ chomp($row); $data .= $sep . '"' . $row . '"'; $sep=', '; @@ -2376,7 +2382,7 @@ sub wanted { # the readable tests in copy_files() # return unless -T; } - elsif ($parse_src eq 'proc') { + elsif ($parse_src eq 'proc'){ return if $File::Find::name =~ m!(/mb_groups|debug)$!; } # print $File::Find::name . "\n"; @@ -2405,7 +2411,7 @@ sub upload_file { # print "$host $domain $dir $user $pass\n"; print "File to be uploaded:\n$file_path\n"; - if ($host && ( $file_path && -e $file_path ) ){ + if ($host && ($file_path && -e $file_path)){ # NOTE: important: must explicitly set to passive true/1 $ftp = Net::FTP->new($host, Debug => 0, Passive => 1) || main::error_handler('ftp-connect', $ftp->message); $ftp->login($user, $pass) || main::error_handler('ftp-login', $ftp->message); @@ -2463,7 +2469,7 @@ sub download_file { $dl{'no-ssl-opt'} ||= ''; $dl{'spider'} ||= ''; $file ||= 'N/A'; # to avoid debug error - if ( ! $dl{'dl'} ){ + if (!$dl{'dl'}){ return 0; } if ($dl{'timeout'}){ @@ -2473,7 +2479,7 @@ sub download_file { # print "$dl{'dl'}\n"; # tiny supports spider sort of ## NOTE: 1 is success, 0 false for Perl - if ($dl{'dl'} eq 'tiny' ){ + if ($dl{'dl'} eq 'tiny'){ $cmd = "Using tiny: type: $type \nurl: $url \nfile: $file"; $result = get_file($type, $url, $file); $debug_data = ($type ne 'stdout') ? $result : 'Success: stdout data not null.'; @@ -2488,14 +2494,14 @@ sub download_file { $result = qx($cmd); $debug_data = ($result) ? 'Success: stdout data not null.' : 'Download resulted in null data!'; } - elsif ($type eq 'file') { + elsif ($type eq 'file'){ $args = $dl{'file'}; $cmd = "$dl{'dl'} $dl{'no-ssl-opt'} $ua $timeout $args $file \"$url\" $dl{'null'}"; system($cmd); $result = ($?) ? 0 : 1; # reverse these into Perl t/f $debug_data = $result; } - elsif ( $dl{'dl'} eq 'wget' && $type eq 'spider'){ + elsif ($dl{'dl'} eq 'wget' && $type eq 'spider'){ $cmd = "$dl{'dl'} $dl{'no-ssl-opt'} $ua $timeout $dl{'spider'} \"$url\""; system($cmd); $result = ($?) ? 0 : 1; # reverse these into Perl t/f @@ -2519,7 +2525,7 @@ sub get_file { $file ||= 'N/A'; log_data('dump','%{$response}',$response) if $b_log; # print Dumper $response; - if ( ! $response->{'success'} ){ + if (!$response->{'success'}){ my $content = $response->{'content'}; $content ||= "N/A\n"; my $msg = "Failed to connect to server/file!\n"; @@ -2532,13 +2538,13 @@ sub get_file { if ($debug){ print "$response->{success}\n"; print "$response->{status} $response->{reason}\n"; - while (my ($key, $value) = each %{$response->{'headers'}}) { - for (ref $value eq "ARRAY" ? @$value : $value) { + while (my ($key, $value) = each %{$response->{'headers'}}){ + for (ref $value eq "ARRAY" ? @$value : $value){ print "$key: $_\n"; } } } - if ( $type eq "stdout" || $type eq "ua-stdout" ){ + if ($type eq "stdout" || $type eq "ua-stdout"){ $return = $response->{'content'}; } elsif ($type eq "spider"){ @@ -2579,7 +2585,7 @@ sub set_downloader { $dl{'stdout'} = ''; $dl{'timeout'} = ''; } - elsif ( $dl{'curl'} && check_program('curl') ){ + elsif ($dl{'curl'} && check_program('curl')){ $quiet = '-s ' if !$dbg[1]; $dl{'dl'} = 'curl'; $dl{'file'} = " -L ${quiet}-o "; @@ -2588,7 +2594,7 @@ sub set_downloader { $dl{'timeout'} = ' -y '; $dl{'ua'} = ' -A ' . $dl_ua; } - elsif ($dl{'wget'} && check_program('wget') ){ + elsif ($dl{'wget'} && check_program('wget')){ $quiet = '-q ' if !$dbg[1]; $dl{'dl'} = 'wget'; $dl{'file'} = " ${quiet}-O "; @@ -2607,7 +2613,7 @@ sub set_downloader { $dl{'timeout'} = ' -T '; } # at least openbsd/netbsd - elsif ($bsd_type && check_program('ftp') ){ + elsif ($bsd_type && check_program('ftp')){ $dl{'dl'} = 'ftp'; $dl{'file'} = ' -o '; $dl{'null'} = ' 2>/dev/null'; @@ -2634,73 +2640,73 @@ sub set_perl_downloader { sub error_handler { eval $start if $b_log; - my ( $err, $one, $two) = @_; + my ($err,$one,$two) = @_; my ($b_help,$b_recommends); my ($b_exit,$errno) = (1,0); my $message = do { - if ( $err eq 'empty' ) { 'empty value' } + if ($err eq 'empty'){ 'empty value' } ## Basic rules - elsif ( $err eq 'not-in-irc' ) { + elsif ($err eq 'not-in-irc'){ $errno=1; "You can't run option $one in an IRC client!" } ## Internal/external options - elsif ( $err eq 'bad-arg' ) { + elsif ($err eq 'bad-arg'){ $errno=10; $b_help=1; "Unsupported value: $two for option: $one" } - elsif ( $err eq 'bad-arg-int' ) { + elsif ($err eq 'bad-arg-int'){ $errno=11; "Bad internal argument: $one" } - elsif ( $err eq 'distro-block' ) { + elsif ($err eq 'distro-block'){ $errno=20; "Option: $one has been disabled by the $self_name distribution maintainer." } - elsif ( $err eq 'option-feature-incomplete' ) { + elsif ($err eq 'option-feature-incomplete'){ $errno=21; "Option: '$one' feature: '$two' has not been implemented yet." } - elsif ( $err eq 'unknown-option' ) { + elsif ($err eq 'unknown-option'){ $errno=22; $b_help=1; "Unsupported option: $one" } ## Data - elsif ( $err eq 'open-data' ) { + elsif ($err eq 'open-data'){ $errno=32; "Error opening data for reading: $one \nError: $two" } - elsif ( $err eq 'download-error' ) { + elsif ($err eq 'download-error'){ $errno=33; "Error downloading file with $dl{'dl'}: $one \nError: $two" } ## Files: - elsif ( $err eq 'copy-failed' ) { + elsif ($err eq 'copy-failed'){ $errno=40; "Error copying file: $one \nError: $two" } - elsif ( $err eq 'create' ) { + elsif ($err eq 'create'){ $errno=41; "Error creating file: $one \nError: $two" } - elsif ( $err eq 'downloader-error' ) { + elsif ($err eq 'downloader-error'){ $errno=42; "Error downloading file: $one \nfor download source: $two" } - elsif ( $err eq 'file-corrupt' ) { + elsif ($err eq 'file-corrupt'){ $errno=43; "Downloaded file is corrupted: $one" } - elsif ( $err eq 'mkdir' ) { + elsif ($err eq 'mkdir'){ $errno=44; "Error creating directory: $one \nError: $two" } - elsif ( $err eq 'open' ) { + elsif ($err eq 'open'){ $errno=45; $b_exit=0; "Error opening file: $one \nError: $two" } - elsif ( $err eq 'open-dir' ) { + elsif ($err eq 'open-dir'){ $errno=46; "Error opening directory: $one \nError: $two" } - elsif ( $err eq 'output-file-bad' ) { + elsif ($err eq 'output-file-bad'){ $errno=47; "Value for --output-file must be full path, a writable directory, \nand include file name. Path: $two" } - elsif ( $err eq 'not-writable' ) { + elsif ($err eq 'not-writable'){ $errno=48; "The file: $one is not writable!" } - elsif ( $err eq 'open-dir-failed' ) { + elsif ($err eq 'open-dir-failed'){ $errno=49; "The directory: $one failed to open with error: $two" } - elsif ( $err eq 'remove' ) { + elsif ($err eq 'remove'){ $errno=50; "Failed to remove file: $one Error: $two" } - elsif ( $err eq 'rename' ) { + elsif ($err eq 'rename'){ $errno=51; "There was an error moving files: $one\nError: $two" } - elsif ( $err eq 'write' ) { + elsif ($err eq 'write'){ $errno=52; "Failed writing file: $one - Error: $two!" } ## Downloaders - elsif ( $err eq 'missing-downloader' ) { + elsif ($err eq 'missing-downloader'){ $errno=60; "Downloader program $two could not be located on your system." } - elsif ( $err eq 'missing-perl-downloader' ) { + elsif ($err eq 'missing-perl-downloader'){ $errno=61; $b_recommends=1; "Perl downloader missing required module." } ## FTP - elsif ( $err eq 'ftp-bad-path' ) { + elsif ($err eq 'ftp-bad-path'){ $errno=70; "Unable to locate for FTP upload file:\n$one" } - elsif ( $err eq 'ftp-connect' ) { + elsif ($err eq 'ftp-connect'){ $errno=71; "There was an error with connection to ftp server: $one" } - elsif ( $err eq 'ftp-login' ) { + elsif ($err eq 'ftp-login'){ $errno=72; "There was an error with login to ftp server: $one" } - elsif ( $err eq 'ftp-upload' ) { + elsif ($err eq 'ftp-upload'){ $errno=73; "There was an error with upload to ftp server: $one" } ## Modules - elsif ( $err eq 'required-module' ) { + elsif ($err eq 'required-module'){ $errno=80; $b_recommends=1; "The required $one Perl module is not installed:\n$two" } ## DEFAULT else { @@ -2901,7 +2907,7 @@ sub check_items { else { @data = qw(/etc/lsb-release /etc/os-release /proc/asound/cards /proc/asound/version /proc/cpuinfo /proc/mdstat /proc/meminfo /proc/modules - /proc/mounts /proc/scsi/scsi /var/log/Xorg.0.log ); + /proc/mounts /proc/scsi/scsi /var/log/Xorg.0.log); } $b_file = 1; $item = 'File'; @@ -2926,8 +2932,8 @@ sub check_items { $about = ''; %info = item_data($item); $about = $info{$info_os}; - if ( ( $b_dir && -d $item ) || ( $b_file && -r $item ) || - ($b_program && main::check_program($item) ) || + if (($b_dir && -d $item) || ($b_file && -r $item) || + ($b_program && main::check_program($item)) || ($b_perl_module && main::check_perl_module($item)) || ($b_kernel_module && @modules && (grep {/^$item$/} @modules))){ $result = 'Present'; @@ -2950,13 +2956,13 @@ sub check_items { $rows[scalar @rows] = ['0', '', '', " "]; if (@missing){ $rows[scalar @rows] = ['0', '', '', "The following $type are missing$extra4:"]; - foreach (@missing) { + foreach (@missing){ $rows[scalar @rows] = ['0', '', '', "$item: $_"]; } } if (@unreadable){ $rows[scalar @rows] = ['0', '', '', "The following $type are not readable: "]; - foreach (@unreadable) { + foreach (@unreadable){ $rows[scalar @rows] = ['0', '', '', "$item: $_"]; } } @@ -3479,7 +3485,7 @@ sub make_row { } sub make_line { my $line = ''; - foreach (0 .. $size{'max'} - 2 ){ + foreach (0 .. $size{'max'} - 2){ $line .= '-'; } return $line; @@ -3589,7 +3595,7 @@ sub get_piece { $string =~ s/^\s+|\s+$//g; my @temp = split(/$sep/, $string); eval $end if $b_log; - if ( exists $temp[$num] ){ + if (exists $temp[$num]){ $temp[$num] =~ s/,//g; return $temp[$num]; } @@ -3639,7 +3645,7 @@ sub is_int { # receives string, returns boolean 1 if numeric. tr/// is 4x faster than regex sub is_numeric { - return 1 if ( defined $_[0] && ( $_[0] =~ tr/0123456789//) >= 1 && + return 1 if (defined $_[0] && ($_[0] =~ tr/0123456789//) >= 1 && length($_[0]) == ($_[0] =~ tr/0123456789.//) && ($_[0] =~ tr/.//) <= 1); } @@ -3680,14 +3686,14 @@ sub program_data { eval $start if $b_log; my ($values_id,$version_id,$level) = @_; my (@data,$path,@program_data); - $level = 0 if ! $level; + $level = 0 if !$level; # print "val_id: $values_id ver_id:$version_id lev:$level ex:$extra\n"; - $version_id = $values_id if ! $version_id; + $version_id = $values_id if !$version_id; @data = program_values($values_id); if ($data[3]){ $program_data[0] = $data[3]; # programs that have no version method return 0 0 for index 1 and 2 - if ( $extra >= $level && $data[1] && $data[2]){ + if ($extra >= $level && $data[1] && $data[2]){ $program_data[1] = program_version($version_id,$data[0], $data[1],$data[2],$data[5],$data[6],$data[7],$data[8]); } @@ -3985,8 +3991,8 @@ sub program_version { $num-- if (defined $num && $num > 0); # konvi in particular doesn't like using $ENV{'PATH'} as set, so we need # to always assign the full path if it hasn't already been done - if ( $version ne 'file' && $app !~ /^\// ){ - if (my $program = check_program($app) ){ + if ($version ne 'file' && $app !~ /^\//){ + if (my $program = check_program($app)){ $app = $program; } else { @@ -4012,7 +4018,7 @@ sub program_version { return 0 if !$cmd; } # note, some wm/apps send version info to stderr instead of stdout - elsif ($stderr) { + elsif ($stderr){ $cmd = "$app $version 2>&1"; } else { @@ -4032,7 +4038,7 @@ sub program_version { while (<$ch>){ #chomp; last if $count > $exit; - if ( $_ =~ /$search/i ) { + if ($_ =~ /$search/i){ $_ = trimmer($_); # print "loop: $_ :: num: $num\n"; $_ =~ s/$replace//i if $replace; @@ -4068,7 +4074,7 @@ sub program_version_cmd { eval $start if $b_log; my ($app,$app_name,$extra) = @_; my @data = ('',0); - if ($app_name eq 'cicada') { + if ($app_name eq 'cicada'){ $data[0] = $app . ' -c "' . $extra . '" 2>/dev/null';} elsif ($app_name =~ /^(|l|lo|m|pd)ksh(93)?$/){ $data[0] = $app . ' -c \'printf %s "$KSH_VERSION"\' 2>/dev/null'; @@ -4086,15 +4092,15 @@ sub program_version_pkg { my ($app) = @_; my ($program,@data); # note: version $num is 3 in dpkg-query/pacman/rpm, which is convenient - if ($program = check_program('dpkg-query') ){ + if ($program = check_program('dpkg-query')){ $data[0] = "$program -W -f='\${Package}\tversion\t\${Version}\n' $app 2>/dev/null"; $data[1] = "^$app\\b"; } - elsif ($program = check_program('pacman') ){ + elsif ($program = check_program('pacman')){ $data[0] = "$program -Q --info $app 2>/dev/null"; $data[1] = '^Version'; } - elsif ($program = check_program('rpm') ){ + elsif ($program = check_program('rpm')){ $data[0] = "$program -qi --nodigest --nosignature $app 2>/dev/null"; $data[1] = '^Version'; } @@ -4110,8 +4116,8 @@ sub program_version_pkg { sub reader { eval $start if $b_log; my ($file,$strip,$index) = @_; - return if ! $file; - open(my $fh, '<', $file ) or error_handler('open', $file, $!); + return if !$file; + open(my $fh, '<', $file) or error_handler('open', $file, $!); chomp(my @rows = <$fh>); close $fh if $fh; if (@rows && $strip){ @@ -4131,8 +4137,8 @@ sub reader { # args: 1 - the file to create if not exists sub toucher { my $file = shift; - if ( ! -e $file ){ - open( my $fh, '>', $file ) or error_handler('create', $file, $!); + if (! -e $file){ + open(my $fh, '>', $file) or error_handler('create', $file, $!); } } @@ -4191,7 +4197,7 @@ sub get_defaults { 'pinxi-man' => "https://smxi.org/in/$self_name.1", 'pinxi-man-gh' => "https://github.com/smxi/inxi/raw/inxi-perl/$self_name.1", ); - if ( exists $defaults{$type}){ + if (exists $defaults{$type}){ return $defaults{$type}; } else { @@ -4204,7 +4210,7 @@ sub get_defaults { # note that 1 must end in / to properly construct the url path sub update_me { eval $start if $b_log; - my ( $self_download, $download_id ) = @_; + my ($self_download,$download_id) = @_; my $downloader_error=1; my $file_contents=''; my $output = ''; @@ -4212,10 +4218,10 @@ sub update_me { $self_download =~ s/\/$//; # dirname sometimes ends with /, sometimes not my $full_self_path = "$self_path/$self_name"; - if ( $b_irc ){ - error_handler('not-in-irc', "-U/--update" ) + if ($b_irc){ + error_handler('not-in-irc', "-U/--update") } - if ( ! -w $full_self_path ){ + if (! -w $full_self_path){ error_handler('not-writable', "$self_name", ''); } $output .= "Starting $self_name self updater.\n"; @@ -4233,11 +4239,11 @@ sub update_me { if ($file_contents){ # make sure the whole file got downloaded and is in the variable print "Validating downloaded data...\n"; - if ( $file_contents =~ /###\*\*EOF\*\*###/ ){ + if ($file_contents =~ /###\*\*EOF\*\*###/){ open(my $fh, '>', $full_self_path); - print $fh $file_contents or error_handler('write', $full_self_path, "$!" ); + print $fh $file_contents or error_handler('write', $full_self_path, "$!"); close $fh; - qx( chmod +x '$self_path/$self_name' ); + qx(chmod +x '$self_path/$self_name'); set_version_data(); $output .= "Successfully updated to $download_id version: $self_version\n"; $output .= "New $download_id version patch number: $self_patch\n"; @@ -4272,21 +4278,21 @@ sub update_man { my $man_file_path = "$man_file_location/$self_name.1" ; my ($file_contents,$man_file_url,$output,$program) = ('','','',''); print "Starting download of man page file now.\n"; - if ( ! -d $man_file_location ){ + if (! -d $man_file_location){ print "The required man directory was not detected on your system.\n"; print "Unable to continue: $man_file_location\n"; return 0; } - if ( ! -w $man_file_location ){ + if (! -w $man_file_location){ print "Cannot write to $man_file_location! Root privileges required.\n"; print "Unable to continue: $man_file_location\n"; return 0; } - if ( -f "/usr/share/man/man8/inxi.8.gz" ){ + if (-f "/usr/share/man/man8/inxi.8.gz"){ print "Updating man page location to man1.\n"; rename "/usr/share/man/man8/inxi.8.gz", "$man_file_location/inxi.1.gz"; - if ( check_program('mandb') ){ - system( 'mandb' ); + if (check_program('mandb')){ + system('mandb'); } } if (!($program = check_program('gzip'))){ @@ -4308,10 +4314,10 @@ sub update_man { if ($file_contents){ # make sure the whole file got downloaded and is in the variable print "Download successful. Validating downloaded man file data...\n"; - if ( $file_contents =~ m|\.\\" EOF|) { + if ($file_contents =~ m|\.\\" EOF|){ print "Contents validated. Writing to man location...\n"; open(my $fh, '>', $man_file_path); - print $fh $file_contents or error_handler('write', $man_file_path, "$!" ); + print $fh $file_contents or error_handler('write', $man_file_path, "$!"); close $fh; print "Writing successful. Compressing file...\n"; system("$program -9 -f $man_file_path > $man_file_path.gz"); @@ -4342,22 +4348,22 @@ sub set_man_location { my $man_paths=qx(man --path 2>/dev/null); my $man_local='/usr/local/share/man'; my $b_use_local=0; - if ( $man_paths && $man_paths =~ /$man_local/ ){ + if ($man_paths && $man_paths =~ /$man_local/){ $b_use_local=1; } # for distro installs - if ( -f "$default_location/inxi.1.gz" ){ + if (-f "$default_location/inxi.1.gz"){ $location=$default_location; } else { - if ( $b_use_local ){ - if ( ! -d "$man_local/man1" ){ + if ($b_use_local){ + if (! -d "$man_local/man1"){ mkdir "$man_local/man1"; } $location="$man_local/man1"; } } - if ( ! $location ){ + if (!$location){ $location=$default_location; } return $location; @@ -4368,19 +4374,19 @@ sub set_man_location { # the values from the UPDATED file, NOT the running program! sub set_version_data { open(my $fh, '<', "$self_path/$self_name"); - while( my $row = <$fh>){ + while (my $row = <$fh>){ chomp($row); $row =~ s/'|;//g; - if ($row =~ /^my \$self_name/ ){ + if ($row =~ /^my \$self_name/){ $self_name = (split('=', $row))[1]; } - elsif ($row =~ /^my \$self_version/ ){ + elsif ($row =~ /^my \$self_version/){ $self_version = (split('=', $row))[1]; } - elsif ($row =~ /^my \$self_date/ ){ + elsif ($row =~ /^my \$self_date/){ $self_date = (split('=', $row))[1]; } - elsif ($row =~ /^my \$self_patch/ ){ + elsif ($row =~ /^my \$self_patch/){ $self_patch = (split('=', $row))[1]; } elsif ($row =~ /^## END INXI INFO/){ @@ -4427,10 +4433,10 @@ sub get { $show{'battery-forced'} = 1; }, 'c|color:i' => sub { my ($opt,$arg) = @_; - if ( $arg >= 0 && $arg < main::get_color_scheme('count') ){ + if ($arg >= 0 && $arg < main::get_color_scheme('count')){ main::set_color_scheme($arg); } - elsif ( $arg >= 94 && $arg <= 99 ){ + elsif ($arg >= 94 && $arg <= 99){ $colors{'selector'} = $arg; } else { @@ -4489,14 +4495,12 @@ sub get { $show{'info'} = 1; }, 'j|swap|swaps' => sub { $show{'short'} = 0; - $show{'swap'} = 1; }, + $show{'swap'} = 1;}, 'J|usb' => sub { $show{'short'} = 0; $show{'usb'} = 1; }, 'l|labels|label' => sub { - $show{'short'} = 0; - $show{'label'} = 1; - $show{'partition'} = 1; }, + $show{'label'} = 1;}, 'limit:i' => sub { my ($opt,$arg) = @_; if ($arg != 0){ @@ -4578,7 +4582,7 @@ sub get { $arg ||= 'cm'; my $num = $arg; $num =~ s/^[cm]+// if $num; - if ( $arg =~ /^([cm]+)([0-9]+)?$/ && (!$num || $num =~ /^\d+/) ){ + if ($arg =~ /^([cm]+)([0-9]+)?$/ && (!$num || $num =~ /^\d+/)){ $show{'process'} = 1; if ($arg =~ /c/){ $show{'ps-cpu'} = 1; @@ -4592,17 +4596,15 @@ sub get { main::error_handler('bad-arg',$opt,$arg); } }, 'u|uuid' => sub { - $show{'short'} = 0; - $show{'partition'} = 1; - $show{'uuid'} = 1; }, + $show{'uuid'} = 1;}, 'v|verbosity:i' => sub { my ($opt,$arg) = @_; $show{'short'} = 0; - if ( $arg =~ /^[0-8]$/ ){ - if ($arg == 0 ){ + if ($arg =~ /^[0-8]$/){ + if ($arg == 0){ $show{'short'} = 1; } - if ($arg >= 1 ){ + if ($arg >= 1){ $show{'cpu-basic'} = 1; $show{'disk-total'} = 1; $show{'graphic'} = 1; @@ -4610,23 +4612,23 @@ sub get { $show{'info'} = 1; $show{'system'} = 1; } - if ($arg >= 2 ){ + if ($arg >= 2){ $show{'battery'} = 1; $show{'disk-basic'} = 1; $show{'raid-basic'} = 1; $show{'machine'} = 1; $show{'network'} = 1; } - if ($arg >= 3 ){ + if ($arg >= 3){ $show{'network-advanced'} = 1; $show{'cpu'} = 1; $extra = 1; } - if ($arg >= 4 ){ + if ($arg >= 4){ $show{'disk'} = 1; $show{'partition'} = 1; } - if ($arg >= 5 ){ + if ($arg >= 5){ $show{'audio'} = 1; $show{'bluetooth'} = 1; $show{'ram'} = 1; @@ -4638,14 +4640,14 @@ sub get { $show{'swap'} = 1; $show{'uuid'} = 1; } - if ($arg >= 6 ){ + if ($arg >= 6){ $show{'optical'} = 1; $show{'partition-full'} = 1; $show{'unmounted'} = 1; $show{'usb'} = 1; $extra = 2; } - if ($arg >= 7 ){ + if ($arg >= 7){ $use{'downloader'} = 1 if !main::check_program('dig'); $show{'battery-forced'} = 1; $show{'bluetooth-forced'} = 1; @@ -4655,7 +4657,7 @@ sub get { $show{'raid-forced'} = 1; $extra = 3; } - if ($arg >= 8 ){ + if ($arg >= 8){ $b_admin = 1; $use{'downloader'} = 1; $show{'process'} = 1; @@ -4675,7 +4677,7 @@ sub get { my ($opt) = @_; $show{'short'} = 0; $use{'downloader'} = 1; - if ( $use{'weather'} ){ + if ($use{'weather'}){ $show{'weather'} = 1; } else { @@ -4732,14 +4734,14 @@ sub get { } }, 'y|width:i' => sub { my ($opt, $arg) = @_; - if( defined $arg && $arg == -1){ + if (defined $arg && $arg == -1){ $arg = 2000; } # note: :i creates 0 value if not supplied even though means optional elsif (!$arg){ $arg = 80; } - if ( $arg =~ /\d/ && ($arg == 1 || $arg >= 80) ){ + if ($arg =~ /\d/ && ($arg == 1 || $arg >= 80)){ main::set_display_width($arg); } else { @@ -4756,19 +4758,19 @@ sub get { ## Start non data options 'alt:i' => sub { my ($opt,$arg) = @_; - if ($arg == 40) { + if ($arg == 40){ $dl{'tiny'} = 0; $use{'downloader'} = 1;} - elsif ($arg == 41) { + elsif ($arg == 41){ $dl{'curl'} = 0; $use{'downloader'} = 1;} - elsif ($arg == 42) { + elsif ($arg == 42){ $dl{'fetch'} = 0; $use{'downloader'} = 1;} - elsif ($arg == 43) { + elsif ($arg == 43){ $dl{'wget'} = 0; $use{'downloader'} = 1;} - elsif ($arg == 44) { + elsif ($arg == 44){ $dl{'curl'} = 0; $dl{'fetch'} = 0; $dl{'wget'} = 0; @@ -4799,7 +4801,7 @@ sub get { }, 'dbg:i' => sub { my ($opt,$arg) = @_; - if ($arg > 0) { + if ($arg > 0){ $dbg[$arg] = 1; } else { @@ -4873,10 +4875,10 @@ sub get { $arg = lc($arg); if ($arg =~ /^(curl|fetch|ftp|perl|wget)$/){ if ($arg eq 'perl' && (!main::check_perl_module('HTTP::Tiny') || - !main::check_perl_module('IO::Socket::SSL') )){ + !main::check_perl_module('IO::Socket::SSL'))){ main::error_handler('missing-perl-downloader', $opt, $arg); } - elsif ( !main::check_program($arg)) { + elsif (!main::check_program($arg)){ main::error_handler('missing-downloader', $opt, $arg); } else { @@ -4894,8 +4896,8 @@ sub get { my ($opt,$arg) = @_; if ($arg){ my $wl = 'bluetooth|compiler|cpu|dboot|dmidecode|ipmi|logical|pciconf|'; - $wl .= 'pcictl|pcidump|raid-hw|raid-lvm|raid-md|raid-soft|raid-zfs|'; - $wl .= 'sensors|sysctl|uptime|usbconfig|usbdevs|vmstat|xorg-log'; + $wl .= 'pcictl|pcidump|raid-btrfs|raid-hw|raid-lvm|raid-md|raid-soft|'; + $wl .= 'raid-zfs|sensors|sysctl|uptime|usbconfig|usbdevs|vmstat|xorg-log'; for (split(',',$arg)){ if ($_ =~ /\b($wl)\b/){ $fake{lc($1)} = 1; @@ -4928,7 +4930,7 @@ sub get { 'ftp:s' => sub { my ($opt,$arg) = @_; # pattern: ftp.x.x/x - if ($arg =~ /^ftp\..+\..+\/[^\/]+$/ ){ + if ($arg =~ /^ftp\..+\..+\/[^\/]+$/){ $ftp_alt = $arg; } else { @@ -5041,7 +5043,7 @@ sub get { }}, '<>' => sub { my ($opt) = @_; - main::error_handler('unknown-option', "$opt", "" );} + main::error_handler('unknown-option', "$opt", "");} ); # or error_handler('unknown-option', "@ARGV", ''); # run all these after so that we can change widths, downloaders, etc # print Data::Dumper::Dumper \%trigger; @@ -5083,6 +5085,10 @@ sub post_process { main::error_handler('bad-arg', '--output', '--output-file not provided'); } } + if (($show{'label'} || $show{'uuid'}) && !$show{'partition'} && + !$show{'partition-full'} && !$show{'swap'} && !$show{'unmounted'}){ + main::error_handler('bad-arg', '-l/-u', 'missing required option(s) -j, -o, -p, -P'); + } $show{'graphic-basic'} = 0 if $b_admin; if ($use{'sensors-default'}){ @sensors_exclude = (); @@ -5095,6 +5101,7 @@ sub post_process { } if ($show{'raid'} || $show{'disk'} || $show{'disk-total'} || $show{'disk-basic'} || $show{'unmounted'}){ + $use{'btrfs'} = 1; $use{'mdadm'} = 1; } if ($b_admin && $show{'disk'}){ @@ -5114,20 +5121,20 @@ sub post_process { $show{'partition'} = 0 if $show{'partition-full'}; $show{'host'} = 0 if $show{'no-host'}; $show{'host'} = 1 if ($show{'host'} || (!$use{'filter'} && !$show{'no-host'})); - if ($show{'disk'} || $show{'optical'} ){ + if ($show{'disk'} || $show{'optical'}){ $show{'disk-basic'} = 0; $show{'disk-total'} = 0; } if ($show{'ram'} || $show{'slot'} || ($show{'cpu'} && ($extra > 1 || $bsd_type)) || - (( $bsd_type || $force{'dmidecode'}) && ($show{'machine'} || $show{'battery'}))){ + (($bsd_type || $force{'dmidecode'}) && ($show{'machine'} || $show{'battery'}))){ $use{'dmidecode'} = 1; } if ($show{'audio'} || $show{'bluetooth'} || $show{'graphic'} || - $show{'network'} || $show{'raid'} ){ + $show{'network'} || $show{'raid'}){ $use{'pci'} = 1; } if ($show{'usb'} || $show{'audio'} || $show{'bluetooth'} || - $show{'graphic'} || $show{'network'} ){ + $show{'graphic'} || $show{'network'}){ $use{'usb'} = 1; } if ($bsd_type){ @@ -5185,11 +5192,11 @@ sub process_updater { $use{'man'} = 1; $use{'yes-man'} = 1; } - elsif ( $arg =~ /^[12]$/){ + elsif ($arg =~ /^[12]$/){ $download_id = "branch $arg"; $self_download = main::get_defaults("inxi-branch-$arg"); } - elsif ( $arg =~ /^http/){ + elsif ($arg =~ /^http/){ $download_id = 'alt server'; $self_download = $arg; } @@ -5212,12 +5219,12 @@ sub show_options { my $partition_string='partition'; my $partition_string_u='Partition'; my $flags = ($b_arm) ? 'features' : 'flags' ; - if ( $bsd_type ){ + if ($bsd_type){ $partition_string='slice'; $partition_string_u='Slice'; } # fit the line to the screen! - for my $i ( 0 .. ( ( $size{'max'} / 2 ) - 2 ) ){ + for my $i (0 .. (($size{'max'} / 2) - 2)){ $line = $line . '- '; } push(@data, @@ -5274,8 +5281,7 @@ sub show_options { IRC client or shell type, $self_name version." ], ['1', '-j', '--swap', "Swap in use. Includes ${partition_string}s, zram, file." ], ['1', '-J', '--usb', "Show USB data: Hubs and Devices." ], - ['1', '-l', '--label', "$partition_string_u labels. Triggers -P. - For full -p output, use -pl." ], + ['1', '-l', '--label', "$partition_string_u labels. Use with -j, -o, -p, -P." ], ['1', '-L', '--logical', "Logical devices, LVM (VG, LV), LUKS, Crypto, bcache, etc. Shows components/devices, sizes, etc." ], ['1', '-m', '--memory', "Memory (RAM) data. Requires root. Numbers of @@ -5319,8 +5325,7 @@ sub show_options { of processes for each type (default: 5; if in IRC, max: 5). " ], ['1', '', '', "Make sure that there is no space between letters and numbers (e.g.^-t^cm10)." ], - ['1', '-u', '--uuid', "$partition_string_u UUIDs. Triggers -P. For full -p - output, use -pu." ], + ['1', '-u', '--uuid', "$partition_string_u UUIDs. Use with -j, -o, -p, -P." ], ['1', '-v', '--verbosity', "Set $self_name verbosity level (0-8). Should not be used with -b or -F. Example: $self_name^-v^4" ], ['2', '0', '', "Same as: $self_name" ], @@ -5344,7 +5349,7 @@ sub show_options { processes (-tcm), PCI slots (--slots); triggers admin (-a)."], ); # if distro maintainers don't want the weather feature disable it - if ( $use{'weather'} ){ + if ($use{'weather'}){ push(@data, ['1', '-w', '--weather', "Local weather data/time. To check an alternate location, see -W. NO AUTOMATED QUERIES OR EXCESSIVE USE ALLOWED!"], @@ -5453,7 +5458,7 @@ sub show_options { ['2', '-t', '', "Adds memory use output to CPU (-xt c), and CPU use to memory (-xt m)." ], ); - if ( $use{'weather'} ){ + if ($use{'weather'}){ push(@data, ['2', '-w,-W', '', "Wind speed and direction, humidity, pressure, and time zone, if available." ]); @@ -5494,7 +5499,7 @@ sub show_options { if available (Xfce/KDE/Trinity only)." ], ['2', '--slots', '', "Slot length." ], ); - if ( $use{'weather'} ){ + if ($use{'weather'}){ push(@data, ['2', '-w,-W', '', "Snow, rain, precipitation, (last observed hour), cloud cover, wind chill, dew point, heat index, if available." ] @@ -5508,7 +5513,7 @@ sub show_options { ['2', '-B', '', "Chemistry, cycles, location (if available)." ], ['2', '-C', '', "CPU voltage, external clock speed (if root and dmidecode installed)." ], ['2', '-D', '', "Firmware rev. if available; partition scheme, in some cases; disk - rotation speed/SSD (if detected)." ], + type, rotation rpm (if available)." ], ['2', '-E', '', "Serial number, class ID, HCI version and revision." ], ['2', '-G', '', "Serial number, class ID." ], ['2', '-I', '', "For 'Shell:' adds ([doas|su|sudo|login]) to shell name if present; @@ -5526,7 +5531,7 @@ sub show_options { xfce4-panel, mate-panel); (if available) dm version number, window manager version number, virtual terminal number."], ); - if ( $use{'weather'} ){ + if ($use{'weather'}){ push(@data, ['2', '-w,-W', '', "Location (uses -z/irc filter), weather observation time, altitude, sunrise/sunset, if available." ] @@ -5540,7 +5545,7 @@ sub show_options { and directories, then shows what package(s) you need to install to add support for that feature." ], ); - if ( $use{'update'} ){ + if ($use{'update'}){ push(@data, ['1', '-U', '--update', "Auto-update $self_name. Will also install/update man page. Note: if you installed as root, you must be root to update, otherwise @@ -5581,7 +5586,7 @@ sub show_options { ['1', '', '--limit', "[-1; 1-x] Set max output limit of IP addresses for -i (default 10; -1 removes limit)." ], ); - if ( $use{'update'} ){ + if ($use{'update'}){ push(@data, ['1', '', '--man', "Install correct man version for dev branch (-U 3) or pinxi using -U." ], ); @@ -5595,7 +5600,7 @@ sub show_options { ['1', '', '--no-html-wan', "Skip HTML IP sources for WAN IP checks, use dig only, or nothing if --no-dig." ], ); - if ( $use{'update'} ){ + if ($use{'update'}){ push(@data, ['1', '', '--no-man', "Disable man install for all -U update actions." ], ); @@ -5674,17 +5679,17 @@ sub show_version { my $working_path=$self_path; my (@data,$link,$self_string); Cwd->import('getcwd'); # no point loading this on top use, we only use getcwd here - if ( $working_path eq '.' ){ + if ($working_path eq '.'){ $working_path = getcwd(); } - elsif ( $working_path !~ /^\// ){ + elsif ($working_path !~ /^\//){ $working_path = getcwd() . "/$working_path"; } $working_path =~ s%/$%%; # handle if it's a symbolic link, rare, but can happen with directories # in irc clients which would only matter if user starts inxi with -! 30 override # in irc client - if ( -l "$working_path/$self_name" ){ + if (-l "$working_path/$self_name"){ $link="$working_path/$self_name"; $working_path = readlink "$working_path/$self_name"; $working_path =~ s/[^\/]+$//; @@ -5692,7 +5697,7 @@ sub show_version { # strange output /./ ending, but just trim it off, I don't know how it happens $working_path =~ s%/\./%/%; push(@data, [ 0, '', '', "$self_name $self_version-$self_patch ($self_date)"]); - if ( ! $b_irc ){ + if (!$b_irc){ push(@data, [ 0, '', '', '']); my $year = (split/-/, $self_date)[0]; push(@data, @@ -5701,7 +5706,7 @@ sub show_version { [ 0, '', '', "Using Perl version: $]"], [ 0, '', '', "Program Location: $working_path" ], ); - if ( $link ){ + if ($link){ push(@data, [ 0, '', '', "Started via symbolic link: $link" ]); } push(@data, @@ -5761,7 +5766,7 @@ sub get_client_name { eval $start if $b_log; my $client_name = ''; # print "$ppid\n"; - if ($ppid && -e "/proc/$ppid/exe" ){ + if ($ppid && -e "/proc/$ppid/exe"){ $client_name = lc(readlink "/proc/$ppid/exe"); $client_name =~ s/^.*\///; if ($client_name =~ /^(bash|csh|dash|fish|sh|python.*|perl.*|zsh)$/){ @@ -5769,7 +5774,7 @@ sub get_client_name { # my @temp = (main::grabber("ps -wwp $ppid -o ppid 2>/dev/null"))[1]; $pppid =~ s/^\s+|\s+$//g; $client_name =~ s/[0-9\.]+$//; # clean things like python2.7 - if ($pppid && -f "/proc/$pppid/exe" ){ + if ($pppid && -f "/proc/$pppid/exe"){ $client_name = lc(readlink "/proc/$pppid/exe"); $client_name =~ s/^.*\///; $client{'native'} = 0; @@ -5819,11 +5824,11 @@ sub get_client_version { $client{'name-print'} = $app[3]; $client{'console-irc'} = $app[4]; } - if ($client{'name'} =~ /^(bash|csh|fish|dash|sh|zsh)$/ ){ + if ($client{'name'} =~ /^(bash|csh|fish|dash|sh|zsh)$/){ $client{'name-print'} = 'shell wrapper'; $client{'console-irc'} = 1; } - elsif ($client{'name'} eq 'bitchx') { + elsif ($client{'name'} eq 'bitchx'){ @data = main::grabber("$client{'name'} -v"); $string = awk(\@data,'Version'); if ($string){ @@ -5838,28 +5843,28 @@ sub get_client_version { # so we need to read the actual config file for hexchat. Note that older hexchats # used xchat config file, so test first for default, then legacy. Because it's possible # for this file to be user edited, doing some extra checks here. - elsif ($client{'name'} eq 'hexchat') { - if ( -f '~/.config/hexchat/hexchat.conf' ){ + elsif ($client{'name'} eq 'hexchat'){ + if (-f '~/.config/hexchat/hexchat.conf'){ @data = main::reader('~/.config/hexchat/hexchat.conf','strip'); } - elsif ( -f '~/.config/hexchat/xchat.conf' ){ + elsif (-f '~/.config/hexchat/xchat.conf'){ @data = main::reader('~/.config/hexchat/xchat.conf','strip'); } if (@data){ $client{'version'} = main::awk(\@data,'version',2,'\s*=\s*'); } # fingers crossed, hexchat won't open gui!! - if (!$client{'version'}) { + if (!$client{'version'}){ @data = main::grabber("$client{'name'} --version 2>/dev/null"); $client{'version'} = main::awk(\@data,'hexchat',2,'\s+'); } $client{'name-print'} = 'HexChat'; } # note: see legacy inxi konvi logic if we need to restore any of the legacy code. - elsif ($client{'name'} eq 'konversation') { - $client{'konvi'} = ( ! $client{'native'} ) ? 2 : 1; + elsif ($client{'name'} eq 'konversation'){ + $client{'konvi'} = (!$client{'native'}) ? 2 : 1; } - elsif ($client{'name'} =~ /quassel/i) { + elsif ($client{'name'} =~ /quassel/i){ @data = main::grabber("$client{'name'} -v 2>/dev/null"); foreach (@data){ if ($_ =~ /^Quassel IRC:/){ @@ -5874,7 +5879,7 @@ sub get_client_version { $client{'version'} ||= '(pre v0.4.1)?'; } # then do some perl type searches, do this last since it's a wildcard search - elsif ($client{'name'} =~ /^(perl.*|ksirc|dsirc)$/ ) { + elsif ($client{'name'} =~ /^(perl.*|ksirc|dsirc)$/){ my @cmdline = main::get_cmdline(); # Dynamic runpath detection is too complex with KSirc, because KSirc is started from # kdeinit. /proc//exe is a link to /usr/bin/kdeinit @@ -5885,7 +5890,7 @@ sub get_client_version { # KSirc was run by browsing up the process tree in /proc. That alone is straightjacket material. # (KSirc sucks anyway ;) foreach (@cmdline){ - if ( $_ =~ /dsirc/ ){ + if ($_ =~ /dsirc/){ $client{'version'} = main::program_version('ksirc','KSirc:',2,'-v',0,0); $client{'name'} = 'ksirc'; $client{'name-print'} = 'KSirc'; @@ -5894,12 +5899,12 @@ sub get_client_version { $client{'console-irc'} = 1; perl_python_client(); } - elsif ($client{'name'} =~ /python/) { + elsif ($client{'name'} =~ /python/){ perl_python_client(); } # NOTE: these must be empirically determined, not all events that # show no tty are actually IRC. tmux is not a vt, but runs inside one - if (!$client{'name-print'}) { + if (!$client{'name-print'}){ my $wl_terms = 'alacritty|altyo|black-screen|conhost|doas|evilvte|'; $wl_terms .= 'germinal|guake|havoc|hyper|kate|kitty|kmscon|konsole|login|'; $wl_terms .= 'macwise|minicom|putty|rxvt|sakura|securecrt|shellinabox|'; @@ -5927,11 +5932,11 @@ sub get_cmdline { eval $start if $b_log; my @cmdline; my $i = 0; - if (! -e "/proc/$ppid/cmdline" ){ + if (! -e "/proc/$ppid/cmdline"){ return 1; } local $\ = ''; - open( my $fh, '<', "/proc/$ppid/cmdline" ) or + open(my $fh, '<', "/proc/$ppid/cmdline") or print_line("Open /proc/$ppid/cmdline failed: $!"); my @rows = <$fh>; close $fh; @@ -5940,7 +5945,7 @@ sub get_cmdline { $i++; last if $i > 31; } - if ( $i == 0 ){ + if ($i == 0){ $cmdline[0] = $rows[0]; $i = ($cmdline[0]) ? 1 : 0; } @@ -5954,8 +5959,8 @@ sub perl_python_client { # this is a hack to try to show konversation if inxi is running but started via /cmd # OR via program shortcuts, both cases in fact now # main::print_line("konvi: " . scalar grep { $_ =~ /konversation/ } @ps_cmd); - if ( $b_display && main::check_program('konversation') && - ( grep { $_ =~ /konversation/ } @ps_cmd )){ + if ($b_display && main::check_program('konversation') && + (grep { $_ =~ /konversation/ } @ps_cmd)){ @app = main::program_values('konversation'); $client{'version'} = main::program_version('konversation',$app[0],$app[1],$app[2],$app[5],$app[6]); $client{'name'} = 'konversation'; @@ -5964,18 +5969,18 @@ sub perl_python_client { } ## NOTE: supybot only appears in ps aux using 'SHELL' command; the 'CALL' command ## gives the user system irc priority, and you don't see supybot listed, so use SHELL - elsif ( !$b_display && + elsif (!$b_display && (main::check_program('supybot') || main::check_program('gribble') || main::check_program('limnoria')) && - ( grep { $_ =~ /supybot/ } @ps_cmd ) ){ + (grep { $_ =~ /supybot/ } @ps_cmd)){ @app = main::program_values('supybot'); $client{'version'} = main::program_version('supybot',$app[0],$app[1],$app[2],$app[5],$app[6]); if ($client{'version'}){ - if ( grep { $_ =~ /gribble/ } @ps_cmd ){ + if (grep { $_ =~ /gribble/ } @ps_cmd){ $client{'name'} = 'gribble'; $client{'name-print'} = 'Gribble'; } - if ( grep { $_ =~ /limnoria/ } @ps_cmd){ + if (grep { $_ =~ /limnoria/ } @ps_cmd){ $client{'name'} = 'limnoria'; $client{'name-print'} = 'Limnoria'; } @@ -6004,7 +6009,7 @@ sub perl_python_client { ## and all other irc clients are not running. As of 2014-03-25 this isn't used in my cases sub check_modern_konvi { eval $start if $b_log; - return 0 if ! $client{'qdbus'}; + return 0 if !$client{'qdbus'}; my $b_modern_konvi = 0; my $konvi_version = ''; my $konvi = ''; @@ -6012,7 +6017,7 @@ sub check_modern_konvi { my (@temp); # main::log_data('data',"name: $client{'name'} :: qdb: $client{'qdbus'} :: version: $client{'version'} :: konvi: $client{'konvi'} :: PPID: $ppid") if $b_log; # sabayon uses /usr/share/apps/konversation as path - if ( -d '/usr/share/kde4/apps/konversation' || -d '/usr/share/apps/konversation' ){ + if (-d '/usr/share/kde4/apps/konversation' || -d '/usr/share/apps/konversation'){ $pid = main::awk(\@ps_aux,'konversation -session',2,'\s+'); main::log_data('data',"pid: $pid") if $b_log; $konvi = readlink ("/proc/$pid/exe"); @@ -6040,7 +6045,7 @@ sub check_modern_konvi { ## for testing this module # my $ppid = getppid(); # system('qdbus org.kde.konversation', '/irc', 'say', $client{'dserver'}, $client{'dtarget'}, -# "getpid_dir: $konvi_qt4 verNum: $konvi_version pid: $pid ppid: $ppid" ); +# "getpid_dir: $konvi_qt4 verNum: $konvi_version pid: $pid ppid: $ppid"); eval $end if $b_log; return $b_modern_konvi; } @@ -6049,12 +6054,12 @@ sub set_konvi_data { eval $start if $b_log; my $config_tool = ''; # https://userbase.kde.org/Konversation/Scripts/Scripting_guide - if ( $client{'konvi'} == 3 ){ + if ($client{'konvi'} == 3){ $client{'dserver'} = shift @ARGV; $client{'dtarget'} = shift @ARGV; $client{'dobject'} = 'default'; } - elsif ( $client{'konvi'} == 1 ){ + elsif ($client{'konvi'} == 1){ $client{'dport'} = shift @ARGV; $client{'dserver'} = shift @ARGV; $client{'dtarget'} = shift @ARGV; @@ -6063,13 +6068,13 @@ sub set_konvi_data { # for some reason this logic hiccups on multiple spaces between args @ARGV = grep { $_ ne '' } @ARGV; # there's no current kde 5 konvi config tool that we're aware of. Correct if changes. - if ( main::check_program('kde4-config') ){ + if (main::check_program('kde4-config')){ $config_tool = 'kde4-config'; } - elsif ( main::check_program('kde5-config') ){ + elsif (main::check_program('kde5-config')){ $config_tool = 'kde5-config'; } - elsif ( main::check_program('kde-config') ){ + elsif (main::check_program('kde-config')){ $config_tool = 'kde-config'; } # The section below is on request of Argonel from the Konversation developer team: @@ -6093,7 +6098,7 @@ sub set_konvi_data { sub apply_filter { my ($string) = @_; if ($string){ - $string = ( $use{'filter'} ) ? $filter_string : $string; + $string = ($use{'filter'}) ? $filter_string : $string; } else { $string = 'N/A'; @@ -6105,7 +6110,7 @@ sub apply_filter { sub apply_partition_filter { my ($source,$string,$type) = @_; return $string if !$string || $string eq 'N/A'; - if ($source eq 'system') { + if ($source eq 'system'){ my $test = ($type eq 'label') ? '=LABEL=': '=UUID='; $string =~ s/$test[^\s]+/$test$filter_string/g; } @@ -6128,7 +6133,7 @@ sub clean_characters { # newline, pipe, brackets, + sign, with space, then clear doubled # spaces and then strip out trailing/leading spaces. # etc/issue often has junk stuff like (\l) \n \l - return if ! $data; + return if !$data; $data =~ s/[:\47]|\\[a-z]|\n|,|\"|\*|\||\+|\[\s\]|n\/a|\s\s+/ /g; $data =~ s/\(\s*\)//; $data =~ s/^\s+|\s+$//g; @@ -6230,7 +6235,7 @@ sub get_size { sub increment_starters { my ($key,$indexes) = @_; my $result = $key; - if (defined $indexes->{$key} ){ + if (defined $indexes->{$key}){ $indexes->{$key}++; $result = "$key-$indexes->{$key}"; } @@ -6278,7 +6283,7 @@ sub pci_long_filter { # which can contain regex characters, get rid of those sub regex_cleaner { my ($string) = @_; - return if ! $string; + return if !$string; $string =~ s/(\{|\}|\(|\)|\[|\]|\|)/ /g; $string =~ s/\s\s+/ /g; $string =~ s/^\s+|\s+$//g; @@ -6287,7 +6292,7 @@ sub regex_cleaner { sub remove_duplicates { my ($string) = @_; - return if ! $string; + return if !$string; my $holder = ''; my (@temp); foreach (split(/\s+/, $string)){ @@ -6551,28 +6556,28 @@ sub print_basic { my $length = @$data; my ($start,$i,$j,$line); - if ( $size{'max'} > 110 ){ + if ($size{'max'} > 110){ $indent_static = 22; } - elsif ($size{'max'} < 90 ){ + elsif ($size{'max'} < 90){ $indent_static = 15; } # print $length . "\n"; for my $i (0 .. $#$data){ # print "0: $data->[$i][0]\n"; - if ($data->[$i][0] == 0 ){ + if ($data->[$i][0] == 0){ $indent = 0; $indent1 = 0; $indent2 = 0; } - elsif ($data->[$i][0] == 1 ){ + elsif ($data->[$i][0] == 1){ $indent = $indent_static; $indent1 = $indent1_static; $indent2= $indent2_static; } - elsif ($data->[$i][0] == 2 ){ - $indent = ( $indent_static + 7 ); - $indent1 = ( $indent_static + 5 ); + elsif ($data->[$i][0] == 2){ + $indent = ($indent_static + 7); + $indent1 = ($indent_static + 5); $indent2 = 0; } $data->[$i][3] =~ s/\n/ /g; @@ -6581,13 +6586,13 @@ sub print_basic { $data->[$i][1] = $data->[$i][1] . ', '; } $start = sprintf("%${indent1}s%-${indent2}s",$data->[$i][1],$data->[$i][2]); - if ($indent > 1 && ( length($start) > ( $indent - 1) ) ){ + if ($indent > 1 && (length($start) > ($indent - 1))){ $line = sprintf("%-${indent}s\n", "$start"); print_line($line); $start = ''; # print "1-print.\n"; } - if ( ( $indent + length($data->[$i][3]) ) < $size{'max'} ){ + if (($indent + length($data->[$i][3])) < $size{'max'}){ $data->[$i][3] =~ s/\^/ /g; $line = sprintf("%-${indent}s%s\n", "$start", $data->[$i][3]); print_line($line); @@ -6600,12 +6605,12 @@ sub print_basic { # then splits like awk, on one or more white spaces. foreach my $word (split(' ', $data->[$i][3])){ # print "$word\n"; - if ( ( $indent + length($holder) + length($word) ) < $size{'max'} ) { + if (($indent + length($holder) + length($word)) < $size{'max'}){ $word =~ s/\^/ /g; $holder .= $word . $sep; # print "3-hold.\n"; } - #elsif ( ( $indent + length($holder) + length($word) ) >= $size{'max'}){ + # elsif (($indent + length($holder) + length($word)) >= $size{'max'}){ else { $line = sprintf("%-${indent}s%s\n", "$start", $holder); print_line($line); @@ -6639,14 +6644,14 @@ sub print_data { my ($b_container,$indent_use,$indentx) = (0,0,0); # $size{'max'} = 88; # NOTE: indent < 11 would break the output badly in some cases - if ($size{'max'} < $size{'wrap-max'} || $size{'indent'} < 11 ){ + if ($size{'max'} < $size{'wrap-max'} || $size{'indent'} < 11){ $indent = 2; } - # foreach my $key1 (sort { (split('#', $a))[0] <=> (split('#', $b))[0] } keys %$data) { - foreach my $key1 (sort { substr($a,0,3) <=> substr($b,0,3) } keys %$data) { - # foreach my $key1 (sort { $a cmp $b } keys %$data) { + # foreach my $key1 (sort { (split('#', $a))[0] <=> (split('#', $b))[0] } keys %$data){ + foreach my $key1 (sort { substr($a,0,3) <=> substr($b,0,3) } keys %$data){ + # foreach my $key1 (sort { $a cmp $b } keys %$data){ $key = (split('#', $key1))[3]; - if ($key ne 'SHORT' ) { + if ($key ne 'SHORT'){ $start = sprintf("$colors{'c1'}%-${indent}s$colors{'cn'}","$key$sep{'s1'}"); $start_holder = $key; if ($indent < 10){ @@ -6716,7 +6721,7 @@ sub print_data { # in Perl 5.08 oddly enough. @temp = split(/\s+/, $val2); $split_count = scalar @temp; - if ( !$b_single && ( length( "$key$sep{'s2'} $val2" ) + $length ) < $size{'max'} ) { + if (!$b_single && (length("$key$sep{'s2'} $val2") + $length) < $size{'max'}){ # print "one\n"; $length += length("$key$sep{'s2'} $val2"); $holder .= "$colors{'c1'}$key$sep{'s2'}$colors{'c2'} $val2"; @@ -6724,8 +6729,8 @@ sub print_data { # handle case where the opening key/value pair is > max, and where # there are a lot of terms, like cpu flags, raid types supported. Raid # can have the last row have a lot of devices, or many raid types - elsif ( !$b_single && ( length( "$key$sep{'s2'} $val2" ) + $indent ) > $size{'max'} && - !defined $ids{$key} && $split_count > 2 ) { + elsif (!$b_single && (length("$key$sep{'s2'} $val2") + $indent) > $size{'max'} && + !defined $ids{$key} && $split_count > 2){ # print "two\n"; @values = split(/\s+/, $val2); $val3 = shift @values; @@ -6737,7 +6742,7 @@ sub print_data { foreach (@values){ # my $l = (length("$_ ") + $length); # print "$l\n"; - if ( (length("$_ ") + $length) < $size{'max'} ){ + if ((length("$_ ") + $length) < $size{'max'}){ # print "three.1\n"; # print "a\n"; if ($start2){ @@ -6837,13 +6842,13 @@ sub print_line { $client{'konvi'} = 3; $client{'dobject'} = 'Konversation'; } - if ($client{'konvi'} == 1 && $client{'dcop'} ){ + if ($client{'konvi'} == 1 && $client{'dcop'}){ # konvi doesn't seem to like \n characters, it just prints them literally $line =~ s/\n//g; #qx('dcop "$client{'dport'}" "$client{'dobject'}" say "$client{'dserver'}" "$client{'dtarget'}" "$line 1"); system('dcop', $client{'dport'}, $client{'dobject'}, 'say', $client{'dserver'}, $client{'dtarget'}, "$line 1"); } - elsif ($client{'konvi'} == 3 && $client{'qdbus'} ){ + elsif ($client{'konvi'} == 3 && $client{'qdbus'}){ # print $line; $line =~ s/\n//g; #qx(qdbus org.kde.konversation /irc say "$client{'dserver'}" "$client{'dtarget'}" "$line"); @@ -6880,7 +6885,7 @@ sub get { else { push(@rows,device_output()); } - if (((($b_arm || $b_mips) && !$use{'soc-audio'} && !$use{'pci-tool'}) || !@rows ) && + if (((($b_arm || $b_mips) && !$use{'soc-audio'} && !$use{'pci-tool'}) || !@rows) && (my $file = $system_files{'asound-cards'})){ push(@rows,asound_output($file)); } @@ -6925,7 +6930,7 @@ sub device_output { } $rows[$j]->{main::key($num++,1,2,'driver')} = $driver; if ($extra > 0 && !$bsd_type){ - if ($row->[9] ){ + if ($row->[9]){ my $version = main::get_module_version($row->[9]); $rows[$j]->{main::key($num++,0,3,'v')} = $version if $version; } @@ -6967,7 +6972,7 @@ sub asound_output { foreach (@asound){ # filtering out modems and usb devices like webcams, this might get a # usb audio card as well, this will take some trial and error - if (!/modem|usb/i && /^\s*[0-9]/) { + if (!/modem|usb/i && /^\s*[0-9]/){ $num = 1; my @working = split(/:\s*/, $_); # now let's get 1 2 @@ -7257,7 +7262,7 @@ sub battery_output { } } if ($extra > 0){ - if ($battery->{$key}{'manufacturer'} || $battery->{$key}{'model_name'}) { + if ($battery->{$key}{'manufacturer'} || $battery->{$key}{'model_name'}){ if ($battery->{$key}{'manufacturer'} && $battery->{$key}{'model_name'}){ $model = "$battery->{$key}{'manufacturer'} $battery->{$key}{'model_name'}"; } @@ -7273,7 +7278,7 @@ sub battery_output { } $rows[$j]->{main::key($num++,0,2,'model')} = $model; if ($extra > 2){ - $chemistry = ( $battery->{$key}{'technology'} ) ? $battery->{$key}{'technology'}: 'N/A'; + $chemistry = ($battery->{$key}{'technology'}) ? $battery->{$key}{'technology'}: 'N/A'; $rows[$j]->{main::key($num++,0,2,'type')} = $chemistry; } if ($extra > 1){ @@ -7368,7 +7373,7 @@ sub battery_data_sys { # android shows some files only root readable $value = (-r $path) ? main::reader($path,'',0): ''; # mains, plus in psu - if ($file eq 'type' && $value && lc($value) ne 'battery' ){ + if ($file eq 'type' && $value && lc($value) ne 'battery'){ $battery{$id}->{'purpose'} = 'mains'; } if ($value){ @@ -7412,7 +7417,7 @@ sub battery_data_sys { $value = main::dmi_cleaner($value); } } - elsif ($b_root && -e $path && ! -r $path ){ + elsif ($b_root && -e $path && ! -r $path){ $value = main::row_defaults('root-required'); } $battery{$id}->{$file} = $value; @@ -7424,10 +7429,10 @@ sub battery_data_sys { # if the energy/charge values exist for this item, if so, it's a battery, if not, # it's a device. if ($id =~ /^(BAT|CMB).*$/i || - ( $battery{$id}->{'energy_full'} || $battery{$id}->{'charge_full'} || - $battery{$id}->{'energy_now'} || $battery{$id}->{'charge_now'} || - $battery{$id}->{'energy_full_design'} || $battery{$id}->{'charge_full_design'} ) || - $battery{$id}->{'voltage_min_design'} || $battery{$id}->{'voltage_now'} ){ + ($battery{$id}->{'energy_full'} || $battery{$id}->{'charge_full'} || + $battery{$id}->{'energy_now'} || $battery{$id}->{'charge_now'} || + $battery{$id}->{'energy_full_design'} || $battery{$id}->{'charge_full_design'}) || + $battery{$id}->{'voltage_min_design'} || $battery{$id}->{'voltage_now'}){ $battery{$id}->{'purpose'} = 'primary'; } else { @@ -7528,7 +7533,7 @@ sub battery_data_sysctl { $battery{$id}->{'energy_full_design'} = $battery{$id}->{'charge_full_design'} * $battery{$id}->{'voltage_min_design'}; } } - if ( $battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'} ){ + if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'}){ $battery{$id}->{'of_orig'} = 100 * $battery{$id}->{'energy_full'}/$battery{$id}->{'energy_full_design'}; $battery{$id}->{'of_orig'} = sprintf("%.1f", $battery{$id}->{'of_orig'}); } @@ -7566,25 +7571,25 @@ sub battery_data_dmi { 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] } - elsif ($value[0] eq 'Manufacturer') {$battery{$id}->{'manufacturer'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] =~ /Chemistry/) {$battery{$id}->{'technology'} = $value[1] } - elsif ($value[0] =~ /Serial Number/) {$battery{$id}->{'serial_number'} = $value[1] } - elsif ($value[0] =~ /^Name/) {$battery{$id}->{'model_name'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Design Capacity') { + if ($value[0] eq 'Location'){$battery{$id}->{'location'} = $value[1] } + elsif ($value[0] eq 'Manufacturer'){$battery{$id}->{'manufacturer'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] =~ /Chemistry/){$battery{$id}->{'technology'} = $value[1] } + elsif ($value[0] =~ /Serial Number/){$battery{$id}->{'serial_number'} = $value[1] } + elsif ($value[0] =~ /^Name/){$battery{$id}->{'model_name'} = main::dmi_cleaner($value[1]) } + elsif ($value[0] eq 'Design Capacity'){ $value[1] =~ s/\s*mwh$//i; $battery{$id}->{'energy_full_design'} = sprintf("%.1f", $value[1]/1000); } - elsif ($value[0] eq 'Design Voltage') { + elsif ($value[0] eq 'Design Voltage'){ $value[1] =~ s/\s*mv$//i; $battery{$id}->{'voltage_min_design'} = sprintf("%.1f", $value[1]/1000); } } - if ($battery{$id}->{'energy_now'} && $battery{$id}->{'energy_full'} ){ + if ($battery{$id}->{'energy_now'} && $battery{$id}->{'energy_full'}){ $battery{$id}->{'capacity'} = 100 * $battery{$id}->{'energy_now'} / $battery{$id}->{'energy_full'}; $battery{$id}->{'capacity'} = sprintf("%.1f%", $battery{$id}->{'capacity'}); } - if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'} ){ + if ($battery{$id}->{'energy_full_design'} && $battery{$id}->{'energy_full'}){ $battery{$id}->{'of_orig'} = 100 * $battery{$id}->{'energy_full'} / $battery{$id}->{'energy_full_design'}; $battery{$id}->{'of_orig'} = sprintf("%.0f%", $battery{$id}->{'of_orig'}); } @@ -7809,7 +7814,7 @@ sub advanced_output { } if (@temp && %hci){ if ($hci{'alert'}){ - if (keys %hci == 1) { + if (keys %hci == 1){ check_service(); # sets $service $j = scalar @rows; $rows[$j]->{main::key($num++,1,$k,'Report')} = $tool; @@ -8119,17 +8124,17 @@ sub full_output { if (my $file = $system_files{'proc-cpuinfo'}){ # bsd sleep is set before sysctl runs, same idea if ($b_hires){ - eval 'Time::HiRes::usleep( $sleep )'; + eval 'Time::HiRes::usleep($sleep)'; } else { select(undef, undef, undef, $cpu_sleep); } %cpu = cpuinfo_data($file,'full'); } - elsif ($bsd_type ){ + elsif ($bsd_type){ my ($key1,$val1) = ('',''); - if ( $alerts{'sysctl'} ){ - if ( $alerts{'sysctl'}->{'action'} eq 'use' ){ + if ($alerts{'sysctl'}){ + if ($alerts{'sysctl'}->{'action'} eq 'use'){ # $key1 = 'Status'; # $val1 = main::row_defaults('dev'); %cpu = sysctl_data('full'); @@ -8155,7 +8160,7 @@ sub full_output { if ($cpu{'system-cpus'}){ my %system_cpus = %{$cpu{'system-cpus'}}; my $i = 1; - my $counter = ( %system_cpus && scalar keys %system_cpus > 1 ) ? '-' : ''; + 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; @@ -8182,7 +8187,7 @@ sub full_output { $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'} ){ + if (!$b_admin && defined $cpu{'stepping'}){ $rows[$j]->{main::key($num++,0,2,'rev')} = $cpu{'stepping'}; } } @@ -8298,7 +8303,7 @@ sub full_output { my @bugs = cpu_bugs_sys(); my $value = ''; if (!@bugs){ - if ( $cpu{'bugs'}){ + if ($cpu{'bugs'}){ my @proc_bugs = split(/\s+/, $cpu{'bugs'}); @proc_bugs = sort @proc_bugs; $value = join(' ', @proc_bugs); @@ -8357,17 +8362,17 @@ sub short_data { if (my $file = $system_files{'proc-cpuinfo'}){ my $sleep = $cpu_sleep * 1000000; if ($b_hires){ - eval 'Time::HiRes::usleep( $sleep )'; + eval 'Time::HiRes::usleep($sleep)'; } else { select(undef, undef, undef, $cpu_sleep); } %cpu = cpuinfo_data($file,$type); } - elsif ($bsd_type ){ + elsif ($bsd_type){ my ($key1,$val1) = ('',''); - if ( $alerts{'sysctl'} ){ - if ( $alerts{'sysctl'}->{'action'} eq 'use' ){ + if ($alerts{'sysctl'}){ + if ($alerts{'sysctl'}->{'action'} eq 'use'){ # $key1 = 'Status'; # $val1 = main::row_defaults('dev'); %cpu = sysctl_data($type); @@ -8505,11 +8510,11 @@ sub cpuinfo_data { $proc_count++; # print "p2a: $proc_count\n"; } - if (!$b_first ){ + if (!$b_first){ # note: alternate: # Processor : AArch64 Processor rev 4 (aarch64) # but no model name type - if ( $b_arm || $line[1] =~ /ARM|AArch/i){ + if ($b_arm || $line[1] =~ /ARM|AArch/i){ $b_arm = 1; $cpu{'type'} = 'arm'; } @@ -8521,16 +8526,18 @@ sub cpuinfo_data { } } elsif (!$cpu{'family'} && - ($line[0] eq 'architecture' || $line[0] eq 'cpu family' || $line[0] eq 'cpu architecture' )){ + ($line[0] eq 'architecture' || $line[0] eq 'cpu family' || + $line[0] eq 'cpu architecture')){ if ($line[1] =~ /^\d+$/){ # translate integers to hex $cpu{'family'} = uc(sprintf("%x", $line[1])); } - elsif ($b_arm) { + elsif ($b_arm){ $cpu{'arch'} = $line[1]; } } - elsif (!defined $cpu{'stepping'} && ($line[0] eq 'stepping' || $line[0] eq 'cpu revision')){ + elsif (!defined $cpu{'stepping'} && ($line[0] eq 'stepping' || + $line[0] eq 'cpu revision')){ $cpu{'stepping'} = uc(sprintf("%x", $line[1])); } # ppc @@ -8538,21 +8545,23 @@ sub cpuinfo_data { $cpu{'stepping'} = $line[1]; } # this is hex so uc for cpu arch id. raspi 4 has Model rather than Hard - elsif (!$cpu{'model_id'} && (!$b_ppc && !$b_arm && $line[0] eq 'model') ){ + elsif (!$cpu{'model_id'} && (!$b_ppc && !$b_arm && $line[0] eq 'model')){ $cpu{'model_id'} = uc(sprintf("%x", $line[1])); } - elsif (!$cpu{'model_id'} && $line[0] eq 'cpu variant' ){ + elsif (!$cpu{'model_id'} && $line[0] eq 'cpu variant'){ $cpu{'model_id'} = uc($line[1]); $cpu{'model_id'} =~ s/^0X//; } # cpu can show in arm - elsif (!$cpu{'model_name'} && ( $line[0] eq 'model name' || $line[0] eq 'cpu' || $line[0] eq 'cpu model' )){ + elsif (!$cpu{'model_name'} && ($line[0] eq 'model name' || + $line[0] eq 'cpu' || $line[0] eq 'cpu model')){ $cpu{'model_name'} = main::cleaner($line[1]); $cpu{'model_name'} = cpu_cleaner($cpu{'model_name'}); - if ( $b_arm || $line[1] =~ /ARM|AArch/i){ + if ($b_arm || $line[1] =~ /ARM|AArch/i){ $b_arm = 1; $cpu{'type'} = 'arm'; - if ($cpu{'model_name'} && $cpu{'model_name'} =~ /(.*)\srev\s([\S]+)\s(\(([\S]+)\))?/){ + if ($cpu{'model_name'} && + $cpu{'model_name'} =~ /(.*)\srev\s([\S]+)\s(\(([\S]+)\))?/){ $cpu{'model_name'} = $1; $cpu{'stepping'} = $2; if ($4){ @@ -8567,15 +8576,15 @@ sub cpuinfo_data { $cpu{'type'} = 'mips'; } } - elsif ( $line[0] eq 'cpu mhz' || $line[0] eq 'clock' ){ + 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]; } - elsif (!$cpu{'siblings'} && $line[0] eq 'siblings' ){ + elsif (!$cpu{'siblings'} && $line[0] eq 'siblings'){ $cpu{'siblings'} = $line[1]; } - elsif (!$cpu{'cores'} && $line[0] eq 'cpu cores' ){ + elsif (!$cpu{'cores'} && $line[0] eq 'cpu cores'){ $cpu{'cores'} = $line[1]; } # increment by 1 for every new physical id we see. These are in almost all cases @@ -8593,28 +8602,28 @@ sub cpuinfo_data { elsif ($line[0] eq 'core id'){ # print "ph: $phys_holder did: $die_id l1: $line[1] s: $speed\n"; # https://www.pcworld.com/article/3214635/components-processors/ryzen-threadripper-review-we-test-amds-monster-cpu.html - if ($line[1] > 0 ){ + if ($line[1] > 0){ $die_holder = $line[1]; $core_count++; } # NOTE: this logic won't work for die detections, unforutnately. # ARM uses a different /sys based method, and ryzen relies on math on the cores # in process_data - elsif ($line[1] == 0 && $die_holder > 0 ){ + elsif ($line[1] == 0 && $die_holder > 0){ $die_holder = $line[1]; $core_count = 0; - $die_id++ if ($cpu{'type'} ne 'intel' && $cpu{'type'} ne 'amd' ); + $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; # print "ph: $phys_holder did: $die_id l1: $line[1] s: $speed\n"; } - if (!$cpu{'type'} && $line[0] eq 'vendor_id' ){ + if (!$cpu{'type'} && $line[0] eq 'vendor_id'){ $cpu{'type'} = cpu_vendor($line[1]); } ## this is only for -C full cpu output - if ( $type eq 'full' ){ - if (!$cpu{'l2-cache'} && ($line[0] eq 'cache size' || $line[0] eq 'l2 cache size' )){ + if ($type eq 'full'){ + if (!$cpu{'l2-cache'} && ($line[0] eq 'cache size' || $line[0] eq 'l2 cache size')){ if ($line[1] =~ /(\d+\s*[KMG])i?B?$/){ $cpu{'l2-cache'} = main::translate_size($1); } @@ -8653,7 +8662,7 @@ sub cpuinfo_data { } } } - if (!$cpu{'flags'} && ($line[0] eq 'flags' || $line[0] eq 'features' )){ + if (!$cpu{'flags'} && ($line[0] eq 'flags' || $line[0] eq 'features')){ $cpu{'flags'} = $line[1]; } if ($extra > 0 && $line[0] eq 'bogomips'){ @@ -8661,7 +8670,7 @@ sub cpuinfo_data { $cpu{'bogomips'} += $line[1] if $line[1] > 50; } } - if ($b_admin ){ + if ($b_admin){ # note: not used unless maybe /sys data missing? if (!$cpu{'bugs'} && $line[0] eq 'bugs'){ $cpu{'bugs'} = $line[1]; @@ -8725,47 +8734,47 @@ sub sysctl_data { @{$sysctl{'cpu'}} = () if !$sysctl{'cpu'}; # don't want error next! foreach (@{$sysctl{'cpu'}}){ @line = split(/\s*:\s*/, $_); - next if ! $line[0]; + next if !$line[0]; # darwin shows machine, like MacBook7,1, not cpu # machdep.cpu.brand_string: Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz - if (($bsd_type ne 'darwin' && $line[0] eq 'hw.model' ) || - $line[0] eq 'machdep.cpu.brand_string' ){ + if (($bsd_type ne 'darwin' && $line[0] eq 'hw.model') || + $line[0] eq 'machdep.cpu.brand_string'){ # cut L2 cache/cpu max speed out of model string, if available # openbsd 5.6: AMD Sempron(tm) Processor 3400+ ("AuthenticAMD" 686-class, 256KB L2 cache) # openbsd 6.x has Lx cache data in dmesg.boot # freebsd 10: hw.model: AMD Athlon(tm) II X2 245 Processor $line[1] = main::cleaner($line[1]); $line[1] = cpu_cleaner($line[1]); - if ( $line[1] =~ /([0-9]+)[\s-]*([KM]B)\s+L2 cache/i) { + if ($line[1] =~ /([0-9]+)[\s-]*([KM]B)\s+L2 cache/i){ my $multiplier = ($2 eq 'MB') ? 1024: 1; $cpu{'l2-cache'} = $1 * $multiplier; } - if ( $line[1] =~ /([^0-9\.][0-9\.]+)[\s-]*[MG]Hz/) { + if ($line[1] =~ /([^0-9\.][0-9\.]+)[\s-]*[MG]Hz/){ $cpu{'max-freq'} = $1; - if ($cpu{'max-freq'} =~ /MHz/i) { + if ($cpu{'max-freq'} =~ /MHz/i){ $cpu{'max-freq'} =~ s/[\s-]*MHz//; $cpu{'max-freq'} = speed_cleaner($cpu{'max-freq'},'mhz'); } - elsif ($cpu{'max-freq'} =~ /GHz/) { + elsif ($cpu{'max-freq'} =~ /GHz/){ $cpu{'max-freq'} =~ s/[\s-]*GHz//i; $cpu{'max-freq'} = $cpu{'max-freq'} / 1000; $cpu{'max-freq'} = speed_cleaner($cpu{'max-freq'},'mhz'); } } - if ( $line[1] =~ /\)$/ ){ + if ($line[1] =~ /\)$/){ $line[1] =~ s/\s*\(.*\)$//; } $cpu{'model_name'} = $line[1]; $cpu{'type'} = cpu_vendor($line[1]); } # NOTE: hw.l1icachesize: hw.l1dcachesize: ; in bytes, apparently - elsif ($line[0] eq 'hw.l1icachesize') { + elsif ($line[0] eq 'hw.l1icachesize'){ $cpu{'l1-cache'} = $line[1]/1024; } - elsif ($line[0] eq 'hw.l2cachesize') { + elsif ($line[0] eq 'hw.l2cachesize'){ $cpu{'l2-cache'} = $line[1]/1024; } - elsif ($line[0] eq 'hw.l3cachesize') { + elsif ($line[0] eq 'hw.l3cachesize'){ $cpu{'l3-cache'} = $line[1]/1024; } # this is in mghz in samples @@ -8774,13 +8783,13 @@ sub sysctl_data { $cpu{'cur-freq'} = $line[1]; } # these are in hz: 2400000000 - elsif ($line[0] eq 'hw.cpufrequency') { + elsif ($line[0] eq 'hw.cpufrequency'){ $cpu{'cur-freq'} = $line[1]/1000000; } - elsif ($line[0] eq 'hw.busfrequency_min') { + elsif ($line[0] eq 'hw.busfrequency_min'){ $cpu{'min-freq'} = $line[1]/1000000; } - elsif ($line[0] eq 'hw.busfrequency_max') { + elsif ($line[0] eq 'hw.busfrequency_max'){ $cpu{'max-freq'} = $line[1]/1000000; } # FB seems to call freq something other than clock speed, unreliable @@ -8795,23 +8804,23 @@ sub sysctl_data { (!$cpu{'processors'} || !defined $cpu{'processors'}->[$1])){ $cpu{'processors'}->[$1] = undef; } - elsif ($line[0] eq 'machdep.cpu.vendor') { + elsif ($line[0] eq 'machdep.cpu.vendor'){ $cpu{'type'} = cpu_vendor($line[1]); } # darwin only? - elsif ($line[0] eq 'machdep.cpu.features') { + elsif ($line[0] eq 'machdep.cpu.features'){ $cpu{'flags'} = lc($line[1]); } - elsif ($line[0] eq 'hw.ncpu' ) { + elsif ($line[0] eq 'hw.ncpu'){ $cpu{'cores'} = $line[1]; } # Freebsd does some voltage hacking to actually run at lowest listed # frequencies. The cpu does not actually support all the speeds output # here but works in freebsd. Disabled this, the freq appear to refer to # something else, not cpu clock. Remove XXX to enable - elsif ($line[0] eq 'dev.cpu.0.freq_levelsXXX') { + elsif ($line[0] eq 'dev.cpu.0.freq_levelsXXX'){ $line[1] =~ s/^\s+|\/[0-9]+|\s+$//g; - if ( $line[1] =~ /[0-9]+\s+[0-9]+/ ) { + if ($line[1] =~ /[0-9]+\s+[0-9]+/){ # get rid of -1 in FB: 2400/-1 2200/-1 2000/-1 1800/-1 $line[1] =~ s|/-1||g; my @temp = split(/\s+/, $line[1]); @@ -8821,11 +8830,11 @@ sub sysctl_data { } } # Disabled w/XXX. this is almost certainly bad data, should not be used - elsif (!$cpu{'cur-freq'} && $line[0] eq 'dev.cpu.0.freqXXX' ) { + elsif (!$cpu{'cur-freq'} && $line[0] eq 'dev.cpu.0.freqXXX'){ $cpu{'cur-freq'} = $line[1]; } # the following have only been seen in DragonflyBSD data but thumbs up! - elsif ($line[0] eq 'hw.cpu_topology.members' ) { + elsif ($line[0] eq 'hw.cpu_topology.members'){ my @temp = split(/\s+/, $line[1]); my $count = scalar @temp; $count-- if $count > 0; @@ -8835,27 +8844,27 @@ sub sysctl_data { $cpu{'processors'}->[$_] = 0; } } - elsif ($line[0] eq 'hw.cpu_topology.cpu1.physical_siblings' ) { + elsif ($line[0] eq 'hw.cpu_topology.cpu1.physical_siblings'){ # string, like: cpu0 cpu1 my @temp = split(/\s+/, $line[1]); $cpu{'siblings'} = scalar @temp; } # increment by 1 for every new physical id we see. These are in almost all cases # separate cpus, not separate dies within a single cpu body. - elsif ( $line[0] eq 'hw.cpu_topology.cpu0.physical_id' ){ - if ($phys_holder != $line[1] ){ + elsif ($line[0] eq 'hw.cpu_topology.cpu0.physical_id'){ + if ($phys_holder != $line[1]){ $phys_id++; $phys_holder = $line[1]; $ids[$phys_id] = [0]; $ids[$phys_id]->[$die_id] = [0]; } } - elsif ( $line[0] eq 'hw.cpu_topology.cpu0.core_id' ){ - if ($line[1] > 0 ){ + elsif ($line[0] eq 'hw.cpu_topology.cpu0.core_id'){ + if ($line[1] > 0){ $die_holder = $line[1]; } # this handles multi die cpus like 16 core ryzen - elsif ($line[1] == 0 && $die_holder > 0 ){ + elsif ($line[1] == 0 && $die_holder > 0){ $die_id++ ; $die_holder = $line[1]; } @@ -8881,7 +8890,7 @@ sub sysctl_data { $cpu{'stepping'} = $dmesg_boot{'stepping'} if !$cpu{'stepping'}; $cpu{'type'} = $dmesg_boot{'type'} if !$cpu{'type'}; } - if ( $extra > 0 && !$cpu{'arch'} && $type ne 'short' ){ + if ($extra > 0 && !$cpu{'arch'} && $type ne 'short'){ ($cpu{'arch'},$cpu{'arch-note'}) = cpu_arch($cpu{'type'},$cpu{'family'},$cpu{'model_id'},$cpu{'stepping'}); # print "$cpu{'type'},$cpu{'family'},$cpu{'model_id'},$cpu{'arch'}\n"; } @@ -8902,8 +8911,8 @@ sub dboot_data { if ($dboot{'cpu'}){ foreach (@{$dboot{'cpu'}}){ # can be ~Features/Features2/AMD Features - if (/Features/ || ( $bsd_type eq "openbsd" && - /^cpu0:\s*[a-z0-9]{2,3}(\s|,)[a-z0-9]{2,3}(\s|,)/i )) { + if (/Features/ || ($bsd_type eq "openbsd" && + /^cpu0:\s*[a-z0-9]{2,3}(\s|,)[a-z0-9]{2,3}(\s|,)/i)){ my @line = split(/:\s*/, lc($_)); # free bsd has to have weird syntax: <....,> # Features2=0x1e98220b @@ -9103,16 +9112,16 @@ sub cpu_properties { my ($cpu) = @_; my ($b_amd_zen,$b_epyc,$b_ht,$b_elbrus,$b_intel,$b_ryzen,$b_xeon); my ($cores_x,$cache_check) = (1,''); - if ($cpu->{'type'} ){ + if ($cpu->{'type'}){ if ($cpu->{'type'} eq 'intel'){ $b_intel = 1; $b_xeon = 1 if $cpu->{'model_name'} =~ /Xeon/i; } - elsif ($cpu->{'type'} eq 'amd' ){ - if ( $cpu->{'family'} && $cpu->{'family'} eq '17' ) { + elsif ($cpu->{'type'} eq 'amd'){ + if ($cpu->{'family'} && $cpu->{'family'} eq '17'){ $b_amd_zen = 1; - if ($cpu->{'model_name'} ){ - if ($cpu->{'model_name'} =~ /Ryzen/i ){ + if ($cpu->{'model_name'}){ + if ($cpu->{'model_name'} =~ /Ryzen/i){ $b_ryzen = 1; } elsif ($cpu->{'model_name'} =~ /EPYC/i){ @@ -9121,7 +9130,7 @@ sub cpu_properties { } } } - elsif ($cpu->{'type'} eq 'elbrus') { + elsif ($cpu->{'type'} eq 'elbrus'){ $b_elbrus = 1; } } @@ -9132,7 +9141,7 @@ sub cpu_properties { my @processors; my ($speed,$speed_key); # handle case where cpu reports say, phys id 0, 2, 4, 6 [yes, seen it] - foreach (@phys) { + foreach (@phys){ $physical_count++ if $_; } # count unique processors ## @@ -9212,7 +9221,7 @@ sub cpu_properties { $cpu->{'dies'} = ($temp[1] && $temp[1] > 0) ? $temp[0]++ : $temp[0]; } # these always have 4 dies - elsif ($b_epyc) { + elsif ($b_epyc){ $cpu_cores = $cpu->{'cores'}; $cpu->{'dies'} = 4; } @@ -9221,7 +9230,7 @@ sub cpu_properties { # } # final check, override the num of cores value if it clearly is wrong # and use the raw core count and synthesize the total instead of real count - if ( $cpu_cores == 0 && ($cpu->{'cores'} * $physical_count > 1)){ + if ($cpu_cores == 0 && ($cpu->{'cores'} * $physical_count > 1)){ $cpu_cores = ($cpu->{'cores'} * $physical_count); } # last check, seeing some intel cpus and vms with intel cpus that do not show any @@ -9230,9 +9239,9 @@ sub cpu_properties { $cpu_cores = $processors_count; } # this happens with BSDs which have very little cpu data available - if ( $processors_count == 0 && $cpu_cores > 0 ){ + if ($processors_count == 0 && $cpu_cores > 0){ $processors_count = $cpu_cores; - if ($bsd_type && ($b_ht || $b_amd_zen) && $cpu_cores > 2 ){ + if ($bsd_type && ($b_ht || $b_amd_zen) && $cpu_cores > 2){ $cpu_cores = $cpu_cores/2;; } my $count = $processors_count; @@ -9299,7 +9308,7 @@ sub cpu_properties { # if > 1 processor && processor id (physical id) != core id then Multi-Core Processors (MCP) # if > 1 processor && processor ids (physical id) > 1 then Symmetric Multi Processing (SMP) # if = 1 processor then single core/processor Uni-Processor (UP) - if ($processors_count > 1 || ($b_intel && $cpu->{'siblings'} > 0)) { + if ($processors_count > 1 || ($b_intel && $cpu->{'siblings'} > 0)){ # non-multicore MT if ($processors_count == ($physical_count * $cpu_cores * 2)){ # print "mt:1\n"; @@ -9309,17 +9318,17 @@ sub cpu_properties { # # print "mt:2\n"; # $cpu_type .= 'MT'; # } - elsif ($cpu->{'siblings'} > 1 && ($cpu->{'siblings'} == 2 * $cpu_cores )){ + elsif ($cpu->{'siblings'} > 1 && ($cpu->{'siblings'} == 2 * $cpu_cores)){ # print "mt:3\n"; $cpu_type .= 'MT'; } # non-MT multi-core or MT multi-core - if ( ($processors_count == $cpu_cores ) || ($physical_count < $cpu_cores)){ + if (($processors_count == $cpu_cores) || ($physical_count < $cpu_cores)){ my $sep = ($cpu_type) ? ' ' : '' ; $cpu_type .= $sep . 'MCP'; } # only solidly known > 1 die cpus will use this, ryzen and arm for now - if ( $cpu->{'dies'} > 1 ){ + if ($cpu->{'dies'} > 1){ my $sep = ($cpu_type) ? ' ' : '' ; $cpu_type .= $sep . 'MCM'; } @@ -9337,7 +9346,7 @@ sub cpu_properties { } $cpu_layout .= count_alpha($cpu_cores) . 'Core'; $cpu_layout .= ' (' . $cpu->{'dies'}. '-Die)' if !$bsd_type && $cpu->{'dies'} > 1; - if (!$cpu->{'l2-cache'} ){ + if (!$cpu->{'l2-cache'}){ # do nothing } # the only possible change for bsds is if we can get phys counts in the future @@ -9358,7 +9367,7 @@ sub cpu_properties { else { $l2_cache = $cpu->{'l2-cache'} * $physical_count; } - if ($cpu->{'cur-freq'} && $cpu->{'min-freq'} && $cpu->{'max-freq'} ){ + if ($cpu->{'cur-freq'} && $cpu->{'min-freq'} && $cpu->{'max-freq'}){ $min_max = "$cpu->{'min-freq'}/$cpu->{'max-freq'} MHz"; $min_max_key = "min/max"; $speed_key = ($show{'short'} || $show{'cpu-basic'}) ? 'speed' : 'Speed'; @@ -9385,7 +9394,7 @@ sub cpu_properties { $speed = "$cpu->{'cur-freq'} MHz"; } - if ( !$bits_sys && !$b_arm && $cpu->{'flags'} ){ + if (!$bits_sys && !$b_arm && $cpu->{'flags'}){ $bits_sys = ($cpu->{'flags'} =~ /\blm\b/) ? 64 : 32; } my %cpu_properties = ( @@ -9423,7 +9432,7 @@ sub cpu_bugs_sys { my @items = main::globber('/sys/devices/system/cpu/vulnerabilities/*'); if (@items){ foreach (@items){ - $value = ( -r $_) ? main::reader($_,'',0) : main::row_defaults('root-required'); + $value = (-r $_) ? main::reader($_,'',0) : main::row_defaults('root-required'); $type = ($value =~ /^Mitigation:/) ? 'mitigation': 'status'; $_ =~ s/.*\/([^\/]+)$/$1/; $value =~ s/Mitigation: //; @@ -9528,9 +9537,10 @@ sub set_cpu_speeds_sys { } # policy4/cpuinfo_max_freq:["2000000"] policy0/cpuinfo_max_freq:["1500000"] # policy4/cpuinfo_min_freq:["200000"] - if ( (scalar @max_freq < 2 && scalar @min_freq < 2 ) && + if ((scalar @max_freq < 2 && scalar @min_freq < 2) && (defined $speeds{'min-freq'} && defined $speeds{'max-freq'}) && - ($speeds{'min-freq'} > $speeds{'max-freq'} || $speeds{'min-freq'} == $speeds{'max-freq'} )){ + ($speeds{'min-freq'} > $speeds{'max-freq'} || + $speeds{'min-freq'} == $speeds{'max-freq'})){ $speeds{'min-freq'} = 0; } } @@ -9593,7 +9603,7 @@ sub cpu_vendor { my ($string) = @_; my ($vendor) = (''); $string = lc($string); - if ($string =~ /intel/) { + if ($string =~ /intel/){ $vendor = "intel" } elsif ($string =~ /amd/){ @@ -9798,7 +9808,7 @@ sub cpu_arch { $arch = 'WinChip 3'} } elsif ($family eq '6'){ - if ($model =~ /^(6)$/ ){ + if ($model =~ /^(6)$/){ $arch = 'WinChip-based'} elsif ($model =~ /^(7|8)$/){ $arch = 'C3'} @@ -9811,7 +9821,7 @@ sub cpu_arch { } } # note, to test uncoment $cpu{'type'} = Elbrus in proc/cpuinfo logic - elsif ( $type eq 'elbrus'){ + elsif ($type eq 'elbrus'){ # E8CB if ($family eq '4'){ if ($model eq '1'){ @@ -9830,10 +9840,10 @@ sub cpu_arch { else { $arch = 'Elbrus-8C';} } # note: stepping > 1 may be 8C1 - elsif ( $model eq '8' ){ + elsif ($model eq '8'){ $arch = 'Elbrus-1C+'} # 8C2 morphed out of E8CV, but the two were the same die - elsif ( $model eq '9' ){ + elsif ($model eq '9'){ $arch = 'Elbrus-8CV/8C2'; $note = $check;} elsif ($model eq 'A'){ @@ -9871,15 +9881,15 @@ sub cpu_arch { } elsif ($type eq 'intel'){ if ($family eq '4'){ - if ( $model =~ /^(0|1|2|3|4|5|6|7|8|9)$/ ){ + if ($model =~ /^(0|1|2|3|4|5|6|7|8|9)$/){ $arch = '486'} } elsif ($family eq '5'){ - if ( $model =~ /^(1|2|3|7)$/ ){ + if ($model =~ /^(1|2|3|7)$/){ $arch = 'P5'} - elsif ( $model =~ /^(4|8)$/ ){ + elsif ($model =~ /^(4|8)$/){ $arch = 'P5'} # MMX - elsif ( $model =~ /^(9|A)$/ ){ + elsif ($model =~ /^(9|A)$/){ $arch = 'Lakemont'} } elsif ($family eq '6'){ @@ -10077,7 +10087,7 @@ sub set_cpu_data { # MHZ - cell cpus sub speed_cleaner { my ($speed,$opt) = @_; - return if ! $speed || $speed eq '0'; + return if !$speed || $speed eq '0'; $speed =~ s/[GMK]HZ$//gi; $speed = ($speed/1000) if $opt && $opt eq 'khz'; $speed = sprintf("%.0f", $speed); @@ -10085,7 +10095,7 @@ sub speed_cleaner { } sub cpu_cleaner { my ($cpu) = @_; - return if ! $cpu; + return if !$cpu; my $filters = '@|cpu |cpu deca|([0-9]+|single|dual|two|triple|three|tri|quad|four|'; $filters .= 'penta|five|hepta|six|hexa|seven|octa|eight|multi)[ -]core|'; $filters .= 'ennea|genuine|multi|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]'; @@ -10127,10 +10137,10 @@ sub get { if ($type eq 'standard'){ push(@rows,storage_output(\@data)); push(@rows,drive_output(\@data)) if $show{'disk'} && @data; - if ($bsd_type && !$dboot{'disk'} && $type eq 'standard' && $show{'disk'} ){ + if ($bsd_type && !$dboot{'disk'} && $type eq 'standard' && $show{'disk'}){ $key1 = 'Drive Report'; my $file = $system_files{'dmesg-boot'}; - if ( $file && ! -r $file){ + if ($file && ! -r $file){ $val1 = main::row_defaults('dmesg-boot-permissions'); } elsif (!$file){ @@ -10196,7 +10206,7 @@ sub storage_output { $rows[$j]->{main::key($num++,0,4,'lvm-free')} = $size; } if (($size_value && $size_value =~ /^[0-9]/) && - ($used && $disks->[0]{'used'} =~ /^[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; @@ -10216,7 +10226,7 @@ sub drive_output { $j = scalar @rows; $rows[$j]->{main::key($num++,0,1,'SMART Message')} = $smartctl_missing; } - elsif ($b_admin) { + elsif ($b_admin){ ($smart_age,$smart_basic,$smart_fail) = smartctl_fields(); } foreach my $row (sort { $a->{'id'} cmp $b->{'id'} } @$disks){ @@ -10267,9 +10277,12 @@ sub drive_output { $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'} || $row->{'drive-type'})){ - $row->{'rotation'} = $row->{'drive-type'} if !$row->{'rotation'}; - $rows[$j]->{main::key($num++,0,2,'rotation')} = $row->{'rotation'}; + if ($extra > 2){ + $row->{'drive-type'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'type')} = $row->{'drive-type'}; + if ($row->{'rotation'}){ + $rows[$j]->{main::key($num++,0,2,'rpm')} = $row->{'rotation'}; + } } if ($extra > 1){ if (!$row->{'serial'} && $alerts{'bioctl'} && @@ -10297,7 +10310,7 @@ sub drive_output { if (!$row->{'duid'} && $alerts{'bioctl'}->{'action'} eq 'permissions'){ $rows[$j]->{main::key($num++,0,2,'duid')} = main::row_defaults('root-required'); } - elsif ($row->{'duid'}) { + elsif ($row->{'duid'}){ $rows[$j]->{main::key($num++,0,2,'duid')} = main::apply_filter($row->{'duid'}); } } @@ -10365,12 +10378,12 @@ sub drive_data { my ($used) = (0); PartitionItem::set_partitions() if !$loaded{'set-partitions'}; RaidItem::raid_data() if !$loaded{'raid'}; + # see docs/inxi-data.txt PARTITION DATA for more on remote/fuse fs + my $fs_skip = PartitionItem::fs_excludes('disk-used'); foreach my $row (@partitions){ - # don't count remote used, also, some cases mount - # panfs is parallel NAS volume manager, need more data - # null is hammer fs slice; nfs, nfs4 - next if ($row->{'fs'} && $row->{'fs'} =~ /^(cifs|iso9660|nfs\d{0,2}|null|overlay|panfs|sshfs|smbfs|unionfs)$/); - # don't count zfs or file type swap + # don't count remote/distributed/union type fs towards used + next if ($row->{'fs'} && $row->{'fs'} =~ /^(fuse(blk)?[\._-]?)?($fs_skip)$/); + # don't count non partition swap next if ($row->{'swap-type'} && $row->{'swap-type'} ne 'partition'); # in some cases, like redhat, mounted cdrom/dvds show up in partition data next if ($row->{'dev-base'} && $row->{'dev-base'} =~ /^sr[0-9]+$/); @@ -10378,7 +10391,7 @@ sub drive_data { # to same partitions, or btrfs sub volume mounts, is present. The value is # searched for an earlier appearance of that partition and if it is present, # the data is not added into the partition used size. - if ( $row->{'dev-base'} !~ /^(\/\/|:\/)/ && ! (grep {/$row->{'dev-base'}/} @devs) ){ + if ($row->{'dev-base'} !~ /^(\/\/|:\/)/ && !(grep {/$row->{'dev-base'}/} @devs)){ $used += $row->{'used'} if $row->{'used'}; push(@devs, $row->{'dev-base'}); } @@ -10390,7 +10403,7 @@ sub drive_data { @data = bsd_data($used); } if ($b_admin){ - if ( $alerts{'smartctl'} && $alerts{'smartctl'}->{'action'} eq 'use'){ + if ($alerts{'smartctl'} && $alerts{'smartctl'}->{'action'} eq 'use'){ @data = smartctl_data(\@data); } else { @@ -10409,7 +10422,7 @@ sub proc_data { my ($b_hdx,$logical_size,$size) = (0,0,0); PartitionData::set() if !$bsd_type && !$loaded{'partition-data'}; foreach my $row (@proc_partitions){ - if ( $row->[-1] =~ /^(fio[a-z]+|[hsv]d[a-z]+|(ada|mmcblk|n[b]?d|nvme[0-9]+n)[0-9]+)$/) { + if ($row->[-1] =~ /^(fio[a-z]+|[hsv]d[a-z]+|(ada|mmcblk|n[b]?d|nvme[0-9]+n)[0-9]+)$/){ $b_hdx = 1 if $row->[-1] =~ /^hd[a-z]/; push(@drives, { 'firmware' => '', @@ -10427,7 +10440,7 @@ sub proc_data { } # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below # See https://www.mjmwired.net/kernel/Documentation/devices.txt for kernel 4.x device numbers - # if ( $row->[0] =~ /^(3|22|33|8)$/ && $row->[1] % 16 == 0 ) { + # if ($row->[0] =~ /^(3|22|33|8)$/ && $row->[1] % 16 == 0) { # $size += $row->[2]; # } # special case from this data: 8 0 156290904 sda @@ -10438,9 +10451,9 @@ sub proc_data { # nvme partitions to next nvme, so it only passes the test for the first nvme drive. # note: 66 16 9766436864 sdah ; 65 240 9766436864 sdaf[maybe special case when double letters? # Check /proc/devices for major number matches - if ( $row->[0] =~ /^(3|8|22|33|43|6[5-9]|7[12]|12[89]|13[0-5]|179|202|252|253|254|259)$/ && - $row->[-1] =~ /(mmcblk[0-9]+|n[b]?d[0-9]+|nvme[0-9]+n[0-9]+|fio[a-z]+|[hsv]d[a-z]+)$/ && - ( $row->[1] % 16 == 0 || $row->[1] % 16 == 8 || $row->[-1] =~ /(nvme[0-9]+n[0-9]+)$/) ) { + if ($row->[0] =~ /^(3|8|22|33|43|6[5-9]|7[12]|12[89]|13[0-5]|179|202|252|253|254|259)$/ && + $row->[-1] =~ /(mmcblk[0-9]+|n[b]?d[0-9]+|nvme[0-9]+n[0-9]+|fio[a-z]+|[hsv]d[a-z]+)$/ && + ($row->[1] % 16 == 0 || $row->[1] % 16 == 8 || $row->[-1] =~ /(nvme[0-9]+n[0-9]+)$/)){ $size += $row->[2]; } } @@ -10493,7 +10506,7 @@ sub proc_data_advanced { if ($b_hdx){ for ($i = 1; $i < scalar @$drives; $i++){ $file = "/proc/ide/$drives->[$i]{'id'}/model"; - if ( $drives->[$i]{'id'} =~ /^hd[a-z]/ && -e $file){ + if ($drives->[$i]{'id'} =~ /^hd[a-z]/ && -e $file){ $model = main::reader($file,'strip',0); $drives->[$i]{'model'} = $model; } @@ -10554,10 +10567,10 @@ sub proc_data_advanced { } # note: an entire class of model names gets truncated by /sys so that should be the last # in priority re tests. - elsif ( (!@disk_data || !$disk_data[0] ) && $block_type){ + elsif ((!@disk_data || !$disk_data[0]) && $block_type){ # NOTE: while path ${working_path}vendor exists, it contains junk value, like: ATA $path = "${working_path}model"; - if ( -r $path){ + if (-r $path){ $model = main::reader($path,'strip',0); $drives->[$i]{'model'} = $model if $model; } @@ -10572,7 +10585,7 @@ sub proc_data_advanced { $drives->[$i]{'vendor'} = $disk_data[1] if $disk_data[1]; } # maybe rework logic if find good scsi data example, but for now use this - elsif ($drives->[$i]{'model'} && !$drives->[$i]{'vendor'}) { + elsif ($drives->[$i]{'model'} && !$drives->[$i]{'vendor'}){ $drives->[$i]{'model'} = main::disk_cleaner($drives->[$i]{'model'}); my @device_data = device_vendor($drives->[$i]{'model'},''); $drives->[$i]{'model'} = $device_data[1] if $device_data[1]; @@ -10597,16 +10610,16 @@ sub proc_data_advanced { } else { $path = "${working_path}serial"; - if ( -r $path){ + if (-r $path){ $serial = main::reader($path,'strip',0); $drives->[$i]{'serial'} = $serial if $serial; } } - if ($extra > 2 && !$drives->[$i]{'firmware'} ){ + if ($extra > 2 && !$drives->[$i]{'firmware'}){ my @fm = ('rev','fmrev','firmware_rev'); # 0 ~ default; 1 ~ mmc; 2 ~ nvme foreach my $firmware (@fm){ $path = "${working_path}$firmware"; - if ( -r $path){ + if (-r $path){ $drives->[$i]{'firmware'} = main::reader($path,'strip',0); last; } @@ -10619,7 +10632,7 @@ sub proc_data_advanced { $pt_cmd = $data[0]; $drives->[$i]{'partition-table'} = uc($data[1]) if $data[1]; if ($data[2]){ - $drives->[$i]{'rotation'} = "$data[2] rpm"; + $drives->[$i]{'rotation'} = $data[2]; $drives->[$i]{'drive-type'} = 'HDD'; } elsif (($block_type && $block_type ne 'sdx') || @@ -10709,7 +10722,7 @@ sub bsd_data { 'used' => $used, }); #main::log_data('dump','$data',\@data) if $b_log; - if ( $show{'disk'} ){ + if ($show{'disk'}){ push(@data,@drives); # print 'data:', Data::Dumper::Dumper \@data; } @@ -10829,7 +10842,7 @@ sub smartctl_data { main::log_data('dump','@result', \@result) if $b_log; # log before cleanup @result = grep {!/^(smartctl|Copyright|==)/} @result; print 'Drive:/dev/' . $id . ":\n", Data::Dumper::Dumper\@result if $dbg[12]; - if (scalar @result < 5 ){ + if (scalar @result < 5){ if (grep {/failed: permission denied/i} @result){ $data->[$i]{'smart-permissions'} = main::row_defaults('tool-permissions','smartctl'); } @@ -10898,6 +10911,7 @@ sub smartctl_data { elsif ($split[$a] eq 'Rotation Rate'){ if ($split[$r] !~ /^Solid/){ $data->[$i]{'rotation'} = $split[$r]; + $data->[$i]{'rotation'} =~ s/\s*rpm$//i; $data->[$i]{'drive-type'} = 'HDD'; } else { @@ -10905,7 +10919,7 @@ sub smartctl_data { } } elsif ($split[$a] eq 'Serial Number'){ - if ( !$data->[$i]{'serial'}){ + if (!$data->[$i]{'serial'}){ $data->[$i]{'serial'} = $split[$r]; } elsif ($data->[$i]{'type'} && $split[$r] ne $data->[$i]{'serial'}){ @@ -10913,15 +10927,15 @@ sub smartctl_data { } } elsif ($split[$a] eq 'SATA Version is'){ - if ( $split[$r] =~ /SATA ([0-9.]+), ([0-9.]+ [^\s]+)( \(current: ([1-9.]+ [^\s]+)\))?/){ + if ($split[$r] =~ /SATA ([0-9.]+), ([0-9.]+ [^\s]+)(\(current: ([1-9.]+ [^\s]+)\))?/){ $data->[$i]{'sata'} = $1; $data->[$i]{'speed'} = $2 if !$data->[$i]{'speed'}; } } # seen both Size and Sizes. Linux will usually have both, BSDs not physical - elsif ($split[$a] =~ /^Sector Sizes?$/ ){ - if ($data->[$i]{'type'} || !$data->[$i]{'block-logical'} || !$data->[$i]{'block-physical'} ){ - if ($split[$r] =~ m|^([0-9]+) bytes logical/physical| ){ + elsif ($split[$a] =~ /^Sector Sizes?$/){ + if ($data->[$i]{'type'} || !$data->[$i]{'block-logical'} || !$data->[$i]{'block-physical'}){ + if ($split[$r] =~ m|^([0-9]+) bytes logical/physical|){ $data->[$i]{'block-logical'} = $1; $data->[$i]{'block-physical'} = $1; } @@ -10938,11 +10952,11 @@ sub smartctl_data { $data->[$i]{'smart'} = $1; $data->[$i]{'smart'} = ($data->[$i]{'smart'} eq 'Unavailable') ? 'no' : 'yes'; } - elsif ($split[$r] =~ /^(Enabled|Disabled)/ ){ + elsif ($split[$r] =~ /^(Enabled|Disabled)/){ $data->[$i]{'smart-support'} = lc($1); } } - elsif ($split[$a] eq 'SMART overall-health self-assessment test result' ){ + elsif ($split[$a] eq 'SMART overall-health self-assessment test result'){ $data->[$i]{'smart-status'} = $split[$r]; # seen nvme that only report smart health, not smart support $data->[$i]{'smart'} = 'yes' if !$data->[$i]{'smart'}; @@ -10950,7 +10964,7 @@ sub smartctl_data { ## DEVICE CONDITION: temp/read/write/power on/cycles ## # Attributes data fields, sometimes are same syntax as info block:... - elsif ( $split[$a] eq 'Power_Cycle_Count' || $split[$a] eq 'Power Cycles' ){ + elsif ($split[$a] eq 'Power_Cycle_Count' || $split[$a] eq 'Power Cycles'){ $data->[$i]{'smart-cycles'} = $split[$r] if $split[$r]; } elsif ($split[$a] eq 'Power_On_Hours' || $split[$a] eq 'Power On Hours' || @@ -10978,8 +10992,8 @@ sub smartctl_data { } # 'Airflow_Temperature_Cel' like: 29 (Min/Max 14/43) so can't use -1 index # Temperature like 29 Celsisu - elsif ( $split[$a] eq 'Temperature_Celsius' || $split[$a] eq 'Temperature' || - $split[$a] eq 'Airflow_Temperature_Cel' ) { + elsif ($split[$a] eq 'Temperature_Celsius' || $split[$a] eq 'Temperature' || + $split[$a] eq 'Airflow_Temperature_Cel'){ if (!$data->[$i]{'temp'} && $split[$r]){ $data->[$i]{'temp'} = $split[$r]; } @@ -11062,7 +11076,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'Multi_Zone_Error_Rate'){ # note: all t values are 0 that I have seen - if ( ($split[$v] - $split[$t]) < 50){ + if (($split[$v] - $split[$t]) < 50){ $data->[$i]{'smart-multizone-errors-av'} = $split[$v]; $data->[$i]{'smart-multizone-errors-t'} = $split[$v]; } @@ -11091,7 +11105,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'Available Spare Threshold'){ $split[$r] =~ s/%$//; - if ($holder{'spare'} && main::is_numeric($split[$r]) && $split[$r]/$holder{'spare'} > 0.92 ){ + if ($holder{'spare'} && main::is_numeric($split[$r]) && $split[$r]/$holder{'spare'} > 0.92){ $data->[$i]{'smart-available-reserved-space-ar'} = $holder{'spare'}; $data->[$i]{'smart-available-reserved-space-t'} = int($split[$r]); } @@ -11126,7 +11140,7 @@ sub smartctl_data { } } elsif ($split[$a] eq 'Runtime_Bad_Block'){ - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-runtime-bad-block-av'} = $split[$v]; $data->[$i]{'smart-runtime-bad-block-t'} = $split[$t]; $data->[$i]{'smart-runtime-bad-block-f'} = $split[$f] if $split[$f] ne '-'; @@ -11134,7 +11148,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'Seek_Error_Rate'){ # value 72; threshold either 000 or 30 - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-seek-error-rate-av'} = $split[$v]; $data->[$i]{'smart-seek-error-rate-t'} = $split[$t]; $data->[$i]{'smart-seek-error-rate-f'} = $split[$f] if $split[$f] ne '-'; @@ -11142,7 +11156,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'Spin_Up_Time'){ # raw will always be > 0 on spinning disks - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-spinup-time-av'} = $split[$v]; $data->[$i]{'smart-spinup-time-t'} = $split[$t]; $data->[$i]{'smart-spinup-time-f'} = $split[$f] if $split[$f] ne '-'; @@ -11150,7 +11164,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'SSD_Life_Left'){ # raw will always be > 0 on spinning disks - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-ssd-life-left-av'} = $split[$v]; $data->[$i]{'smart-ssd-life-left-t'} = $split[$t]; $data->[$i]{'smart-ssd-life-left-f'} = $split[$f] if $split[$f] ne '-'; @@ -11158,7 +11172,7 @@ sub smartctl_data { } elsif ($split[$a] eq 'Unused_Rsvd_Blk_Cnt_Tot'){ # raw will always be > 0 on spinning disks - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-unused-reserve-block-av'} = $split[$v]; $data->[$i]{'smart-unused-reserve-block-t'} = $split[$t]; $data->[$i]{'smart-unused-reserve-block-f'} = $split[$f] if $split[$f] ne '-'; @@ -11166,15 +11180,15 @@ sub smartctl_data { } elsif ($split[$a] eq 'Used_Rsvd_Blk_Cnt_Tot'){ # raw will always be > 0 on spinning disks - if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92 ){ + if ($b_attributes && $split[$v] && $split[$t] && $split[$t]/$split[$v] > 0.92){ $data->[$i]{'smart-used-reserve-block-av'} = $split[$v]; $data->[$i]{'smart-used-reserve-block-t'} = $split[$t]; $data->[$i]{'smart-used-reserve-block-f'} = $split[$f] if $split[$f] ne '-'; } } - elsif ($b_attributes ){ - if ( $split[$y] eq 'Pre-fail' && ($split[$f] ne '-' || - ($split[$t] && $split[$v] && $split[$t]/$split[$v] > 0.92 ))) { + elsif ($b_attributes){ + if ($split[$y] eq 'Pre-fail' && ($split[$f] ne '-' || + ($split[$t] && $split[$v] && $split[$t]/$split[$v] > 0.92))){ $num++; $data->[$i]{'smart-unknown-' . $num . '-a'} = $split[$a]; $data->[$i]{'smart-unknown-' . $num . '-v'} = $split[$v]; @@ -11198,7 +11212,7 @@ sub peripheral_data { my ($type) = (''); # print "$id here\n"; if (@by_id){ - foreach (@by_id) { + foreach (@by_id){ if ("/dev/$id" eq Cwd::abs_path($_)){ # print "$id here\n"; if (/usb-/i){ @@ -11213,7 +11227,7 @@ sub peripheral_data { } # note: sometimes with wwn- numbering usb does not appear in by-id but it does in by-path if (!$type && @by_path){ - foreach (@by_path) { + foreach (@by_path){ if ("/dev/$id" eq Cwd::abs_path($_)){ if (/usb-/i){ $type = 'USB'; @@ -11242,13 +11256,13 @@ sub disk_data_advanced { if ($program = main::check_program('udevadm')){ $return[0] = "$program info -q property -n "; } - elsif ($b_root && -e "/lib/udev/udisks-part-id") { + elsif ($b_root && -e "/lib/udev/udisks-part-id"){ $return[0] = "/lib/udev/udisks-part-id /dev/"; } - elsif ($b_root && ($program = main::check_program('fdisk'))) { + elsif ($b_root && ($program = main::check_program('fdisk'))){ $return[0] = "$program -l /dev/"; } - if (!$return[0]) { + if (!$return[0]){ $return[0] = 'na' } } @@ -11273,7 +11287,7 @@ sub disk_data_advanced { } else { foreach (@data){ - if ( /^(UDISKS_PARTITION_TABLE_SCHEME|ID_PART_TABLE_TYPE)/ ){ + if (/^(UDISKS_PARTITION_TABLE_SCHEME|ID_PART_TABLE_TYPE)/){ my @working = split('=', $_); $return[1] = $working[1]; } @@ -11523,7 +11537,7 @@ sub set_vendors { # supertalent also has FM: |FM ['^(G[\.]?SKILL)','^G[\.]?SKILL','G.SKILL',''], ['^G[\s-]*Tech','^G[\s-]*Technology','G-Technology',''], - ['^(Haajan|HS[1-9])','^Haajan','Haajan',''], + ['^(Hajaan|HS[1-9])','^Haajan','Haajan',''], ['^Haizhide','^Haizhide','Haizhide',''], ['^(Hama|FlashPen\s?Fancy)','^Hama','Hama',''], ['^HDC','^HDC\b','HDC',''], @@ -11581,6 +11595,8 @@ sub set_vendors { # LENSE30512GMSP34MEAT3TA / UMIS RPITJ256PED2MWX ['^(LEN|UMIS)','^Lenovo','Lenovo',''], ['^RPFT','','Lenovo O.E.M.',''], + # JAJS300M120C JAJM600M256C JAJS600M1024C JAJS600M256C + ['^(Leven|JAJ[MS][1-9])','^Leven','Leven',''], ['^LG\b','^LG','LG',''], ['(LITE[-\s]?ON[\s-]?IT)','LITE[-]?ON[\s-]?IT','LITE-ON IT',''], # LITEONIT_LSS-24L6G ['(LITE[-\s]?ON|^PH[1-9])','LITE[-]?ON','LITE-ON',''], # PH6-CE240-L; CL1-3D256-Q11 NVMe LITEON 256GB @@ -11804,7 +11820,7 @@ sub hdd_temp { if ($device =~ /nvme/i){ if (!$b_nvme){ $b_nvme = 1; - if ($path = main::check_program('nvme')) { + if ($path = main::check_program('nvme')){ $nvme = $path; } } @@ -11815,7 +11831,7 @@ sub hdd_temp { my @row = split(/\s*:\s*/, $_); next if !$row[0]; # other rows may have: Temperature sensor 1 : - if ( $row[0] eq 'temperature') { + if ($row[0] eq 'temperature'){ $row[1] =~ s/\s*C//; $hdd_temp = $row[1]; last; @@ -11826,7 +11842,7 @@ sub hdd_temp { else { if (!$b_hddtemp){ $b_hddtemp = 1; - if ($path = main::check_program('hddtemp')) { + if ($path = main::check_program('hddtemp')){ $hddtemp = $path; } } @@ -11842,18 +11858,35 @@ sub hdd_temp { sub hdd_temp_sys { eval $start if $b_log; my ($device) = @_; - my ($hdd_temp,$hdd_temp_alt,%sensors,@working); + my ($hdd_temp,$hdd_temp_alt,%sensors,@data,@working); my ($holder,$index) = ('',''); - my $path = Cwd::abs_path("/sys/block/$device"); - return if !$path; - # slice out the part of path that gives us hwmon - $path =~ s%/(block|nvme)/.*$%%; - return if ! -e "$path/hwmon/"; - # we don't want these: crit|max|min|lowest|highest + my $path = "/sys/block/$device/device"; + my $path_trimmed = Cwd::abs_path("/sys/block/$device"); + # slice out the part of path that gives us hwmon in earlier kernel drivetemp + $path_trimmed =~ s%/(block|nvme)/.*$%% if $path_trimmed; + print "device: $device path: $path\n path_trimmed: $path_trimmed\n" if $dbg[21]; + return if ! -e $path && (!$path_trimmed || ! -e "$path_trimmed/hwmon"); + # first type, trimmed block,nvme (ata and nvme), 5.9 kernel: + # /sys/devices/pci0000:10/0000:10:08.1/0000:16:00.2/ata8/host7/target7:0:0/7:0:0:0/hwmon/hwmon5/ + # /sys/devices/pci0000:10/0000:10:01.2/0000:13:00.0/hwmon/hwmon0/ < nvme + # /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.1/ata2/host1/target1:0:0/1:0:0:0/hwmon/hwmon3/ + # second type, 5.10+ kernel: + # /sys/devices/pci0000:20/0000:20:03.1/0000:21:00.0/nvme/nvme0/nvme0n1/device/hwmon1 + # /sys/devices/pci0000:00/0000:00:08.1/0000:0b:00.2/ata12/host11/target11:0:0/11:0:0:0/block/sdd/device/hwmon/hwmon1 + # we don't want these items: crit|max|min|lowest|highest + # original kernel 5.8/9 match for nvme and sd, 5.10+ match for sd + if (-e "$path_trimmed/hwmon/"){ + @data = main::globber("$path_trimmed/hwmon/hwmon*/temp*_{input,label}"); + } + # this case only happens if path_trimmed case isn't there, but leave in case + elsif (-e "$path/hwmon/"){ + @data = main::globber("$path/hwmon/hwmon*/temp*_{input,label}"); + } + # current match for nvme, but fails for 5.8/9 kernel nvme + else { + @data = main::globber("$path/hwmon*/temp*_{input,label}"); + } # seeing long lag to read temp input files for some reason - # on some systems, just one one of them. - my @data = main::globber("$path/hwmon/hwmon*/temp*_{input,label}"); - # print "device: $device\n"; foreach (sort @data){ # print "file: $_\n"; # print(main::reader($_,'',0),"\n"); @@ -11904,7 +11937,7 @@ sub block_data { my $path_log_block = "/sys/block/$id/queue/logical_block_size"; my $path_phy_block = "/sys/block/$id/queue/physical_block_size"; # legacy system path - if (! -e $path_phy_block && -e "/sys/block/$id/queue/hw_sector_size" ){ + if (! -e $path_phy_block && -e "/sys/block/$id/queue/hw_sector_size"){ $path_phy_block = "/sys/block/$id/queue/hw_sector_size"; } $block_log = main::reader($path_log_block,'',0) if -r $path_log_block; @@ -11952,7 +11985,7 @@ sub device_speed { # pcie1: 2.5 GT/s; pcie2: 5.0 GT/s; pci3: 8 GT/s # NOTE: PCIe 3 stopped using the 8b/10b encoding but a sample pcie3 nvme has # rated speed of GT/s * .8 anyway. GT/s * (128b/130b) - $speed = ($speed <= 5 ) ? $speed * .8 : $speed * 128/130; + $speed = ($speed <= 5) ? $speed * .8 : $speed * 128/130; $speed = sprintf("%.1f",$speed) if $speed; $working = "/sys/class/nvme/$id/device/max_link_width"; $lanes = main::reader($working,'',0) if -r $working; @@ -12155,7 +12188,7 @@ sub display_output(){ $server_string = "$graphics{'x-vendor'}$version"; # print "$server_string\n"; } - elsif ($graphics{'x-version'}) { + elsif ($graphics{'x-version'}){ if ($graphics{'x-version'} =~ /^Xvesa/){ $server_string = $graphics{'x-version'}; } @@ -12192,7 +12225,7 @@ sub display_output(){ # Normally Arch gdm log is here: ~/.local/share/xorg/Xorg.1.log # $driver comes from the Device lines, and is just last fallback. if ($driver && $driver ne 'N/A'){ - if (-e '/var/lib/gdm' && !$b_root ){ + if (-e '/var/lib/gdm' && !$b_root){ $driver_missing = main::row_defaults('display-driver-na') . ' - ' . main::row_defaults('root-suggested'); } else { @@ -12222,7 +12255,7 @@ sub display_output(){ $row[0]->{main::key($num++,0,3,'alternate')} = $drivers[3]; } } - if ($b_admin ){ + if ($b_admin){ if (defined $graphics{'display-id'}){ $row[0]->{main::key($num++,0,2,'display-ID')} = $graphics{'display-id'}; } @@ -12246,8 +12279,8 @@ sub display_output(){ $screen_count++; ($diag,$dpi,$hz,$resolution,$size) = (undef); $row_key++ if !$show{'graphic-basic'}; - if ( !$show{'graphic-basic'} || $m_count == 0 ){ - if ( !$show{'graphic-basic'} && defined $main->{'screen'} ){ + 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'}; } $resolution = $main->{'res-x'} . 'x' . $main->{'res-y'} if $main->{'res-x'} && $main->{'res-y'}; @@ -12256,7 +12289,7 @@ sub display_output(){ if ($s_count == 1 || !$show{'graphic-basic'}){ $row[$row_key]->{main::key($num++,0,3,'s-res')} = $resolution; } - elsif ($show{'graphic-basic'}) { + 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; } @@ -12264,7 +12297,7 @@ sub display_output(){ if ($main->{'s-dpi'} && (!$show{'graphic-basic'} || $extra > 1)){ $row[$row_key]->{main::key($num++,0,3,'s-dpi')} = $main->{'s-dpi'}; } - if ( !$show{'graphic-basic'} ){ + if (!$show{'graphic-basic'}){ if ($main->{'size-x'} && $main->{'size-y'}){ $size = $main->{'size-x'} . 'x' . $main->{'size-y'} . 'mm ('. $main->{'size-x-i'} . 'x' . $main->{'size-y-i'} . '")'; @@ -12355,7 +12388,7 @@ sub display_data_x { # print join("\n",@xdpyinfo), "\n"; foreach (@xdpyinfo){ @working = split(/:\s+/, $_); - next if ( ($graphics{'screens'} && $working[0] !~ /^(dimensions$|screen\s#)/ ) || !$working[0] ); + next if (($graphics{'screens'} && $working[0] !~ /^(dimensions$|screen\s#)/) || !$working[0]); # print "$_\n"; if ($working[0] eq 'vendor string'){ $working[1] =~ s/The\s|\sFoundation//g; @@ -12405,7 +12438,7 @@ sub display_data_x { $size_x_i = ($3) ? sprintf("%.1f", ($3/25.4)) : 0; $size_y_i = ($4) ? sprintf("%.1f", ($4/25.4)) : 0; $dpi = ($res_x && $size_x) ? sprintf("%.0f", ($res_x*25.4/$size_x)) : ''; - $diagonal = ($res_x && $size_x) ? sprintf("%.1f", (sqrt($size_x**2 + $size_y**2)/25.4 )) : ''; + $diagonal = ($res_x && $size_x) ? sprintf("%.1f", (sqrt($size_x**2 + $size_y**2)/25.4)) : ''; $diagonal += 0 if $diagonal;# trick to get rid of decimal 0 $diagonal_m = ($res_x && $size_x) ? sprintf("%.0f", (sqrt($size_x**2 + $size_y**2))) : ''; } @@ -12453,7 +12486,7 @@ sub display_data_x { $size_x_i = ($7) ? sprintf("%.1f", ($7/25.4)) : 0; $size_y_i = ($8) ? sprintf("%.1f", ($8/25.4)) : 0; $dpi = ($res_x && $size_x) ? sprintf("%.0f", $res_x * 25.4 / $size_x) : ''; - $diagonal = ($res_x && $size_x) ? sprintf("%.1f", (sqrt($size_x**2 + $size_y**2)/25.4 )) : ''; + $diagonal = ($res_x && $size_x) ? sprintf("%.1f", (sqrt($size_x**2 + $size_y**2)/25.4)) : ''; $diagonal += 0 if $diagonal; # trick to get rid of decimal 0 $diagonal_m = ($res_x && $size_x) ? sprintf("%.0f", (sqrt($size_x**2 + $size_y**2))) : ''; push(@monitors, { @@ -12499,7 +12532,7 @@ sub display_data_x { } $i++; } - if (!$graphics{'screens'}) { + if (!$graphics{'screens'}){ $graphics{'tty'} = tty_data(); } } @@ -12530,7 +12563,7 @@ sub set_compositor { $graphics{'compositor'} = display_compositor($protocol); # gnome-shell is incredibly slow to return version if (($extra > 2 || $protocol eq 'wayland') && $graphics{'compositor'} && - ( !$show{'system'} || $graphics{'compositor'} ne 'gnome-shell' ) ){ + (!$show{'system'} || $graphics{'compositor'} ne 'gnome-shell')){ $graphics{'compositor-version'} = (main::program_data($graphics{'compositor'},$graphics{'compositor'},3))[1]; } eval $end if $b_log; @@ -12556,7 +12589,7 @@ sub get_protocol { $id = (split(/\s+/, $_))[0]; last; # multiuser? too bad, we'll go for the first one } - if ($id ){ + if ($id){ my $temp = (main::grabber("$program show-session $id -p Type --no-pager --no-legend 2>/dev/null"))[0]; $temp =~ s/Type=// if $temp; # ssh will not show /dev/ttyx so would have passed the first test @@ -12572,7 +12605,7 @@ sub gl_output(){ my $num = 0; my (@row,$arg); # print ("$b_display : $b_root\n"); - if ( $b_display){ + if ($b_display){ if (my $program = main::check_program('glxinfo')){ # NOTE: glxinfo -B is not always available, unfortunately my @glxinfo = main::grabber("$program $display_opt 2>/dev/null"); @@ -12616,7 +12649,7 @@ sub gl_output(){ } # dropping all conditions from this test to just show full mesa information # there is a user case where not f and mesa apply, atom mobo - # /opengl version/ && ( f || $2 !~ /mesa/ ) { + # /opengl version/ && ( f || $2 !~ /mesa/){ elsif (/^opengl version/i){ @working = split(/:\s*/, $_, 2); if ($working[1]){ @@ -12631,7 +12664,7 @@ sub gl_output(){ @working = split(/\s+/, $working[1]); $compat_version = $working[0]; } - elsif (!$b_nogl) { + elsif (!$b_nogl){ push(@opengl_version, main::row_defaults('gl-empty')); } } @@ -12662,8 +12695,8 @@ sub gl_output(){ # non free drivers once filtered and cleaned show the same for core and compat # but this stopped for some reason at 4.5/4.6 nvidia if (@core_profile_version && @opengl_version && - join('', @core_profile_version) ne join( '', @opengl_version) && - !(grep {/nvidia/i} @opengl_version ) ){ + join('', @core_profile_version) ne join('', @opengl_version) && + !(grep {/nvidia/i} @opengl_version)){ @opengl_version = @core_profile_version; $b_compat = 1; } @@ -12736,7 +12769,7 @@ sub x_drivers { my ($driver,@driver_data,,%drivers); my ($alternate,$failed,$loaded,$sep,$unloaded) = ('','','','',''); if (my $log = $system_files{'xorg-log'}){ - if ($fake{'xorg-log'}) { + if ($fake{'xorg-log'}){ # $log = "$ENV{HOME}/bin/scripts/inxi/data/xorg-logs/Xorg.0-voyager-serena.log"; # $log = "$ENV{HOME}/bin/scripts/inxi/data/xorg-logs/loading-unload-failed-all41-mint.txt"; # $log = "$ENV{HOME}/bin/scripts/inxi/data/xorg-logs/loading-unload-failed-phd21-mint.txt"; @@ -12761,14 +12794,14 @@ sub x_drivers { next if !/Failed|Unload|Loading/; # print "$_\n"; # note that in file names, driver is always lower case - if (/\sLoading.*($list)_drv.so$/i ) { + if (/\sLoading.*($list)_drv.so$/i){ $driver=lc($1); # we get all the actually loaded drivers first, we will use this to compare the # failed/unloaded, which have not always actually been truly loaded $drivers{$driver}='loaded'; } # openbsd uses UnloadModule: - elsif (/(Unloading\s|UnloadModule).*\"?($list)(_drv.so)?\"?$/i ) { + elsif (/(Unloading\s|UnloadModule).*\"?($list)(_drv.so)?\"?$/i){ $driver=lc($2); # we get all the actually loaded drivers first, we will use this to compare the # failed/unloaded, which have not always actually been truly loaded @@ -12784,14 +12817,14 @@ sub x_drivers { # (II) Unloading nouveau # (II) Failed to load module "nouveau" (already loaded, 0) # (II) LoadModule: "modesetting" - elsif (/Failed.*($list)\"?.*$/i ) { + elsif (/Failed.*($list)\"?.*$/i){ # Set driver to lower case because sometimes it will show as # RADEON or NVIDIA in the actual x start $driver=lc($1); # we need to make sure that the driver has already been truly loaded, # not just discussed if (exists $drivers{$driver} && $drivers{$driver} ne 'alternate'){ - if ( $_ !~ /\(already loaded/){ + if ($_ !~ /\(already loaded/){ $drivers{$driver}='failed'; } # reset the previous line's 'unloaded' to 'loaded' as well @@ -12806,19 +12839,19 @@ sub x_drivers { } my $sep = ''; foreach (sort keys %drivers){ - if ($drivers{$_} eq 'loaded') { + if ($drivers{$_} eq 'loaded'){ $sep = ($loaded) ? ',' : ''; $loaded .= $sep . $_; } - elsif ($drivers{$_} eq 'unloaded') { + elsif ($drivers{$_} eq 'unloaded'){ $sep = ($unloaded) ? ',' : ''; $unloaded .= $sep . $_; } - elsif ($drivers{$_} eq 'failed') { + elsif ($drivers{$_} eq 'failed'){ $sep = ($failed) ? ',' : ''; $failed .= $sep . $_; } - elsif ($drivers{$_} eq 'alternate') { + elsif ($drivers{$_} eq 'alternate'){ $sep = ($alternate) ? ',' : ''; $alternate .= $sep . $_; } @@ -12835,7 +12868,7 @@ sub x_version { # load the extra X paths, it's important that these are first, because # later Xorg versions show error if run in console or ssh if the true path # is not used. - @paths = ( qw(/usr/lib /usr/lib/xorg /usr/lib/xorg-server /usr/libexec /usr/X11R6/bin), @paths ); + @paths = (qw(/usr/lib /usr/lib/xorg /usr/lib/xorg-server /usr/libexec /usr/X11R6/bin), @paths); # IMPORTANT: both commands send version data to stderr! if ($program = main::check_program('Xorg')){ @data = main::grabber("$program -version 2>&1"); @@ -12854,11 +12887,11 @@ sub x_version { $version = (split(/\s+/, $_))[3]; last; } - elsif (/^X Window System Version/i) { + elsif (/^X Window System Version/i){ $version = (split(/\s+/, $_))[4]; last; } - elsif (/^Xvesa from/i) { + elsif (/^Xvesa from/i){ $version = (split(/\s+/, $_))[3]; $version = "Xvesa $version" if $version; last; @@ -12930,7 +12963,7 @@ sub display_compositor { ); foreach my $item (@compositors){ # no need to use check program with short list of ps_gui - # if (main::check_program($item[0]) && (grep {/^$item[1]$/} @ps_gui ) ){ + # if (main::check_program($item[0]) && (grep {/^$item[1]$/} @ps_gui)){ if (grep {/^$item->[1]$/} @ps_gui){ $compositor = $item->[3]; last; @@ -13146,7 +13179,7 @@ sub general_data { if ($row->{'type'} && (($row->{'type'} eq 'crypt' || $row->{'type'} eq 'mpath' || $row->{'type'} eq 'multipath') || ($row->{'type'} eq 'dm' && $row->{'name'} =~ /veracrypt/i) || - ($parent{'fs'} eq 'bcache') ) ){ + ($parent{'fs'} eq 'bcache'))){ my (@full_components,$mapped,$type); $mapped = $mapper{$row->{'name'}} if %mapper; next if grep(/^$row->{'name'}$/, @found); @@ -13340,7 +13373,7 @@ sub get { } } } - elsif (-d '/sys/class/dmi/id/') { + elsif (-d '/sys/class/dmi/id/'){ %data = machine_data_sys(); if (%data){ @rows = machine_output(\%data); @@ -13355,7 +13388,7 @@ sub get { } } } - elsif (!$bsd_type) { + elsif (!$bsd_type){ # this uses /proc/cpuinfo so only GNU/Linux if ($b_arm || $b_mips || $b_ppc){ %data = machine_data_soc(); @@ -13367,7 +13400,7 @@ sub get { } } # if error case, null data, whatever - if ($key1) { + if ($key1){ push(@rows,{main::key($num++,0,1,$key1) => $val1,}); } eval $end if $b_log; @@ -13402,16 +13435,16 @@ sub machine_output { # 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/*') ){ + 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->{'board_vendor'} && + 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'})) ){ + $data->{'product_name'} eq $data->{'board_name'}))){ $b_skip_system = 1; } } @@ -13437,12 +13470,12 @@ sub machine_output { $data->{'chassis_version'} eq $data->{'board_version'}){ $b_skip_chassis = 1; } - if (!$b_skip_chassis && $data->{'chassis_vendor'} ){ - if ($data->{'chassis_vendor'} ne $data->{'sys_vendor'} ){ + if (!$b_skip_chassis && $data->{'chassis_vendor'}){ + if ($data->{'chassis_vendor'} ne $data->{'sys_vendor'}){ $chassis_vendor = $data->{'chassis_vendor'}; } # dmidecode can have these be the same - if ($data->{'chassis_type'} && $data->{'device'} ne $data->{'chassis_type'} ){ + if ($data->{'chassis_type'} && $data->{'device'} ne $data->{'chassis_type'}){ $chassis_type = $data->{'chassis_type'}; } if ($data->{'chassis_version'}){ @@ -13560,18 +13593,18 @@ sub machine_data_sys { } $data{'firmware'} = 'BIOS'; # print Data::Dumper::Dumper \@sys_files; - if (!-d $sys_dir ){ - if ( -d $sys_dir_alt){ + if (!-d $sys_dir){ + if (-d $sys_dir_alt){ $sys_dir = $sys_dir_alt; } else { return 0; } } - if ( -d '/sys/firmware/efi'){ + if (-d '/sys/firmware/efi'){ $data{'firmware'} = 'UEFI'; } - elsif ( glob('/sys/firmware/acpi/tables/UEFI*') ){ + elsif (glob('/sys/firmware/acpi/tables/UEFI*')){ $data{'firmware'} = 'UEFI-[Legacy]'; } foreach (@sys_files){ @@ -13580,7 +13613,7 @@ sub machine_data_sys { $data{$_} = main::reader($path,'',0); $data{$_} = ($data{$_}) ? main::dmi_cleaner($data{$_}) : ''; } - elsif (!$b_root && -e $path && !-r $path ){ + elsif (!$b_root && -e $path && !-r $path){ $data{$_} = main::row_defaults('root-required'); } else { @@ -13588,7 +13621,7 @@ sub machine_data_sys { } } if ($data{'chassis_type'}){ - if ( $data{'chassis_type'} == 1){ + if ($data{'chassis_type'} == 1){ $data{'device'} = get_device_vm($data{'sys_vendor'},$data{'product_name'}); $data{'device'} ||= 'other-vm?'; } @@ -13642,15 +13675,15 @@ sub machine_data_soc { if ($build_prop{'product-manufacturer'} && $build_prop{'product-model'}){ my $brand = ''; if ($build_prop{'product-brand'} && - $build_prop{'product-brand'} ne $build_prop{'product-manufacturer'}) { + $build_prop{'product-brand'} ne $build_prop{'product-manufacturer'}){ $brand = $build_prop{'product-brand'} . ' '; } $data{'model'} = $brand . $build_prop{'product-manufacturer'} . ' ' . $build_prop{'product-model'}; } - elsif ($build_prop{'product-device'} ){ + elsif ($build_prop{'product-device'}){ $data{'model'} = $build_prop{'product-device'}; } - elsif ($build_prop{'product-name'} ){ + elsif ($build_prop{'product-name'}){ $data{'model'} = $build_prop{'product-name'}; } } @@ -13661,7 +13694,7 @@ sub machine_data_soc { $model = main::dmi_cleaner($model); $model = (split(/\x01|\x02|\x03|\x00/, $model))[0] if $model; my $device_temp = main::regex_cleaner($data{'device'}); - if ( !$data{'device'} || ($model && $model !~ /\Q$device_temp\E/i) ){ + if (!$data{'device'} || ($model && $model !~ /\Q$device_temp\E/i)){ $model = main::arm_cleaner($model); $data{'model'} = $model; } @@ -13714,19 +13747,19 @@ sub machine_data_dmi { foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Release Date') { + if ($value[0] eq 'Release Date'){ $data{'bios_date'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Vendor') { + elsif ($value[0] eq 'Vendor'){ $data{'bios_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') { + elsif ($value[0] eq 'Version'){ $data{'bios_version'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'ROM Size') { + elsif ($value[0] eq 'ROM Size'){ $data{'bios_romsize'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'BIOS Revision') { + elsif ($value[0] eq 'BIOS Revision'){ $data{'bios_rev'} = main::dmi_cleaner($value[1]) } } else { - if ($item eq '~UEFI is supported') { + if ($item eq '~UEFI is supported'){ $data{'firmware'} = 'UEFI';} } } @@ -13738,15 +13771,15 @@ sub machine_data_dmi { foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Product Name') { + if ($value[0] eq 'Product Name'){ $data{'product_name'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') { + elsif ($value[0] eq 'Version'){ $data{'product_version'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Serial Number') { + elsif ($value[0] eq 'Serial Number'){ $data{'product_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') { + elsif ($value[0] eq 'Manufacturer'){ $data{'sys_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'UUID') { + elsif ($value[0] eq 'UUID'){ $data{'sys_uuid'} = main::dmi_cleaner($value[1]) } } } @@ -13758,13 +13791,13 @@ sub machine_data_dmi { foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Product Name') { + if ($value[0] eq 'Product Name'){ $data{'board_name'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Serial Number') { + elsif ($value[0] eq 'Serial Number'){ $data{'board_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') { + elsif ($value[0] eq 'Manufacturer'){ $data{'board_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') { + elsif ($value[0] eq 'Version'){ $data{'board_version'} = main::dmi_cleaner($value[1]) } } } @@ -13776,17 +13809,17 @@ sub machine_data_dmi { foreach my $item (@$row[3 .. $#$row]){ if ($item !~ /^~/){ # skip the indented rows my @value = split(/:\s+/, $item); - if ($value[0] eq 'Serial Number') { + if ($value[0] eq 'Serial Number'){ $data{'chassis_serial'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Type') { + elsif ($value[0] eq 'Type'){ $data{'chassis_type'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Manufacturer') { + elsif ($value[0] eq 'Manufacturer'){ $data{'chassis_vendor'} = main::dmi_cleaner($value[1]) } - elsif ($value[0] eq 'Version') { + elsif ($value[0] eq 'Version'){ $data{'chassis_version'} = main::dmi_cleaner($value[1]) } } } - if ( $data{'chassis_type'} && $data{'chassis_type'} ne 'Other' ){ + if ($data{'chassis_type'} && $data{'chassis_type'} ne 'Other'){ $data{'device'} = $data{'chassis_type'}; } next; @@ -13826,9 +13859,9 @@ sub machine_data_sysctl { my (%data,$product,$vendor,$vm); # ^hw\.(vendor|product|version|serialno|uuid) foreach (@{$sysctl{'machine'}}){ - next if ! $_; + next if !$_; my @item = split(':', $_); - next if ! $item[1]; + next if !$item[1]; if ($item[0] eq 'hw.vendor' || $item[0] eq 'machdep.dmi.board-vendor'){ $data{'board_vendor'} = main::dmi_cleaner($item[1]); } @@ -13869,7 +13902,7 @@ sub machine_data_sysctl { $data{'bios_rev'} = $1; $data{'firmware'} = 'BIOS' if $_ =~ /BIOS/; } - elsif ($item[1] =~ /^vendor\s(.*?)\sversion\s(.*?)\sdate\s([\S]+)/ ){ + elsif ($item[1] =~ /^vendor\s(.*?)\sversion\s(.*?)\sdate\s([\S]+)/){ $data{'bios_vendor'} = $1; $data{'bios_version'} = $2; $data{'bios_date'} = $3; @@ -13955,7 +13988,7 @@ sub get_device_vm { $manufacturer ||= ''; $product_name ||= ''; my $vm; - if ( my $program = main::check_program('systemd-detect-virt') ){ + if (my $program = main::check_program('systemd-detect-virt')){ my $vm_test = (main::grabber("$program 2>/dev/null"))[0]; if ($vm_test){ # kvm vbox reports as oracle, usually, unless they change it @@ -13967,7 +14000,7 @@ sub get_device_vm { } } } - if (!$vm || lc($vm) eq 'bochs') { + if (!$vm || lc($vm) eq 'bochs'){ if (-e '/proc/vz'){$vm = 'openvz'} elsif (-e '/proc/xen'){$vm = 'xen'} elsif (-e '/dev/vzfs'){$vm = 'virtuozzo'} @@ -13981,7 +14014,7 @@ sub get_device_vm { } } # this will catch many Linux systems and some BSDs - if (!$vm || lc($vm) eq 'bochs' ) { + if (!$vm || lc($vm) eq 'bochs'){ # $device_vm is '' if nothing detected my @vm_data = ($device_vm); push(@vm_data,@{$dboot{'machine-vm'}}) if $dboot{'machine-vm'}; @@ -13989,7 +14022,7 @@ sub get_device_vm { my @dev = glob('/dev/disk/by-id/*'); push(@vm_data,@dev); } - if ( grep {/innotek|vbox|virtualbox/i} @vm_data){ + if (grep {/innotek|vbox|virtualbox/i} @vm_data){ $vm = 'virtualbox'; } elsif (grep {/vmware/i} @vm_data){ @@ -14017,7 +14050,7 @@ sub get_device_vm { $vm = 'virtual-machine' if grep {/^flags.*hypervisor/} @info; } # this may be wrong, confirm it - if (!$vm && -e '/dev/vda' || -e '/dev/vdb' || -e '/dev/xvda' || -e '/dev/xvdb' ){ + if (!$vm && -e '/dev/vda' || -e '/dev/vdb' || -e '/dev/xvda' || -e '/dev/xvdb'){ $vm = 'virtual-machine'; } } @@ -14152,7 +14185,7 @@ sub device_output { } $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,'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){ @@ -14259,7 +14292,7 @@ sub advanced_data_sys { @paths = main::globber('/sys/class/net/*'); } @paths = grep {!/\/lo$/} @paths; - if ( $count > 0 && $count < scalar @paths ){ + if ($count > 0 && $count < scalar @paths){ @paths = splice(@paths, $count, scalar @paths); } if ($vendor eq 'check'){ @@ -14273,7 +14306,7 @@ sub advanced_data_sys { # for usb, we already know where we are if (!$b_usb){ # pi mmcnr has pcitool and also these vendor/device paths. - if (( !$b_arm && !$b_ppc) || $use{'pci-tool'} ){ + if ((!$b_arm && !$b_ppc) || $use{'pci-tool'}){ $path = "$_/device/vendor"; $data1 = main::reader($path,'',0) if -r $path; $data1 =~ s/^0x// if $data1; @@ -14286,15 +14319,15 @@ sub advanced_data_sys { # there are cases where arm devices have a small pci bus # or, with mmcnr devices, will show device/vendor info in data1/2 # which won't match with the path IDs - if (($b_arm || $b_ppc || $b_mips || $b_sparc) && $chip && Cwd::abs_path($_) =~ /\b$chip\b/) { + if (($b_arm || $b_ppc || $b_mips || $b_sparc) && $chip && Cwd::abs_path($_) =~ /\b$chip\b/){ $data1 = $vendor; $data2 = $chip; } } # print "d1:$data1 v:$vendor d2:$data2 c:$chip bus_id: $bus_id\n"; # print Cwd::abs_path($_), "\n" if $bus_id; - if ( $b_usb || $b_check || ( $data1 && $data2 && $data1 eq $vendor && $data2 eq $chip && - ( ($b_arm || $b_mips || $b_ppc || $b_sparc) || check_bus_id($_,$bus_id) ) ) ) { + if ($b_usb || $b_check || ($data1 && $data2 && $data1 eq $vendor && $data2 eq $chip && + (($b_arm || $b_mips || $b_ppc || $b_sparc) || check_bus_id($_,$bus_id)))){ $if = $_; $if =~ s/^\/.+\///; # print "top: if: $if ifs: @ifs_found\n"; @@ -14323,10 +14356,10 @@ sub advanced_data_sys { # note that some cards show 'unknown' for state, so only testing explicitly # for 'down' string in that to skip showing speed/duplex # /sys/class/net/$if/wireless : not always there, but worth a try: wlan/wl/ww/wlp - $b_wifi = 1 if !$b_wifi && ( -e "$_$if/wireless" || $if =~ /^(wl|ww)/); + $b_wifi = 1 if !$b_wifi && (-e "$_$if/wireless" || $if =~ /^(wl|ww)/); 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; + $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; } @@ -14389,14 +14422,14 @@ sub advanced_data_bsd { main::key($num++,1,$cont_if,$key) => $if, main::key($num++,0,$ind_if,'state') => $state, },); - push(@ifs_found, $if) if (!$b_check && (! grep {/$if/} @ifs_found )); + push(@ifs_found, $if) if (!$b_check && (!grep {/$if/} @ifs_found)); # print "push: if: $if ifs: @ifs_found\n"; # no print out for wifi since it doesn't have duplex/speed data available # note that some cards show 'unknown' for state, so only testing explicitly # for 'down' string in that to skip showing speed/duplex if (!$b_wifi && $state ne 'down' && $state ne 'no network'){ # make sure the value is strictly numeric before appending Mbps - $speed = ( main::is_int($speed) ) ? "$speed Mbps" : $speed; + $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; } @@ -14469,7 +14502,7 @@ sub if_ip { # scope link # trim off if at end of multi word string if found $data2->[4] =~ s/\s$if$// if $data2->[4] =~ /[^\s]+\s$if$/; - my $key = ($data2->[4] =~ /deprecated|dynamic|temporary|noprefixroute/ ) ? 'type':'virtual' ; + my $key = ($data2->[4] =~ /deprecated|dynamic|temporary|noprefixroute/) ? 'type' : 'virtual'; push(@rows, { main::key($num++,1,$cont_ip,"IP v$ipv") => $ip, main::key($num++,0,$ind_ip,$key) => $data2->[4], @@ -14485,7 +14518,7 @@ sub if_ip { } else { push(@rows, { - main::key($num++,1,($cont_ip - 1 ),'IF') => $if, + main::key($num++,1,($cont_ip - 1),'IF') => $if, main::key($num++,1,$cont_ip,"IP v$ipv") => $ip, main::key($num++,0,$ind_ip,'scope') => $scope, },); @@ -14503,8 +14536,8 @@ sub if_ip { # get ip using downloader to stdout. This is a clean, text only IP output url, # single line only, ending in the ip address. May have to modify this in the future # to handle ipv4 and ipv6 addresses but should not be necessary. -# ip=$( echo 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | gawk --re-interval ' -# ip=$( wget -q -O - $WAN_IP_URL | gawk --re-interval ' +# ip=$(echo 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | gawk --re-interval ' +# ip=$(wget -q -O - $WAN_IP_URL | gawk --re-interval ' # this generates a direct dns based ipv4 ip address, but if opendns.com goes down, # the fall backs will still work. # note: consistently slower than domain based: @@ -14521,11 +14554,11 @@ sub wan_ip { # dig +short @ns1-1.akamaitech.net ANY whoami.akamai.net # this one can take forever, and sometimes requires explicit -4 or -6 # dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com - if (!$force{'no-dig'} && (my $program = main::check_program('dig') )){ + if (!$force{'no-dig'} && (my $program = main::check_program('dig'))){ $ip = (main::grabber("$program +short +time=1 +tries=1 \@ns1-1.akamaitech.net ANY whoami.akamai.net 2>/dev/null"))[0]; $b_dig = 1; } - if (!$ip && !$force{'no-html-wan'}) { + if (!$ip && !$force{'no-html-wan'}){ # note: tests: akamai: 0.055 - 0.065 icanhazip.com: 0.177 0.164 # smxi: 0.525, so almost 10x slower. Dig is fast too # leaving smxi as last test because I know it will always be up. @@ -14534,7 +14567,7 @@ sub wan_ip { # 0.255s: https://get.geojs.io/v1/ip # 0.371s: http://icanhazip.com/ # 0.430s: https://smxi.org/opt/ip.php - my @urls = (!$wan_url) ? qw( http://whatismyip.akamai.com/ + my @urls = (!$wan_url) ? qw(http://whatismyip.akamai.com/ http://icanhazip.com/ https://smxi.org/opt/ip.php) : ($wan_url); foreach (@urls){ $ua = 'ip' if $_ =~ /smxi/; @@ -14577,8 +14610,8 @@ sub check_bus_id { # legacy, not link, but uevent has path: # PHYSDEVPATH=/devices/pci0000:00/0000:00:0a.1/0000:05:00.0 if (Cwd::abs_path($path) =~ /$bus_id\// || - ( -r "$path/uevent" && -s "$path/uevent" && - (grep {/$bus_id/} main::reader("$path/uevent") ) ) ){ + (-r "$path/uevent" && -s "$path/uevent" && + (grep {/$bus_id/} main::reader("$path/uevent")))){ $b_valid = 1; } } @@ -14609,7 +14642,7 @@ sub get { } else{ my $file = $system_files{'dmesg-boot'}; - if ( $file && ! -r $file ){ + if ($file && ! -r $file){ $val1 = main::row_defaults('dmesg-boot-permissions'); } elsif (!$file){ @@ -14677,17 +14710,17 @@ sub drive_output { $speed ||= 'N/A'; my ($audio,$multisession) = ('',''); if (defined $drives->{$key}{'multisession'}){ - $multisession = ( $drives->{$key}{'multisession'} == 1 ) ? 'yes' : 'no' ; + $multisession = ($drives->{$key}{'multisession'} == 1) ? 'yes' : 'no' ; } $multisession ||= 'N/A'; if (defined $drives->{$key}{'audio'}){ - $audio = ( $drives->{$key}{'audio'} == 1 ) ? 'yes' : 'no' ; + $audio = ($drives->{$key}{'audio'} == 1) ? 'yes' : 'no' ; } $audio ||= 'N/A'; my $dvd = 'N/A'; my (@rw,$rws); if (defined $drives->{$key}{'dvd'}){ - $dvd = ( $drives->{$key}{'dvd'} == 1 ) ? 'yes' : 'no' ; + $dvd = ($drives->{$key}{'dvd'} == 1) ? 'yes' : 'no' ; } if ($drives->{$key}{'cdr'}){ push(@rw, 'cd-r'); @@ -14710,7 +14743,7 @@ sub drive_output { main::key($num++,0,3,'dvd') => $dvd, main::key($num++,0,3,'rw') => $rws, }); - if ($extra > 0 ){ + if ($extra > 0){ my $state = $drives->{$key}{'state'}; $state ||= 'N/A'; $rows[$j]->{ main::key($num++,0,3,'state')} = $state; @@ -14751,7 +14784,7 @@ sub drive_data_bsd { if ($count && $count > 1){ @temp = split(/\s+/, $drives{$working}->{'model'}); $drives{$working}->{'vendor'} = $temp[0]; - my $index = ($#temp > 2 ) ? ($#temp - 1): $#temp; + my $index = ($#temp > 2) ? ($#temp - 1): $#temp; $drives{$working}->{'model'} = join(' ', @temp[1..$index]); $drives{$working}->{'rev'} = $temp[-1] if $count > 2; } @@ -14856,7 +14889,7 @@ sub drive_data_linux { foreach my $key (keys %drives){ next if $drives{$key}->{'type'} eq 'floppy'; my $device = "/sys/block/$key/device"; - if ( -d $device){ + if (-d $device){ if (-r "$device/vendor"){ $drives{$key}->{'vendor'} = main::reader("$device/vendor",'',0); $drives{$key}->{'vendor'} = main::cleaner($drives{$key}->{'vendor'}); @@ -14866,7 +14899,7 @@ sub drive_data_linux { $drives{$key}->{'rev'} = main::reader("$device/rev",'',0); } } - elsif ( -r "/proc/ide/$key/model"){ + elsif (-r "/proc/ide/$key/model"){ $drives{$key}->{'vendor'} = main::reader("/proc/ide/$key/model",'',0); $drives{$key}->{'vendor'} = main::cleaner($drives{$key}->{'vendor'}); } @@ -14880,33 +14913,33 @@ sub drive_data_linux { last if ($id eq $key); $index++; } - last if ! $index; # index will be > 0 if it was found + last if !$index; # index will be > 0 if it was found } - elsif ($item =~/^drive speed:/) { + elsif ($item =~/^drive speed:/){ $drives{$key}->{'speed'} = $split[$index]; } - elsif ($item =~/^Can read multisession:/) { + elsif ($item =~/^Can read multisession:/){ $drives{$key}->{'multisession'}=$split[$index+1]; } - elsif ($item =~/^Can read MCN:/) { + elsif ($item =~/^Can read MCN:/){ $drives{$key}->{'mcn'}=$split[$index+1]; } - elsif ($item =~/^Can play audio:/) { + elsif ($item =~/^Can play audio:/){ $drives{$key}->{'audio'}=$split[$index+1]; } - elsif ($item =~/^Can write CD-R:/) { + elsif ($item =~/^Can write CD-R:/){ $drives{$key}->{'cdr'}=$split[$index+1]; } - elsif ($item =~/^Can write CD-RW:/) { + elsif ($item =~/^Can write CD-RW:/){ $drives{$key}->{'cdrw'}=$split[$index+1]; } - elsif ($item =~/^Can read DVD:/) { + elsif ($item =~/^Can read DVD:/){ $drives{$key}->{'dvd'}=$split[$index+1]; } - elsif ($item =~/^Can write DVD-R:/) { + elsif ($item =~/^Can write DVD-R:/){ $drives{$key}->{'dvdr'}=$split[$index+1]; } - elsif ($item =~/^Can write DVD-RAM:/) { + elsif ($item =~/^Can write DVD-RAM:/){ $drives{$key}->{'dvdram'}=$split[$index+1]; } } @@ -14929,7 +14962,7 @@ sub get { my (@rows,$key1,$val1); my $num = 0; set_partitions() if !$loaded{'set-partitions'}; - if (!@partitions) { + if (!@partitions){ $key1 = 'Message'; #$val1 = ($bsd_type && $bsd_type eq 'darwin') ? # main::row_defaults('darwin-feature') : main::row_defaults('partition-data'); @@ -14954,6 +14987,7 @@ sub create_output { else { @partitions = sort { $a->{$show{'partition-sort'}} <=> $b->{$show{'partition-sort'}} } @partitions; } + my $fs_skip = fs_excludes('label-uuid'); foreach my $row (@partitions){ $num = 1; next if $row->{'type'} eq 'secondary' && $show{'partition'}; @@ -14977,7 +15011,7 @@ sub create_output { push(@rows, { main::key($num++,1,1,'ID') => $row->{'id'}, }); - if (($b_admin || $row->{'hidden'}) && $row->{'raw-size'} ){ + 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; @@ -15010,15 +15044,21 @@ sub create_output { $rows[$j]->{main::key($num++,0,3,'mapped')} = $row->{'dev-mapped'}; } # add fs known to not use label/uuid here - if (($dev_type eq 'dev' && $fs !~ /^(ffs)$/) || - $row->{'label'} || $row->{'uuid'}){ + if (($show{'label'} || $show{'uuid'}) && + $dev_type eq 'dev' && $fs !~ /^(fuse(blk)?[\._-]?)?($fs_skip)$/){ 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'; + if ($use{'filter-label'}){ + $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, ''); + } + $row->{'label'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'}; } 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'; + if ($use{'filter-uuid'}){ + $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, ''); + } + $row->{'uuid'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; } } } @@ -15108,7 +15148,7 @@ sub set_partitions { my @row = split(/\s+/, $_); # autofs is a bsd thing, has size 0 if ($row[0] =~ /^($filters)$/ || $row[0] =~ /^ROOT/i || - ($b_fs && ($row[2] == 0 || $row[1] =~ /^(autofs|devtmpfs|iso9660|tmpfs)$/ ) )){ + ($b_fs && ($row[2] == 0 || $row[1] =~ /^(autofs|devtmpfs|iso9660|tmpfs)$/))){ next; } ($dev_base,$dev_mapped,$dev_type,$fs,$id,$label, @@ -15146,7 +15186,7 @@ sub set_partitions { # note: Main/jails/transmission_1 path can be > 1 deep # Main zfs 3678031340 8156 3678023184 0% /mnt/Main if (!$dev_base && ($row[0] =~ /^([^\/]+\/)(.+)/ || - ($row[0] =~ /^[^\/]+$/ && $row[1] =~ /^(btrfs|hammer[2-9]?|zfs)$/ ) ) ){ + ($row[0] =~ /^[^\/]+$/ && $row[1] =~ /^(btrfs|hammer[2-9]?|zfs)$/))){ $dev_base = $row[0]; $dev_type = 'logical'; } @@ -15173,19 +15213,19 @@ sub set_partitions { else { $fs = get_mounts_fs($row[0],\@mount); } - if ($show{'label'}) { - if ($part{'label'}) { + if ($show{'label'}){ + if ($part{'label'}){ $label = $part{'label'}; } elsif (@labels){ $label = get_label($row[0]); } } - if ($show{'uuid'}) { - if ($part{'uuid'}) { + if ($show{'uuid'}){ + if ($part{'uuid'}){ $uuid = $part{'uuid'}; } - elsif ( @uuids){ + elsif (@uuids){ $uuid = get_uuid($row[0]); } } @@ -15194,7 +15234,7 @@ sub set_partitions { $fs = ($b_fs) ? $row[1]: get_mounts_fs($row[0],\@mount); } # assuming that all null/nullfs are parts of a logical fs - $b_logical = 1 if $fs && $fs =~ /^(hammer|null|zfs)/; + $b_logical = 1 if $fs && $fs =~ /^(btrfs|hammer|null|zfs)/; $id = join(' ', @row[$cols .. $#row]); $size = $row[$cols - $back_size]; if ($b_admin && -e "/sys/block/"){ @@ -15237,7 +15277,7 @@ sub set_partitions { $uuid = $temp{'uuid'}; } $used = $row[$cols - $back_used]; - $percent_used = sprintf("%.1f", ( $used/$size )*100) if ($size && main::is_numeric($size) ); + $percent_used = sprintf("%.1f", ($used/$size)*100) if ($size && main::is_numeric($size)); push(@partitions,{ 'block-size' => $block_size, 'dev-base' => $dev_base, @@ -15277,10 +15317,10 @@ sub swap_data { my ($s,$j,$size_id,$used_id) = (1,0,2,3); if (!$bsd_type){ # faster, avoid subshell, same as swapon -s - if ( -r '/proc/swaps'){ + if (-r '/proc/swaps'){ @working = main::reader("/proc/swaps"); } - elsif ( $path = main::check_program('swapon') ){ + elsif ($path = main::check_program('swapon')){ # note: while -s is deprecated, --show --bytes is not supported # on older systems @working = main::grabber("$path -s 2>/dev/null"); @@ -15290,11 +15330,14 @@ sub swap_data { $swappiness = $data[0]; $cache_pressure = $data[1]; } + if (($show{'label'} || $show{'uuid'}) && !$loaded{'label-uuid'}){ + set_label_uuid(); + } $pattern1 = 'partition|file|ram'; $pattern2 = '[^\s].*[^\s]'; } else { - if ( $path = main::check_program('swapctl') ){ + if ($path = main::check_program('swapctl')){ # output in in KB blocks @working = main::grabber("$path -l -k 2>/dev/null"); } @@ -15356,7 +15399,7 @@ sub swap_data { } $size = $data[$size_id]; $used = $data[$used_id]; - $percent_used = sprintf("%.1f", ( $used/$size )*100); + $percent_used = sprintf("%.1f", ($used/$size)*100); push(@swaps, { 'block-size' => $block_size, 'cache-pressure' => $cache_pressure, @@ -15458,13 +15501,31 @@ sub check_partition_data { # all here for: subs partitiion_data(), check_partition_data() # note: p_d filters 'filesystem', and c_p_d filters against fs sub partition_filters { - my $filters = 'aufs|cgroup.*|cgmfs|configfs|debugfs|\/dev|dev|'; - $filters .= '\/dev\/loop[0-9]*|devfs|devtmpfs|fdescfs|iso9660|'; - $filters .= 'kernfs|linprocfs|linsysfs|none|overla(id|y)|procfs|ptyfs|'; - $filters .= '/run(\/.*)?|run|shm|squashfs|swap|sys|\/sys\/.*|sysfs|'; - $filters .= 'tmpfs|type|udev|unionfs|vartmp'; + # snap mounts with squashfs; appimage/flatpak mount? + # swap is set in swap_data(); cgmfs is in ram, like devfs, sysfs; + # union fs types: aufs, overlayfs, unionfs, mergerfs + my $filters = 'aufs|cgroup.*|cgmfs|configfs|debugfs|\/dev|dev|\/dev\/loop[0-9]*|'; + $filters .= 'devfs|devtmpfs|efivarfs|fdescfs|hugetlbfs|iso9660|kernfs|'; + $filters .= 'linprocfs|linsysfs|none|overla(id|y)(fs)?|procfs|ptyfs|'; + $filters .= '/run(\/.*)?|run|securityfs|shm|squashfs|swap|sys|\/sys\/.*|sysfs|'; + $filters .= 'tmpfs|tracefs|type|udev|unionfs|vartmp'; return $filters } +# used to exclude disk used, partition/unmounted/swap label/uuid, unmounted label/uuid +# see docs/inxi-data.txt PARTITION DATA for more on remote/fuse fs +sub fs_excludes { + my ($source) = @_; + # panfs is parallel NAS volume manager, need more data + # null is hammer fs slice; nfs/nfs3/nfs4; some can be fuse mounts: fuse.sshfs + my $excludes = 'afs|archivemount(fs)?|aufs|avfs|ceph|cifs|gfs\d{0,2}|glusterfs|'; + $excludes .= 'gmailfs|hdfs|ipfs|iso9660||k(osmos)?fs|.*lafs|mhddfs|mergerfs|'; + $excludes .= 'moosefs|nfs\d{0,2}|null(fs)?|ocfs\d{0,2}|openafs|orangefs|'; + $excludes .= 'overla(id|y)(fs)?|panfs|pvfs\d{0,2}|s3fs|sheepdog|squashfs|'; + $excludes .= 'sshfs|smbfs|unionfs|vmfs'; + # for non disk used excludes + $excludes .= '|ffs|fuse(blk)?' if $source eq 'label-uuid'; + return $excludes; +} sub get_mounts_fs { eval $start if $b_log; my ($item,$mount) = @_; @@ -15484,7 +15545,6 @@ sub get_mounts_fs { $fs = $1; last; } - } eval $end if $b_log; main::log_data('data',"fs: $fs") if $b_log; @@ -15493,14 +15553,14 @@ sub get_mounts_fs { sub set_label_uuid { eval $start if $b_log; $loaded{'label-uuid'} = 1; - if ($show{'unmounted'} || $show{'label'} || $show{'swap'} || $show{'uuid'} ){ + if ($show{'unmounted'} || $show{'label'} || $show{'swap'} || $show{'uuid'}){ if (-d '/dev/disk/by-label'){ @labels = main::globber('/dev/disk/by-label/*'); } if (-d '/dev/disk/by-uuid'){ @uuids = main::globber('/dev/disk/by-uuid/*'); } - main::log_data('dump', '@lebels', \@labels) if $b_log; + main::log_data('dump', '@labels', \@labels) if $b_log; main::log_data('dump', '@uuids', \@uuids) if $b_log; } eval $end if $b_log; @@ -15525,7 +15585,7 @@ sub admin_data { $size_raw = 'N/A'; } else { - $percent = sprintf("%.2f", ($size/$size_raw ) * 100) if $size && $size_raw; + $percent = sprintf("%.2f", ($size/$size_raw) * 100) if $size && $size_raw; } # print "$id size: $size %: $percent p-b: $block_size raw: $size_raw\n"; @sizes = ($size_raw,$percent,$block_size); @@ -15625,7 +15685,7 @@ sub get { my $key = 'Message'; push(@rows, ({ main::key($num++,0,1,$key) => main::row_defaults('ps-data-null',''), - },) ); + },)); } eval $end if $b_log; return @rows; @@ -15664,20 +15724,20 @@ sub cpu_processes { $j = scalar @processes; my @row = split(/\s+/, $_); my @command = process_starter(scalar @row, $row[$ps_cols],$row[$ps_cols + 1]); - $cpu = ($ps_cols >= 10 ) ? $row[2] . '%': 'N/A'; + $cpu = ($ps_cols >= 10) ? $row[2] . '%': 'N/A'; @data = ({ main::key($num++,1,2,$i++) => '', main::key($num++,0,3,'cpu') => $cpu, main::key($num++,1,3,'command') => $command[0], },); push(@processes,@data); - if ($command[1]) { + if ($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; if ($extra > 0 && $ps_cols >= 10){ - my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; + 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; @@ -15722,7 +15782,7 @@ sub mem_processes { $j = scalar @processes; my @row = split(/\s+/, $_); if ($ps_cols >= 10){ - my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; + my $decimals = ($row[5]/1024 > 10) ? 1 : 2; $mem = (main::is_int($row[5])) ? sprintf("%.${decimals}f", $row[5]/1024) . ' MiB' : 'N/A'; $mem .= " (" . $row[3] . "%)"; } @@ -15736,7 +15796,7 @@ sub mem_processes { main::key($num++,1,3,'command') => $command[0], },); push(@processes,@data); - if ($command[1]) { + if ($command[1]){ $processes[$j]->{main::key($num++,0,4,'started by')} = $command[1]; } $pid = (defined $pid_col)? $row[$pid_col] : 'N/A'; @@ -15790,10 +15850,12 @@ sub get { my $num = 0; @hardware_raid = hw_data() if $use{'hardware-raid'} || $fake{'raid-hw'}; raid_data() if !$loaded{'raid'}; - # print 'get: ', Data::Dumper::Dumper \@lvm_raid; - # print 'get: ', Data::Dumper::Dumper \@md_raid; - # print 'get: ', Data::Dumper::Dumper \@zfs_raid; - if (!@lvm_raid && !@md_raid && !@zfs_raid && !@soft_raid && !@hardware_raid){ + # print 'get btrfs: ', Data::Dumper::Dumper \@btrfs_raid; + # print 'get lvm: ', Data::Dumper::Dumper \@lvm_raid; + # print 'get md: ', Data::Dumper::Dumper \@md_raid; + # print 'get zfs: ', Data::Dumper::Dumper \@zfs_raid; + if (!@btrfs_raid && !@lvm_raid && !@md_raid && !@zfs_raid && !@soft_raid && + !@hardware_raid){ if ($show{'raid-forced'}){ $key1 = 'Message'; $val1 = main::row_defaults('raid-data'); @@ -15803,6 +15865,9 @@ sub get { if (@hardware_raid){ push(@rows,hw_output(\@hardware_raid)); } + if (@btrfs_raid){ + push(@rows,btrfs_output()); + } if (@lvm_raid){ push(@rows,lvm_output()); } @@ -15861,6 +15926,23 @@ sub hw_output { # print Data::Dumper::Dumper \@rows; return @rows; } +sub btrfs_output { + eval $start if $b_log; + my (@components,@good,@rows); + my ($size); + my ($j,$num) = (0,0); + foreach my $row (sort {$a->{'id'} cmp $b->{'id'}} @btrfs_raid){ + + $j = scalar @rows; + $rows[$j]->{main::key($num++,1,2,'Components')} = ''; + my $b_bump; + components_output('lvm','Online',\@rows,\@good,\$j,\$num,\$b_bump); + components_output('lvm','Meta',\@rows,\@components,\$j,\$num,\$b_bump); + } + eval $end if $b_log; + # print Data::Dumper::Dumper \@rows; + return @rows; +} sub lvm_output { eval $start if $b_log; my (@components,@good,@components_meta,@rows); @@ -15889,7 +15971,7 @@ sub lvm_output { if (defined $row->{'stripes'}){ $rows[$j]->{main::key($num++,0,3,'stripes')} = $row->{'stripes'}; } - if (defined $row->{'raid-mismatches'} && ($extra > 1 || $row->{'raid-mismatches'} > 0 )){ + if (defined $row->{'raid-mismatches'} && ($extra > 1 || $row->{'raid-mismatches'} > 0)){ $rows[$j]->{main::key($num++,0,3,'mismatches')} = $row->{'raid-mismatches'}; } if (defined $row->{'copy-percent'} && ($extra > 1 || $row->{'copy-percent'} < 100)){ @@ -16002,7 +16084,7 @@ sub md_output { elsif (defined $item->[2] && $item->[2] =~ /(S)$/){ push(@spare,$item); } - elsif ($row->{'status'} && $row->{'status'} eq 'inactive' ){ + elsif ($row->{'status'} && $row->{'status'} eq 'inactive'){ push(@inactive,$item); } else { @@ -16129,7 +16211,7 @@ sub zfs_output { @arrays = grep {defined $_} @arrays; @arrays_holder = @arrays; my $count = scalar @arrays; - if (!defined $arrays[0]->{'level'} ){ + if (!defined $arrays[0]->{'level'}){ $level = 'linear'; $rows[$j]->{main::key($num++,0,2,'level')} = $level; } @@ -16227,7 +16309,10 @@ sub components_output { my ($type,$item,$rows_ref,$array_ref,$j_ref,$num_ref,$b_bump_ref) = @_; return if !@$array_ref && $item ne 'Online'; my ($extra1,$extra2,$f1,$f2,$f3,$f4,$f5,$k,$k1,$key1,$l1,$l2,$l3); - if ($type eq 'lvm'){ + if ($type eq 'btrfs'){ + + } + elsif ($type eq 'lvm'){ ($f1,$f2,$f3,$f4,$f5,$l1,$l2,$l3) = (1,2,3,4,5,3,4,5); $k = 1; $extra1 = 'mapped'; @@ -16250,7 +16335,7 @@ sub components_output { # print "item: $item\n"; $$j_ref++ if $$b_bump_ref; $$b_bump_ref = 0; - my $good = ($item eq 'Online' && !@$array_ref ) ? 'N/A' : ''; + my $good = ($item eq 'Online' && !@$array_ref) ? 'N/A' : ''; $$rows_ref[$$j_ref]->{main::key($$num_ref++,1,$l1,$item)} = $good; #$$j_ref++ if $b_admin; # print Data::Dumper::Dumper $array_ref; @@ -16291,8 +16376,12 @@ sub raid_data { PartitionData::set() if !$bsd_type && !$loaded{'partition-data'}; my (@data); $loaded{'raid'} = 1; + if ($fake{'raid-btrfs'} || + ($alerts{'btrfs'}->{'action'} && $alerts{'btrfs'}->{'action'} eq 'use')){ + @btrfs_raid = btrfs_data(); + } if ($fake{'raid-lvm'} || - ($alerts{'lvs'}->{'action'} && $alerts{'lvs'}->{'action'} eq 'use')){ + ($alerts{'lvs'}->{'action'} && $alerts{'lvs'}->{'action'} eq 'use')){ @lvm_raid = lvm_data(); } if ($fake{'raid-md'} || (my $file = $system_files{'proc-mdstat'})){ @@ -16302,7 +16391,7 @@ sub raid_data { DiskDataBSD::set() if !$loaded{'disk-data-bsd'}; @soft_raid = soft_data(); } - if ($fake{'raid-zfs'} || (my $path = main::check_program('zpool') )){ + if ($fake{'raid-zfs'} || (my $path = main::check_program('zpool'))){ DiskDataBSD::set() if $bsd_type && !$loaded{'disk-data-bsd'}; @zfs_raid = zfs_data($path); } @@ -16349,6 +16438,22 @@ sub hw_data { eval $end if $b_log; return @hardware_raid; } +sub btrfs_data { + eval $start if $b_log; + my (@btraid,@working); + if ($fake{'raid-btrfs'}){ + + } + else { + + } + print Data::Dumper::Dumper \@working if $dbg[37]; + + print Data::Dumper::Dumper \@btraid if $dbg[37]; + main::log_data('dump','@lvraid',\@btraid) if $b_log; + eval $end if $b_log; + return @btraid; +} sub lvm_data { eval $start if $b_log; LogicalItem::lvm_data() if !$loaded{'logical-data'}; @@ -16402,7 +16507,7 @@ sub lvm_data { 'vg-used' => $vg_used, }); } - # print Data::Dumper::Dumper \@lvraid; + print Data::Dumper::Dumper \@lvraid if $dbg[37]; main::log_data('dump','@lvraid',\@lvraid) if $b_log; eval $end if $b_log; return @lvraid; @@ -16411,7 +16516,7 @@ sub md_data { eval $start if $b_log; my ($mdstat) = @_; my $j = 0; - if ($fake{'raid-md'}) { + if ($fake{'raid-md'}){ #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-4-device-1.txt"; #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-rebuild-1.txt"; #$mdstat = "$ENV{'HOME'}/bin/scripts/inxi/data/raid/md-2-mirror-fserver2-1.txt"; @@ -16426,12 +16531,12 @@ sub md_data { my (@mdraid,@temp,$b_found,$system,$unused); # NOTE: a system with empty mdstat will not show these values if ($working[0] && $working[0] =~ /^Personalities/){ - $system = ( split(/:\s*/, $working[0]))[1]; + $system = (split(/:\s*/, $working[0]))[1]; $system =~ s/\[|\]//g if $system; shift @working; } if ($working[-1] && $working[-1] =~ /^unused\sdevices/){ - $unused = ( split(/:\s*/, $working[-1]))[1]; + $unused = (split(/:\s*/, $working[-1]))[1]; $unused =~ s/<|>|none//g if $unused; pop @working; } @@ -16499,7 +16604,7 @@ sub md_data { $part_size = $part[2] if !$part_size; } } - if ((!$maj_min || !$part_size) && @lsblk) { + if ((!$maj_min || !$part_size) && @lsblk){ %data= LsblkData::get($name); $maj_min = $data{'maj-min'} if !$maj_min; $part_size = $data{'size'}if !$part_size; @@ -16558,7 +16663,7 @@ sub md_data { $mdraid[0]->{'supported-levels'} = $system if $system; $mdraid[0]->{'unused'} = $unused if $unused; } - # print Data::Dumper::Dumper \@mdraid; + print Data::Dumper::Dumper \@mdraid if $dbg[37]; eval $end if $b_log; return @mdraid; } @@ -16569,7 +16674,7 @@ sub md_details { my $cmd = $alerts{'mdadm'}->{'path'} . " --detail /dev/$id 2>/dev/null"; my @data = main::grabber($cmd,'','strip'); main::log_data('dump',"$id raw: \@data",\@data) if $b_log; - foreach (@data) { + foreach (@data){ @working = split(/\s*:\s*/, $_, 2); if (scalar @working == 2){ if ($working[0] eq 'Array Size' && $working[1] =~ /^([0-9]+)\s\(/){ @@ -16796,7 +16901,7 @@ sub zfs_data { # third is using /dev/disk/by-id # ata-VBOX_HARDDISK_VB5b6350cd-06618d58 - - - - - - - - ONLINE elsif ($row[1] =~ /^(sd[a-z]+|[a-z0-9]+[0-9]+|([\S]+)\/.*|(ata|mmc|nvme|pci|scsi|wwn)-\S+)$/ && - ($row[2] eq '-' || $row[2] =~ /^[0-9\.]+[MGTP]$/)){ + ($row[2] eq '-' || $row[2] =~ /^[0-9\.]+[MGTPE]$/)){ #print "r1:$row[1]",' :: ', Cwd::abs_path('/dev/disk/by-id/'.$row[1]), "\n"; $row[1] =~ /^(sd[a-z]+|[a-z0-9]+[0-9]+|([\S]+)\/.*|(ata|mmc|nvme|pci|scsi|wwn)-\S+)\s.*?(DEGRADED|FAULTED|OFFLINE)?$/; #my $working = ''; @@ -16820,17 +16925,17 @@ 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 = ($row[2])? main::translate_size($row[2]): ''; $size_holder = 0; $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; } - 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; } @@ -16860,7 +16965,7 @@ sub zfs_data { # clear out undefined arrrays values $j = 0; foreach my $row (@zfs){ - my @arrays = (ref $row->{'arrays'} eq 'ARRAY' ) ? @{$row->{'arrays'}} : (); + my @arrays = (ref $row->{'arrays'} eq 'ARRAY') ? @{$row->{'arrays'}} : (); @arrays = grep {defined $_} @arrays; $zfs[$j]->{'arrays'} = \@arrays; $j++; @@ -16902,7 +17007,7 @@ sub zfs_status { @pool_status = main::grabber($cmd,"\n",'strip'); } main::log_data('cmd',$cmd) if $b_log; - #@arrays = (ref $row->{'arrays'} eq 'ARRAY' ) ? @{$row->{'arrays'}} : (); + # @arrays = (ref $row->{'arrays'} eq 'ARRAY') ? @{$row->{'arrays'}} : (); # print "$row->{'id'} rs:$row->{'status'}\n"; $status = ($row->{'status'} && $row->{'status'} eq 'no-status') ? check_zfs_status($row->{'id'},\@pool_status): $row->{'status'}; $zfs->[$j]{'status'} = $status if $status; @@ -17033,7 +17138,7 @@ sub ram_output { $item->{'eec'} ||= 'N/A'; $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 ) ) ){ + (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'}); if ($item->{'mod-qualifier'}){ $rows[$j]->{main::key($num++,0,3,'note')} = $item->{'mod-qualifier'}; @@ -17050,7 +17155,7 @@ sub ram_output { foreach my $entry ($item->{'modules'}){ next if ref $entry ne 'ARRAY'; # print Data::Dumper::Dumper $entry; - foreach my $mod ( @$entry){ + foreach my $mod (@$entry){ $num = 1; $j = scalar @rows; # multi array setups will start index at next from previous array @@ -17067,7 +17172,7 @@ sub ram_output { main::key($num++,0,3,'size') => process_size($mod->{'size'}), }); next if ($mod->{'size'} =~ /\D/); - if ($extra > 1 && $mod->{'type'} ){ + if ($extra > 1 && $mod->{'type'}){ $rows[$j]->{main::key($num++,0,3,'info')} = $mod->{'type'}; } if ($mod->{'speed'} && $mod->{'configured-clock-speed'} && @@ -17090,7 +17195,7 @@ sub ram_output { $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 ){ + if ($extra > 0){ $mod->{'device-type'} ||= 'N/A'; $rows[$j]->{main::key($num++,0,3,'type')} = $mod->{'device-type'}; if ($extra > 2 && $mod->{'device-type'} ne 'N/A'){ @@ -17145,7 +17250,7 @@ sub dmidecode_data { if ($entry->[0] == 5){ foreach my $item (@$entry){ @temp = split(/:\s*/, $item, 2); - next if ! $temp[1]; + 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; @@ -17175,12 +17280,12 @@ sub dmidecode_data { my ($bank_locator,$device_type,$locator,$main_locator) = ('','','',''); foreach my $item (@$entry){ @temp = split(/:\s*/, $item, 2); - next if ! $temp[1]; + next if !$temp[1]; if ($temp[0] eq 'Installed Size'){ # get module size $size = calculate_size($temp[1],0); # using this causes issues, really only works for 16 -# if ($size =~ /^[0-9][0-9]+$/) { +# if ($size =~ /^[0-9][0-9]+$/){ # $ram[$k]->{'device-count-found'}++; # $ram[$k]->{'used-capacity'} += $size; # } @@ -17192,7 +17297,7 @@ sub dmidecode_data { elsif ($temp[0] eq 'Current Speed'){ $speed = main::dmi_cleaner($temp[1]); } - elsif ($temp[0] eq 'Locator' || $temp[0] eq 'Socket Designation' ){ + elsif ($temp[0] eq 'Locator' || $temp[0] eq 'Socket Designation'){ $temp[1] =~ s/D?RAM slot #?/Slot/i; # can be with or without # $locator = $temp[1]; } @@ -17206,7 +17311,7 @@ sub dmidecode_data { # because of the wide range of bank/slot type data, we will just use # the one that seems most likely to be right. Some have: Bank: SO DIMM 0 slot: J6A # so we dump the useless data and use the one most likely to be visibly correct - if ( $bank_locator =~ /DIMM/ ) { + if ($bank_locator =~ /DIMM/){ $main_locator = $bank_locator; } else { @@ -17229,7 +17334,7 @@ sub dmidecode_data { # ($derived_module_size,$max_cap_16) = (0,0); foreach my $item (@$entry){ @temp = split(/:\s*/, $item, 2); - next if ! $temp[1]; + 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; @@ -17268,7 +17373,7 @@ sub dmidecode_data { my ($device_size,$i_data,$i_total,$working_size) = (0,0,0,0); foreach my $item (@$entry){ @temp = split(/:\s*/, $item, 2); - next if ! $temp[1]; + next if !$temp[1]; if ($temp[0] eq 'Array Handle'){ $handle = hex($temp[1]); } @@ -17281,7 +17386,7 @@ sub dmidecode_data { # do not try to guess from installed modules, only use this to correct type 5 data elsif ($temp[0] eq 'Size'){ # we want any non real size data to be preserved - if ( $temp[1] =~ /^[0-9]+\s*[KkMTPG]i?B/ ) { + if ($temp[1] =~ /^[0-9]+\s*[KkMTPG]i?B/){ $derived_module_size = calculate_size($temp[1],$derived_module_size); $working_size = calculate_size($temp[1],0); $device_size = $working_size; @@ -17330,13 +17435,13 @@ sub dmidecode_data { # because of the wide range of bank/slot type data, we will just use # the one that seems most likely to be right. Some have: Bank: SO DIMM 0 slot: J6A # so we dump the useless data and use the one most likely to be visibly correct - if ( $bank_locator =~ /DIMM/ ) { + if ($bank_locator =~ /DIMM/){ $main_locator = $bank_locator; } else { $main_locator = $locator; } - if ($working_size =~ /^[0-9][0-9]+$/) { + if ($working_size =~ /^[0-9][0-9]+$/){ $ram[$handle]->{'device-count-found'}++; # build up actual capacity found for override tests $ram[$handle]->{'used-capacity'} += $working_size; @@ -17386,10 +17491,10 @@ sub dmidecode_data { $ram[$handle]->{'modules'}[$i]{'total-width'} = $total_width; $i++ } - elsif ($entry->[0] < 17 ){ + elsif ($entry->[0] < 17){ next; } - elsif ($entry->[0] > 17 ){ + elsif ($entry->[0] > 17){ last; } } @@ -17513,15 +17618,15 @@ sub process_data { print "1: mms: $item->{'max-module-size'} :dms: $item->{'derived-module-size'} :mc: $max_cap :uc: $item->{'used-capacity'}\n"; print "1a: s5: $item->{'slots-5'} s16: $item->{'slots-16'}\n"; } - if (!$max_cap && $item->{'max-capacity-5'}) { + if (!$max_cap && $item->{'max-capacity-5'}){ $max_cap = $item->{'max-capacity-5'}; } if ($b_debug){ print "2: mms: $item->{'max-module-size'} :dms: $item->{'derived-module-size'} :mc: $max_cap :uc: $item->{'used-capacity'}\n"; } # 2: now check to see if actually found module sizes are > than listed max module, replace if > - if ( $item->{'max-module-size'} && $item->{'derived-module-size'} && - $item->{'derived-module-size'} > $item->{'max-module-size'} ){ + if ($item->{'max-module-size'} && $item->{'derived-module-size'} && + $item->{'derived-module-size'} > $item->{'max-module-size'}){ $item->{'max-module-size'} = $item->{'derived-module-size'}; $est_mod = $est; } @@ -17530,19 +17635,19 @@ sub process_data { } # note: some cases memory capacity == max module size, so one stick will fill it # but I think only with cases of 2 slots does this happen, so if > 2, use the count of slots. - if ($max_cap && ($item->{'device-count-found'} || $item->{'slots-16'}) ){ + if ($max_cap && ($item->{'device-count-found'} || $item->{'slots-16'})){ # first check that actual memory found is not greater than listed max cap, or # checking to see module count * max mod size is not > used capacity if ($item->{'used-capacity'} && $item->{'max-capacity-16'}){ if ($item->{'used-capacity'} > $max_cap){ if ($item->{'max-module-size'} && - $item->{'used-capacity'} < ($item->{'slots-16'} * $item->{'max-module-size'} )){ + $item->{'used-capacity'} < ($item->{'slots-16'} * $item->{'max-module-size'})){ $max_cap = $item->{'slots-16'} * $item->{'max-module-size'}; $est_cap = $est; print "A\n" if $b_debug; } elsif ($item->{'derived-module-size'} && - $item->{'used-capacity'} < ($item->{'slots-16'} * $item->{'derived-module-size'}) ){ + $item->{'used-capacity'} < ($item->{'slots-16'} * $item->{'derived-module-size'})){ $max_cap = $item->{'slots-16'} * $item->{'derived-module-size'}; $est_cap = $est; print "B\n" if $b_debug; @@ -17559,12 +17664,12 @@ sub process_data { if (!$est_cap){ # do not do this for only single modules found, max mod size can be equal to the array size if ($item->{'slots-16'} > 1 && $item->{'device-count-found'} > 1 && - $max_cap < ($item->{'derived-module-size'} * $item->{'slots-16'} ) ){ + $max_cap < ($item->{'derived-module-size'} * $item->{'slots-16'})){ $max_cap = $item->{'derived-module-size'} * $item->{'slots-16'}; $est_cap = $est; print "D\n" if $b_debug; } - elsif ($item->{'device-count-found'} > 0 && $max_cap < ( $item->{'derived-module-size'} * $item->{'device-count-found'} )){ + elsif ($item->{'device-count-found'} > 0 && $max_cap < ($item->{'derived-module-size'} * $item->{'device-count-found'})){ $max_cap = $item->{'derived-module-size'} * $item->{'device-count-found'}; $est_cap = $est; print "E\n" if $b_debug; @@ -17574,7 +17679,7 @@ sub process_data { elsif ($item->{'max-module-size'} > 0 && ($item->{'max-module-size'} * $item->{'slots-16'}) == $item->{'max-capacity-5'} && $item->{'max-capacity-5'} != $item->{'max-capacity-16'} && - $item->{'derived-module-size'} != ($item->{'max-capacity-16'}/$item->{'slots-16'}) ){ + $item->{'derived-module-size'} != ($item->{'max-capacity-16'}/$item->{'slots-16'})){ $max_cap = $item->{'max-capacity-5'}; $est_cap = $est; print "F\n" if $b_debug; @@ -17595,7 +17700,7 @@ sub process_data { # now prep for rebuilding the ram array data if (!$item->{'max-module-size'}){ # ie: 2x4gB - if (!$est_cap && $item->{'derived-module-size'} > 0 && $max_cap > ($item->{'derived-module-size'} * $item->{'slots-16'} * 4) ){ + if (!$est_cap && $item->{'derived-module-size'} > 0 && $max_cap > ($item->{'derived-module-size'} * $item->{'slots-16'} * 4)){ $est_cap = $check; print "G\n" if $b_debug; } @@ -17623,7 +17728,7 @@ sub process_data { # listed max cap, 8gb, max mod 2gb, slots 2 else { if (!$est_cap && $item->{'max-module-size'} > 0){ - if ($max_cap > ( $item->{'max-module-size'} * $item->{'slots-16'})){ + if ($max_cap > ($item->{'max-module-size'} * $item->{'slots-16'})){ $est_cap = $check; print "K\n" if $b_debug; } @@ -17699,14 +17804,14 @@ sub process_size { sub calculate_size { my ($data, $size) = @_; # technically k is KiB, K is KB but can't trust that - if ( $data =~ /^([0-9]+\s*[kKGMTP])i?B/) { + if ($data =~ /^([0-9]+\s*[kKGMTP])i?B/){ my $working = $1; # this converts it to KiB my $working_size = main::translate_size($working); # but we want it back in MiB for RAM, that should get fixed $working_size = $working_size/1024 if $working_size; # print "ws-a: $working_size s-1: $size\n"; - if (main::is_numeric($working_size) && $working_size > $size ) { + if (main::is_numeric($working_size) && $working_size > $size){ $size = $working_size; } # print "ws-b: $working_size s-2: $size\n"; @@ -17945,7 +18050,7 @@ sub get_repos_linux { my $counter = 0; @files = main::globber("$apt.d/*.list"); push(@files, $apt); - main::log_data('data',"apt repo files:\n" . main::joiner(\@files, "\n", 'unset') ) if $b_log; + main::log_data('data',"apt repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log; foreach (sort @files){ # altlinux/pclinuxos use rpms in apt files @data = repo_builder($_,'apt','^\s*(deb|rpm)') if -r $_; @@ -17953,7 +18058,7 @@ sub get_repos_linux { } #@files = main::globber("$ENV{'HOME'}/bin/scripts/inxi/data/repo/apt/*.sources"); @files = main::globber("$apt.d/*.sources"); - main::log_data('data',"apt deb822 repo files:\n" . main::joiner(\@files, "\n", 'unset') ) if $b_log; + main::log_data('data',"apt deb822 repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log; foreach $file (@files){ # critical: whitespace is the separator, no logical ordering of # field names exists within each entry. @@ -18040,7 +18145,7 @@ sub get_repos_linux { # pacman: Arch and derived if (-f $pacman || -f $pacman_g2){ $repo = 'pacman'; - if (-f $pacman_g2 ){ + if (-f $pacman_g2){ $pacman = $pacman_g2; $repo = 'pacman-g2'; } @@ -18100,7 +18205,7 @@ sub get_repos_linux { @data2 = split(/\s*=\s*/, $row); @data2 = map { $_ =~ s/^\s+|\s+$//g ; $_ } @data2; last if $data2[0] =~ /^SLACKPKGPLUS/i && $data2[1] eq 'off'; - # REPOPLUS=( slackpkgplus restricted alienbob ktown multilib slacky) + # REPOPLUS=(slackpkgplus restricted alienbob ktown multilib slacky) if ($data2[0] =~ /^REPOPLUS/i){ @repoplus_list = split(/\s+/, $data2[1]); @repoplus_list = map {s/\(|\)//g; $_} @repoplus_list; @@ -18215,7 +18320,7 @@ sub get_repos_linux { # print Data::Dumper::Dumper \@rows; } # gentoo - if ( (-d $portage_dir || -d $portage_gentoo_dir ) && main::check_program('emerge')){ + if ((-d $portage_dir || -d $portage_gentoo_dir) && main::check_program('emerge')){ @files = (main::globber("$portage_dir*.conf"),main::globber("$portage_gentoo_dir*.conf")); $repo = 'portage'; if (@files){ @@ -18322,14 +18427,14 @@ sub get_repos_linux { if (-d $xbps_dir_1 || -d $xbps_dir_2){ @files = main::globber("$xbps_dir_1*.conf"); push(@files,main::globber("$xbps_dir_2*.conf")) if -d $xbps_dir_2; - main::log_data('data',"xbps repo files:\n" . main::joiner(\@files, "\n", 'unset') ) if $b_log; + main::log_data('data',"xbps repo files:\n" . main::joiner(\@files, "\n", 'unset')) if $b_log; foreach (sort @files){ @data = repo_builder($_,'xbps','^\s*repository\s*=','\s*=\s*',1) if -r $_; push(@rows,@data); } } # Mandriva/Mageia using: urpmq - if ( $path = main::check_program('urpmq') ){ + if ($path = main::check_program('urpmq')){ @data2 = main::grabber("$path --list-media active --list-url","\n",'strip'); main::writer("$debugger_dir/system-repo-data-urpmq.txt",\@data2) if $debugger_dir; # now we need to create the structure: repo info: repo path @@ -18363,8 +18468,8 @@ sub get_repos_linux { } } # Pardus/Solus - if ( (-d $pisi_dir && ( $path = main::check_program('pisi') ) ) || - (-d $eopkg_dir && ( $path = main::check_program('eopkg') ) ) ){ + if ((-d $pisi_dir && ($path = main::check_program('pisi'))) || + (-d $eopkg_dir && ($path = main::check_program('eopkg')))){ #$path = 'eopkg'; my $which = ($path =~ /pisi$/) ? 'pisi': 'eopkg'; my $cmd = ($which eq 'pisi') ? "$path list-repo": "$path lr"; @@ -18392,7 +18497,7 @@ sub get_repos_linux { push(@content, $_) if $repo; } # Local [inactive] Unstable [active] - elsif ( /^(.*)\s\[([\S]+)\]/){ + elsif (/^(.*)\s\[([\S]+)\]/){ $repo = $1; $repo = ($2 =~ /^activ/i) ? $repo : ''; } @@ -18417,7 +18522,7 @@ sub get_repos_linux { ); } } - if (-f $nix && ($path = main::check_program('nix-channel') )){ + if (-f $nix && ($path = main::check_program('nix-channel'))){ @content = main::grabber("$path --list 2>/dev/null","\n",'strip'); main::writer("$debugger_dir/system-repo-data-nix.txt",\@content) if $debugger_dir; if (!@content){ @@ -18453,17 +18558,17 @@ sub get_repos_bsd { my $openbsd = '/etc/pkg.conf'; my $openbsd2 = '/etc/installurl'; my $portsnap = '/etc/portsnap.conf'; - if ( -f $portsnap || -f $freebsd || -d $bsd_pkg || + if (-f $portsnap || -f $freebsd || -d $bsd_pkg || -f $ghostbsd_pkg || -f $hardenedbsd_pkg){ - if ( -f $portsnap ) { + if (-f $portsnap){ @data = repo_builder($portsnap,'portsnap','^\s*SERVERNAME','\s*=\s*',1); push(@rows,@data); } - if ( -f $freebsd ){ + if (-f $freebsd){ @data = repo_builder($freebsd,'freebsd','^\s*ServerName','\s+',1); push(@rows,@data); } - if ( -d $bsd_pkg || -f $freebsd_pkg || -f $ghostbsd_pkg || -f $hardenedbsd_pkg){ + if (-d $bsd_pkg || -f $freebsd_pkg || -f $ghostbsd_pkg || -f $hardenedbsd_pkg){ @files = main::globber('/usr/local/etc/pkg/repos/*.conf'); push(@files, $freebsd_pkg) if -f $freebsd_pkg; push(@files, $ghostbsd_pkg) if -f $ghostbsd_pkg; @@ -18512,7 +18617,7 @@ sub get_repos_bsd { } } } - if (-f $openbsd || -f $openbsd2) { + if (-f $openbsd || -f $openbsd2){ if (-f $openbsd){ @data = repo_builder($openbsd,'openbsd','^installpath','\s*=\s*',1); push(@rows,@data); @@ -18699,12 +18804,12 @@ sub get { # we're allowing 1 or 2 ipmi tools, first the gnu one, then the # almost certain to be present in BSDs if ($fake{'ipmi'} || (main::globber('/dev/ipmi**') && - ( ($program = main::check_program('ipmi-sensors')) || - ($program = main::check_program('ipmitool')) ) ) ){ + (($program = main::check_program('ipmi-sensors')) || + ($program = main::check_program('ipmitool'))))){ if ($fake{'ipmi'} || $b_root){ %sensors = ipmi_data($program); @data = sensors_output('ipmi',\%sensors); - if (!@data) { + if (!@data){ $key1 = 'Message'; $val1 = main::row_defaults('sensors-data-ipmi'); # $val1 = main::row_defaults('dev'); @@ -18749,7 +18854,7 @@ sub get { %sensors = lm_sensors_data(); @data = sensors_output($source,\%sensors); # print "here 2\n"; - if (!@data) { + if (!@data){ $key1 = 'Message'; $val1 = main::row_defaults('sensors-data-linux'); @data = ({main::key($num++,0,1,$key1) => $val1,}); @@ -18770,7 +18875,7 @@ sub sensors_output { my $fan_number = 0; my $num = 0; my $j = 0; - @gpu = gpu_data() if ( $source eq 'sensors' || $source eq 'lm-sensors' ); + @gpu = gpu_data() if ($source eq 'sensors' || $source eq 'lm-sensors'); my $temp_unit = (defined $sensors->{'temp-unit'}) ? " $sensors->{'temp-unit'}": ''; my $cpu_temp = (defined $sensors->{'cpu-temp'}) ? $sensors->{'cpu-temp'} . $temp_unit: 'N/A'; my $mobo_temp = (defined $sensors->{'mobo-temp'}) ? $sensors->{'mobo-temp'} . $temp_unit: 'N/A'; @@ -18805,7 +18910,7 @@ sub sensors_output { 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'; + 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'}){ @@ -18824,7 +18929,7 @@ sub sensors_output { 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 )){ + if ($i == 1 || ($i == 2 && !$b_cpu)){ $rows[$j]->{main::key($num++,0,2,'cpu')} = $fan_main[$i]; $b_cpu = 1; } @@ -18862,14 +18967,14 @@ sub sensors_output { 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'; + 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'; + my $gpu_temp = (defined $info->{'temp'}) ? $info->{'temp'} . $gpu_unit: 'N/A'; $rows[$j]->{main::key($num++,1,2,'device')} = $gpu_type; - if (defined $info->{'screen'} ){ + if (defined $info->{'screen'}){ $rows[$j]->{main::key($num++,0,3,'screen')} = $info->{'screen'}; } $rows[$j]->{main::key($num++,0,3,'temp')} = $gpu_temp; @@ -18899,7 +19004,7 @@ sub sensors_output { $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' ){ + 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'}; @@ -18972,14 +19077,14 @@ sub ipmi_data { # Platform Control Hub (PCH), it is the X370 chip on the Crosshair VI Hero. # VRM: voltage regulator module # NOTE: CPU0_TEMP CPU1_TEMP is possible, unfortunately; CPU Temp Interf - elsif (!$sensors{'cpu-temp'} && $row[$i_key] =~ /^CPU([01])?([\s_]Temp)?$/i) { + elsif (!$sensors{'cpu-temp'} && $row[$i_key] =~ /^CPU([01])?([\s_]Temp)?$/i){ $b_cpu_0 = 1 if defined $1 && $1 == 0; $sensors{'cpu-temp'} = int($row[$i_value]); $working_unit = $row[$i_unit]; $working_unit =~ s/degrees\s// if $b_ipmitool; $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($row[$i_key] =~ /^CPU([1-4])([\s_]Temp)?$/i) { + elsif ($row[$i_key] =~ /^CPU([1-4])([\s_]Temp)?$/i){ $temp_working = $1; $temp_working++ if $b_cpu_0; $sensors{"cpu${temp_working}-temp"} = int($row[$i_value]); @@ -18988,30 +19093,30 @@ sub ipmi_data { $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # for temp1/2 only use temp1/2 if they are null or greater than the last ones - elsif ($row[$i_key] =~ /^(MB[_]?TEMP1|Temp[\s_]1)$/i) { + elsif ($row[$i_key] =~ /^(MB[_]?TEMP1|Temp[\s_]1)$/i){ $temp_working = int($row[$i_value]); $working_unit = $row[$i_unit]; $working_unit =~ s/degrees\s// if $b_ipmitool; - if ( !$sensors{'temp1'} || ( defined $temp_working && $temp_working > 0 ) ) { + if (!$sensors{'temp1'} || (defined $temp_working && $temp_working > 0)){ $sensors{'temp1'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($row[$i_key] =~ /^(MB[_]?TEMP2|Temp[\s_]2)$/i) { + elsif ($row[$i_key] =~ /^(MB[_]?TEMP2|Temp[\s_]2)$/i){ $temp_working = int($row[$i_value]); $working_unit = $row[$i_unit]; $working_unit =~ s/degrees\s// if $b_ipmitool; - if ( !$sensors{'temp2'} || ( defined $temp_working && $temp_working > 0 ) ) { + if (!$sensors{'temp2'} || (defined $temp_working && $temp_working > 0)){ $sensors{'temp2'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # temp3 is only used as an absolute override for systems with all 3 present - elsif ($row[$i_key] =~ /^(MB[_]?TEMP3|Temp[\s_]3)$/i) { + elsif ($row[$i_key] =~ /^(MB[_]?TEMP3|Temp[\s_]3)$/i){ $temp_working = int($row[$i_value]); $working_unit = $row[$i_unit]; $working_unit =~ s/degrees\s// if $b_ipmitool; - if ( !$sensors{'temp3'} || ( defined $temp_working && $temp_working > 0 ) ) { + if (!$sensors{'temp3'} || (defined $temp_working && $temp_working > 0)){ $sensors{'temp3'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; @@ -19023,20 +19128,20 @@ sub ipmi_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 ($row[$i_key] =~ /^(CPU|Processor)[\s_]Fan/i) { + elsif ($row[$i_key] =~ /^(CPU|Processor)[\s_]Fan/i){ $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 # note: cpu/mobo/ps are 1/2/3 - elsif ($row[$i_key] =~ /^(SYS[\s_])?FAN[\s_]?([0-9A-F]+)/i) { + elsif ($row[$i_key] =~ /^(SYS[\s_])?FAN[\s_]?([0-9A-F]+)/i){ $sys_fan_nu = hex($2); $fan_working = int($row[$i_value]); $sensors{'fan-default'} = () if !$sensors{'fan-default'}; - if ($sys_fan_nu =~ /^([0-9]+)$/) { + 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]) { + 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; } } @@ -19045,39 +19150,39 @@ sub ipmi_data { } } } - elsif ($row[$i_key] =~ /^(FAN PSU|PSU FAN)$/i) { + elsif ($row[$i_key] =~ /^(FAN PSU|PSU FAN)$/i){ $sensors{'fan-psu'} = int($row[$i_value]); } - elsif ($row[$i_key] =~ /^(FAN PSU1|PSU1 FAN)$/i) { + elsif ($row[$i_key] =~ /^(FAN PSU1|PSU1 FAN)$/i){ $sensors{'fan-psu-1'} = int($row[$i_value]); } - elsif ($row[$i_key] =~ /^(FAN PSU2|PSU2 FAN)$/i) { + elsif ($row[$i_key] =~ /^(FAN PSU2|PSU2 FAN)$/i){ $sensors{'fan-psu-2'} = int($row[$i_value]); } if ($extra > 0){ - if ($row[$i_key] =~ /^((MAIN\s|P[_]?)?12V|PSU[12]_VOUT)$/i) { + if ($row[$i_key] =~ /^((MAIN\s|P[_]?)?12V|PSU[12]_VOUT)$/i){ $sensors{'volts-12'} = $row[$i_value]; } - elsif ($row[$i_key] =~ /^(MAIN\s5V|P5V|5VCC|5V PG|5V_SB)$/i) { + elsif ($row[$i_key] =~ /^(MAIN\s5V|P5V|5VCC|5V PG|5V_SB)$/i){ $sensors{'volts-5'} = $row[$i_value]; } - elsif ($row[$i_key] =~ /^(MAIN\s3\.3V|P3V3|3\.3VCC|3\.3V PG|3V3_SB)$/i) { + elsif ($row[$i_key] =~ /^(MAIN\s3\.3V|P3V3|3\.3VCC|3\.3V PG|3V3_SB)$/i){ $sensors{'volts-3.3'} = $row[$i_value]; } - elsif ($row[$i_key] =~ /^((P_)?VBAT|CMOS Battery|BATT 3.0V)$/i) { + elsif ($row[$i_key] =~ /^((P_)?VBAT|CMOS Battery|BATT 3.0V)$/i){ $sensors{'volts-vbat'} = $row[$i_value]; } # NOTE: VDimmP1ABC VDimmP1DEF - elsif (!$sensors{'volts-dimm-p1'} && $row[$i_key] =~ /^(P1_VMEM|VDimmP1|MEM RSR A PG|DIMM_VR1_VOLT)/i) { + elsif (!$sensors{'volts-dimm-p1'} && $row[$i_key] =~ /^(P1_VMEM|VDimmP1|MEM RSR A PG|DIMM_VR1_VOLT)/i){ $sensors{'volts-dimm-p1'} = $row[$i_value]; } - elsif (!$sensors{'volts-dimm-p2'} && $row[$i_key] =~ /^(P2_VMEM|VDimmP2|MEM RSR B PG|DIMM_VR2_VOLT)/i) { + elsif (!$sensors{'volts-dimm-p2'} && $row[$i_key] =~ /^(P2_VMEM|VDimmP2|MEM RSR B PG|DIMM_VR2_VOLT)/i){ $sensors{'volts-dimm-p2'} = $row[$i_value]; } - elsif (!$sensors{'volts-soc-p1'} && $row[$i_key] =~ /^(P1_SOC_RUN$)/i) { + elsif (!$sensors{'volts-soc-p1'} && $row[$i_key] =~ /^(P1_SOC_RUN$)/i){ $sensors{'volts-soc-p1'} = $row[$i_value]; } - elsif (!$sensors{'volts-soc-p2'} && $row[$i_key] =~ /^(P2_SOC_RUN$)/i) { + elsif (!$sensors{'volts-soc-p2'} && $row[$i_key] =~ /^(P2_SOC_RUN$)/i){ $sensors{'volts-soc-p2'} = $row[$i_value]; } } @@ -19114,9 +19219,9 @@ sub lm_sensors_data { # note that because of charset issues, no "°" degree sign used, but it is required # in testing regex to avoid error. It might be because I got that data from a forum post, # note directly via debugger. - if ($_ =~ /^T?(AMBIENT|M\/B|MB|Motherboard|SIO|SYS).*:([0-9\.]+)[\s°]*(C|F)/i) { + if ($_ =~ /^T?(AMBIENT|M\/B|MB|Motherboard|SIO|SYS).*:([0-9\.]+)[\s°]*(C|F)/i){ # avoid SYSTIN: 118 C - if (main::is_numeric($2) && $2 < 90 ){ + if (main::is_numeric($2) && $2 < 90){ $sensors{'mobo-temp'} = $2; $working_unit = $3; $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; @@ -19130,107 +19235,107 @@ sub lm_sensors_data { # NOTE: I've seen an inexplicable case where: CPU:52.0°C fails to match with [\s°] but # does match with: [\s°]*. I can't account for this, but that's why the * is there # Tdie is a new k10temp-pci syntax for cpu die temp - elsif ($_ =~ /^(T?CPU.*|Tdie.*):([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^(T?CPU.*|Tdie.*):([0-9\.]+)[\s°]*(C|F)/i){ $temp_working = $2; $working_unit = $3; if (!$sensors{'cpu-temp'} || - ( defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'cpu-temp'} ) ) { + (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'cpu-temp'})){ $sensors{'cpu-temp'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($_ =~ /^PECI\sAgent\s0.*:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^PECI\sAgent\s0.*:([0-9\.]+)[\s°]*(C|F)/i){ $sensors{'cpu-peci-temp'} = $1; $working_unit = $2; $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($_ =~ /^T?(P\/S|Power).*:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^T?(P\/S|Power).*:([0-9\.]+)[\s°]*(C|F)/i){ $sensors{'psu-temp'} = $2; $working_unit = $3; $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($_ =~ /^T?(dimm|mem|sodimm).*:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^T?(dimm|mem|sodimm).*:([0-9\.]+)[\s°]*(C|F)/i){ $sensors{'sodimm-temp'} = $1; $working_unit = $2; $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # for temp1/2 only use temp1/2 if they are null or greater than the last ones - elsif ($_ =~ /^temp1:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^temp1:([0-9\.]+)[\s°]*(C|F)/i){ $temp_working = $1; $working_unit = $2; - if ( !$sensors{'temp1'} || - ( defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp1'} ) ) { + if (!$sensors{'temp1'} || + (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp1'})){ $sensors{'temp1'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } - elsif ($_ =~ /^temp2:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^temp2:([0-9\.]+)[\s°]*(C|F)/i){ $temp_working = $1; $working_unit = $2; - if ( !$sensors{'temp2'} || - ( defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp2'} ) ) { + if (!$sensors{'temp2'} || + (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp2'})){ $sensors{'temp2'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # temp3 is only used as an absolute override for systems with all 3 present - elsif ($_ =~ /^temp3:([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^temp3:([0-9\.]+)[\s°]*(C|F)/i){ $temp_working = $1; $working_unit = $2; - if ( !$sensors{'temp3'} || - ( defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp3'} ) ) { + if (!$sensors{'temp3'} || + (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'temp3'})){ $sensors{'temp3'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # final fallback if all else fails, funtoo user showed sensors putting # temp on wrapped second line, not handled - elsif ($_ =~ /^T?(core0|core 0|Physical id 0)(.*):([0-9\.]+)[\s°]*(C|F)/i) { + elsif ($_ =~ /^T?(core0|core 0|Physical id 0)(.*):([0-9\.]+)[\s°]*(C|F)/i){ $temp_working = $3; $working_unit = $4; - if ( !$sensors{'core-0-temp'} || - ( defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'core-0-temp'} ) ) { + if (!$sensors{'core-0-temp'} || + (defined $temp_working && $temp_working > 0 && $temp_working > $sensors{'core-0-temp'})){ $sensors{'core-0-temp'} = $temp_working; } $sensors{'temp-unit'} = set_temp_unit($sensors{'temp-unit'},$working_unit) if $working_unit; } # note: can be cpu fan:, cpu fan speed:, etc. - elsif (!$sensors{'fan-main'}->[1] && $_ =~ /^F?(CPU|Processor).*:([0-9]+)[\s]RPM/i) { + 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) { + 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) { + 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) { + 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) { + elsif ($_ =~ /^F?(AUX|CASE|CHASSIS|FRONT|REAR).*:([0-9]+)[\s]RPM/i){ $temp_working = $2; - for ( my $i = 5; $i < 30; $i++ ){ + for (my $i = 5; $i < 30; $i++){ next if defined $sensors{'fan-main'}->[$i]; - 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) { + elsif ($_ =~ /^FAN(1)?:([0-9]+)[\s]RPM/i){ $sensors{'fan-default'}->[1] = $2; } - elsif ($_ =~ /^FAN([2-9]|1[0-9]).*:([0-9]+)[\s]RPM/i) { + elsif ($_ =~ /^FAN([2-9]|1[0-9]).*:([0-9]+)[\s]RPM/i){ $fan_working = $2; $sys_fan_nu = $1; - if ($sys_fan_nu =~ /^([0-9]+)$/) { + 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] ) { + 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; } } @@ -19240,20 +19345,20 @@ sub lm_sensors_data { } } if ($extra > 0){ - if ($_ =~ /^[+]?(12 Volt|12V|V\+?12).*:([0-9\.]+)\sV/i) { + if ($_ =~ /^[+]?(12 Volt|12V|V\+?12).*:([0-9\.]+)\sV/i){ $sensors{'volts-12'} = $2; } # note: 5VSB is a field name - elsif ($_ =~ /^[+]?(5 Volt|5V|V\+?5):([0-9\.]+)\sV/i) { + elsif ($_ =~ /^[+]?(5 Volt|5V|V\+?5):([0-9\.]+)\sV/i){ $sensors{'volts-5'} = $2; } - elsif ($_ =~ /^[+]?(3\.3 Volt|3\.3V|V\+?3\.3).*:([0-9\.]+)\sV/i) { + elsif ($_ =~ /^[+]?(3\.3 Volt|3\.3V|V\+?3\.3).*:([0-9\.]+)\sV/i){ $sensors{'volts-3.3'} = $2; } - elsif ($_ =~ /^(Vbat).*:([0-9\.]+)\sV/i) { + elsif ($_ =~ /^(Vbat).*:([0-9\.]+)\sV/i){ $sensors{'volts-vbat'} = $2; } - elsif ($_ =~ /^v(dimm|mem|sodimm).*:([0-9\.]+)\sV/i) { + elsif ($_ =~ /^v(dimm|mem|sodimm).*:([0-9\.]+)\sV/i){ $sensors{'volts-mem'} = $2; } } @@ -19436,22 +19541,22 @@ sub process_data { # this is wrong for systems with > 2 tempX readings, but the logic is too complex with 3 variables # so have to accept that it will be wrong in some cases, particularly for motherboard temp readings. if ($sensors{'temp1'} && $sensors{'temp2'}){ - if ($sensors_cpu_nu) { + if ($sensors_cpu_nu){ $fan_type = $sensors_cpu_nu; } else { # first some fringe cases with cooler cpu than mobo: assume which is cpu temp based on fan speed # but only if other fan speed is 0. if ($sensors{'temp1'} >= $sensors{'temp2'} && - defined $fan_default[1] && defined $fan_default[2] && $fan_default[1] == 0 && $fan_default[2] > 0) { + defined $fan_default[1] && defined $fan_default[2] && $fan_default[1] == 0 && $fan_default[2] > 0){ $fan_type = 2; } elsif ($sensors{'temp2'} >= $sensors{'temp1'} && - defined $fan_default[1] && defined $fan_default[2] && $fan_default[2] == 0 && $fan_default[1] > 0) { + defined $fan_default[1] && defined $fan_default[2] && $fan_default[2] == 0 && $fan_default[1] > 0){ $fan_type = 1; } # then handle the standard case if these fringe cases are false - elsif ($sensors{'temp1'} >= $sensors{'temp2'}) { + elsif ($sensors{'temp1'} >= $sensors{'temp2'}){ $fan_type = 1; } else { @@ -19472,10 +19577,10 @@ sub process_data { } } # convert the diff number for F, it needs to be bigger that is - if ($sensors{'temp-unit'} && $sensors{'temp-unit'} eq "F") { + if ($sensors{'temp-unit'} && $sensors{'temp-unit'} eq "F"){ $temp_diff = $temp_diff * 1.8 } - if ($sensors{'cpu-temp'}) { + if ($sensors{'cpu-temp'}){ # specific hack to handle broken CPUTIN temps with PECI if ($sensors{'cpu-peci-temp'} && ($sensors{'cpu-temp'} - $sensors{'cpu-peci-temp'}) > $temp_diff){ $cpu_temp = $sensors{'cpu-peci-temp'}; @@ -19489,7 +19594,7 @@ sub process_data { if ($fan_type){ # there are some weird scenarios if ($fan_type == 1){ - if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}) { + if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}){ $cpu_temp = $sensors{'temp2'}; } else { @@ -19497,7 +19602,7 @@ sub process_data { } } else { - if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}) { + if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}){ $cpu_temp = $sensors{'temp1'}; } else { @@ -19508,26 +19613,26 @@ sub process_data { else { $cpu_temp = $sensors{'temp1'}; # can be null, that is ok } - if ($cpu_temp) { + if ($cpu_temp){ # using $sensors{'temp3'} is just not reliable enough, more errors caused than fixed imo - # if ( $sensors{'temp3'} && $sensors{'temp3'} > $cpu_temp ) { + # if ($sensors{'temp3'} && $sensors{'temp3'} > $cpu_temp){ # $cpu_temp = $sensors{'temp3'}; # } # there are some absurdly wrong $sensors{'temp1'}: acpitz-virtual-0 $sensors{'temp1'}: +13.8°C - if ($sensors{'core-0-temp'} && ($sensors{'core-0-temp'} - $cpu_temp) > $temp_diff) { + if ($sensors{'core-0-temp'} && ($sensors{'core-0-temp'} - $cpu_temp) > $temp_diff){ $cpu_temp = $sensors{'core-0-temp'}; } } } # if all else fails, use core0/peci temp if present and cpu is null - if (!$cpu_temp) { - if ($sensors{'core-0-temp'}) { + if (!$cpu_temp){ + if ($sensors{'core-0-temp'}){ $cpu_temp = $sensors{'core-0-temp'}; } # note that peci temp is known to be colder than the actual system # sometimes so it is the last fallback we want to use even though in theory # it is more accurate, but fact suggests theory wrong. - elsif ($sensors{'cpu-peci-temp'}) { + elsif ($sensors{'cpu-peci-temp'}){ $cpu_temp = $sensors{'cpu-peci-temp'}; } } @@ -19536,8 +19641,8 @@ sub process_data { $mobo_temp = $sensors{'mobo-temp'}; } elsif ($fan_type){ - if ($fan_type == 1) { - if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}) { + if ($fan_type == 1){ + if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp2'} > $sensors{'temp1'}){ $mobo_temp = $sensors{'temp1'}; } else { @@ -19545,7 +19650,7 @@ sub process_data { } } else { - if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}) { + if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp1'} > $sensors{'temp2'}){ $mobo_temp = $sensors{'temp2'}; } else { @@ -19553,7 +19658,7 @@ sub process_data { } } ## NOTE: not safe to assume $sensors{'temp3'} is the mobo temp, sad to say - # if ( $sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp3'} && $sensors{'temp3'} < $mobo_temp ) { + # if ($sensors{'temp1'} && $sensors{'temp2'} && $sensors{'temp3'} && $sensors{'temp3'} < $mobo_temp){ # $mobo_temp = $sensors{'temp3'}; # } } @@ -19563,7 +19668,7 @@ sub process_data { $sensors{'cpu-temp'} > $sensors{'temp1'}){ $mobo_temp = $sensors{'temp1'}; } - elsif ($sensors{'temp2'}) { + elsif ($sensors{'temp2'}){ $mobo_temp = $sensors{'temp2'}; } } @@ -19572,23 +19677,23 @@ sub process_data { @fan_default = @{$sensors{'fan-default'}} if $sensors{'fan-default'}; $index_count_fan_default = (@fan_default) ? scalar @fan_default : 0; # then set the cpu fan speed - if (!$fan_main[1]) { + if (!$fan_main[1]){ # note, you cannot test for $fan_default[1] or [2] != "" # because that creates an array item in gawk just by the test itself - if ($fan_type == 1 && defined $fan_default[1]) { + if ($fan_type == 1 && defined $fan_default[1]){ $fan_main[1] = $fan_default[1]; $fan_default[1] = undef; } - elsif ($fan_type == 2 && defined $fan_default[2]) { + elsif ($fan_type == 2 && defined $fan_default[2]){ $fan_main[1] = $fan_default[2]; $fan_default[2] = undef; } } # clear out any duplicates. Primary fan real trumps fan working always if same speed - for ($i = 1; $i <= $index_count_fan_main; $i++) { - if (defined $fan_main[$i] && $fan_main[$i]) { - for ($j = 1; $j <= $index_count_fan_default; $j++) { - if (defined $fan_default[$j] && $fan_main[$i] == $fan_default[$j]) { + for ($i = 1; $i <= $index_count_fan_main; $i++){ + if (defined $fan_main[$i] && $fan_main[$i]){ + for ($j = 1; $j <= $index_count_fan_default; $j++){ + if (defined $fan_default[$j] && $fan_main[$i] == $fan_default[$j]){ $fan_default[$j] = undef; } } @@ -19602,18 +19707,18 @@ sub process_data { # shows the proper value, so the corruption might be internal in awk. # Note: gensub is the culprit I think, assigning type string for range 501-1000 but # type integer for all others, this triggers true for > - for ($j = 1; $j <= $index_count_fan_default; $j++) { - if (defined $fan_default[$j] && $fan_default[$j] > 5000 && !$fan_main[2]) { + for ($j = 1; $j <= $index_count_fan_default; $j++){ + if (defined $fan_default[$j] && $fan_default[$j] > 5000 && !$fan_main[2]){ $fan_main[2] = $fan_default[$j]; $fan_default[$j] = ''; # then add one if required for output - if ($index_count_fan_main < 2) { + if ($index_count_fan_main < 2){ $index_count_fan_main = 2; } } } # if they are ALL null, print error message. psFan is not used in output currently - if (!$cpu_temp && !$mobo_temp && !$fan_main[1] && !$fan_main[2] && !$fan_main[1] && !@fan_default) { + if (!$cpu_temp && !$mobo_temp && !$fan_main[1] && !$fan_main[2] && !$fan_main[1] && !@fan_default){ %sensors = (); } else { @@ -19662,7 +19767,7 @@ sub process_data { if ($sodimm_temp){ $sensors{'sodimm-temp'} = $sodimm_temp; } - if ($extra > 0 && ($v_12 || $v_5 || $v_3_3 || $v_vbat) ){ + if ($extra > 0 && ($v_12 || $v_5 || $v_3_3 || $v_vbat)){ $sensors{'volts-12'} = $v_12; $sensors{'volts-5'} = $v_5; $sensors{'volts-3.3'} = $v_3_3; @@ -19683,10 +19788,10 @@ sub gpu_data { my ($j) = (0); if ($path = main::check_program('nvidia-settings')){ # first get the number of screens. This only work if you are in X - if ($b_display) { + if ($b_display){ @data = main::grabber("$path -q screens 2>/dev/null"); foreach (@data){ - if ( /(:[0-9]\.[0-9])/ ) { + if (/(:[0-9]\.[0-9])/){ push(@screens, $1); } } @@ -19812,8 +19917,8 @@ sub get { eval $start if $b_log; my (@rows,$key1,$val1); my $num = 0; - if ($fake{'dmidecode'} || ( $alerts{'dmidecode'}->{'action'} eq 'use' && - (!$b_arm || $use{'slot-tool'} ) )){ + if ($fake{'dmidecode'} || ($alerts{'dmidecode'}->{'action'} eq 'use' && + (!$b_arm || $use{'slot-tool'}))){ @rows = slot_output(); } elsif ($b_arm && !$use{'slot-tool'}){ @@ -19821,7 +19926,7 @@ sub get { $val1 = main::row_defaults('arm-pci',''); @rows = ({main::key($num++,0,1,$key1) => $val1,}); } - elsif ( $alerts{'dmidecode'}->{'action'} ne 'use'){ + elsif ($alerts{'dmidecode'}->{'action'} ne 'use'){ $key1 = $alerts{'dmidecode'}->{'action'}; $val1 = $alerts{'dmidecode'}->{'message'}; $key1 = ucfirst($key1); @@ -19862,11 +19967,11 @@ sub slot_output { } } if ($type){ - $id = 'N/A' if ($id eq '' ); + $id = 'N/A' if ($id eq ''); if ($type eq 'Other' && $designation){ $type = $designation; } - elsif ($type && $designation) { + elsif ($type && $designation){ $type = "$type $designation"; } push(@rows, { @@ -19874,7 +19979,7 @@ sub slot_output { main::key($num++,0,2,'type') => $type, main::key($num++,0,2,'status') => $usage, },); - if ($extra > 1 ){ + if ($extra > 1){ $rows[$j]->{main::key($num++,0,2,'length')} = $length; } } @@ -19945,7 +20050,7 @@ sub create_output { main::key($num++,0,2,'type') => $row->{'swap-type'}, }); # not used for swap as far as I know - if ($b_admin && $row->{'raw-size'} ){ + 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; @@ -19973,13 +20078,19 @@ sub create_output { if ($extra > 0 && $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'; + if ($show{'label'} && ($row->{'label'} || $row->{'swap-type'} eq 'partition')){ + if ($use{'filter-label'}){ + $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, ''); + } + $row->{'label'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'}; } - 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'; + if ($show{'uuid'} && ($row->{'uuid'} || $row->{'swap-type'} eq 'partition')){ + if ($use{'filter-uuid'}){ + $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, ''); + } + $row->{'uuid'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; } } eval $end if $b_log; @@ -20048,6 +20159,7 @@ sub create_output { my (@rows,$fs); my ($j,$num) = (0,0); @$unmounted = sort { $a->{'dev-base'} cmp $b->{'dev-base'} } @$unmounted; + my $fs_skip = PartitionItem::fs_excludes('label-uuid'); foreach my $row (@$unmounted){ $num = 1; my $size = ($row->{'size'}) ? main::get_size($row->{'size'},'string') : 'N/A'; @@ -20065,8 +20177,6 @@ sub create_output { $fs = main::row_defaults('tool-missing-basic','file'); } } - $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, '') if $use{'filter-label'}; - $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, '') if $use{'filter-uuid'}; $j = scalar @rows; push(@rows, { main::key($num++,1,1,'ID') => "/dev/$row->{'dev-base'}", @@ -20082,9 +20192,21 @@ sub create_output { $rows[$j]->{main::key($num++,0,2,'size')} = $size; $rows[$j]->{main::key($num++,0,2,'fs')} = $fs; # don't show for fs known to not have label/uuid - if ($fs !~ /^(ffs)$/){ - $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'}; - $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; + if (($show{'label'} || $show{'uuid'}) && $fs !~ /^(fuse(blk)?[\._-]?)?($fs_skip)$/){ + if ($show{'label'}){ + if ($use{'filter-label'}){ + $row->{'label'} = main::apply_partition_filter('part', $row->{'label'}, ''); + } + $row->{'label'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'label')} = $row->{'label'}; + } + if ($show{'uuid'}){ + if ($use{'filter-uuid'}){ + $row->{'uuid'} = main::apply_partition_filter('part', $row->{'uuid'}, ''); + } + $row->{'uuid'} ||= 'N/A'; + $rows[$j]->{main::key($num++,0,2,'uuid')} = $row->{'uuid'}; + } } } eval $end if $b_log; @@ -20139,7 +20261,7 @@ sub proc_data { $size ||= $row->[2]; $fs = unmounted_filesystem($row->[-1]) if !$fs; # seen: (zfs|lvm2|linux_raid)_member; crypto_luks - # no te: lvm, raid members are never mounted. luks member is never mounted. + # note: lvm, raid members are never mounted. luks member is never mounted. next if $fs && $fs =~ /(bcache|crypto|luks|_member)$/i; # these components of lvm raid will show as partitions byt are reserved private lvm member # See man lvm for all current reserved private volume names @@ -20149,7 +20271,7 @@ sub proc_data { $uuid = PartitionItem::get_uuid("/dev/$row->[-1]") if !$uuid; } else { - my @temp = GpartnData::get($row->[-1]); + my @temp = GpartData::get($row->[-1]); $label = $temp[1] if $temp[1]; $uuid = $temp[2] if $temp[2]; } @@ -20210,7 +20332,7 @@ sub get_mounted { push(@mounted, $row->{'dev-base'}) if $row->{'dev-base'}; } # print Data::Dumper::Dumper \@zfs_raid; - foreach my $row ((@lvm_raid,@md_raid,@soft_raid,@zfs_raid)){ + foreach my $row ((@btrfs_raid,@lvm_raid,@md_raid,@soft_raid,@zfs_raid)){ # we want to not show md0 etc in unmounted report push(@mounted, $row->{'id'}) if $row->{'id'}; # print Data::Dumper::Dumper $row; @@ -20242,7 +20364,7 @@ sub unmounted_filesystem { my ($item) = @_; my ($data,%part); my ($file,$fs,$path) = ('','',''); - if ($path = main::check_program('file')) { + if ($path = main::check_program('file')){ $file = $path; } # order matters in this test! @@ -20280,8 +20402,8 @@ sub get { my $num = 0; if (!$usb{'main'} && $alerts{'lsusb'}->{'action'} ne 'use' && $alerts{'usbdevs'}->{'action'} ne 'use' && - $alerts{'usbconfig'}->{'action'} ne 'use' ){ - if ($os eq 'linux' ){ + $alerts{'usbconfig'}->{'action'} ne 'use'){ + if ($os eq 'linux'){ $key1 = $alerts{'lsusb'}->{'action'}; $val1 = $alerts{'lsusb'}->{'message'}; } @@ -20331,7 +20453,7 @@ sub usb_output { ($b_hub,$ind_sc,$num) = (0,3,1); ($driver,$path_id,$ports,$product, $serial,$speed,$type) = ('','','','','','',''); - $speed = ( main::is_numeric($id->[8]) ) ? sprintf("%1.1f",$id->[8]) : $id->[8] if $id->[8]; + $speed = (main::is_numeric($id->[8])) ? sprintf("%1.1f",$id->[8]) : $id->[8] if $id->[8]; $product = main::cleaner($id->[13]) if $id->[13]; $serial = main::apply_filter($id->[16]) if $id->[16]; $product ||= 'N/A'; @@ -20373,7 +20495,7 @@ sub usb_output { # for either hub or device if ($extra > 1 && main::is_numeric($id->[17])){ my $speed = $id->[17]; - if ($speed >= 1000) {$speed = ($id->[17] / 1000 ) . " Gb/s"} + 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; } @@ -20422,7 +20544,7 @@ sub weather_output { my $location_string; $location_string = $show{'weather-location'}; $location_string =~ s/\+/ /g; - if ( $location_string =~ /,/){ + if ($location_string =~ /,/){ my @temp = split(',', $location_string); my $sep = ''; my $string = ''; @@ -20438,19 +20560,19 @@ sub weather_output { } else { @location = get_location(); - if (!$location[0]) { + if (!$location[0]){ return @rows = ({ main::key($num++,0,1,'Message') => main::row_defaults('weather-null','current location'), }); } } %weather = get_weather(\@location); - if ($weather{'error'}) { + if ($weather{'error'}){ return @rows = ({ main::key($num++,0,1,'Message') => main::row_defaults('weather-error',$weather{'error'}), }); } - if (!$weather{'weather'}) { + if (!$weather{'weather'}){ return @rows = ({ main::key($num++,0,1,'Message') => main::row_defaults('weather-null','weather data'), }); @@ -20472,15 +20594,15 @@ sub weather_output { if (defined $weather{'cloud-cover'}){ $rows[$j]->{main::key($num++,0,2,'cloud cover')} = $weather{'cloud-cover'} . '%'; } - if ($weather{'precip-1h-mm'} && defined $weather{'precip-1h-in'} ){ + if ($weather{'precip-1h-mm'} && defined $weather{'precip-1h-in'}){ $value = process_unit('',$weather{'precip-1h-mm'},'mm',$weather{'precip-1h-in'},'in'); $rows[$j]->{main::key($num++,0,2,'precipitation')} = $value; } - if ($weather{'rain-1h-mm'} && defined $weather{'rain-1h-in'} ){ + if ($weather{'rain-1h-mm'} && defined $weather{'rain-1h-in'}){ $value = process_unit('',$weather{'rain-1h-mm'},'mm',$weather{'rain-1h-in'},'in'); $rows[$j]->{main::key($num++,0,2,'rain')} = $value; } - if ($weather{'snow-1h-mm'} && defined $weather{'snow-1h-in'} ){ + if ($weather{'snow-1h-mm'} && defined $weather{'snow-1h-in'}){ $value = process_unit('',$weather{'snow-1h-mm'},'mm',$weather{'snow-1h-in'},'in'); $rows[$j]->{main::key($num++,0,2,'snow')} = $value; } @@ -20520,7 +20642,7 @@ sub weather_output { push(@rows, { main::key($num++,1,1,'Locale') => $location, },); - if ($extra > 2 && !$use{'filter'} && ($weather{'elevation-m'} || $weather{'elevation-ft'} )){ + if ($extra > 2 && !$use{'filter'} && ($weather{'elevation-m'} || $weather{'elevation-ft'})){ $rows[$j]->{main::key($num++,0,2,'altitude')} = process_elevation($weather{'elevation-m'},$weather{'elevation-ft'}); } $rows[$j]->{main::key($num++,0,2,'current time')} = $weather{'date-time'},; @@ -20550,18 +20672,18 @@ sub process_elevation { my ($meters,$feet) = @_; my ($result,$i_unit,$m_unit) = ('','ft','m'); $feet = sprintf("%.0f", 3.28 * $meters) if defined $meters && !$feet; - $meters = sprintf("%.1f", $feet / 3.28 ) if defined $feet && !$meters; + $meters = sprintf("%.1f", $feet/3.28) if defined $feet && !$meters; $meters = sprintf("%.0f", $meters) if $meters; - if ( defined $meters && $weather_unit eq 'mi' ){ + if (defined $meters && $weather_unit eq 'mi'){ $result = "$meters $m_unit ($feet $i_unit)"; } - elsif (defined $meters && $weather_unit eq 'im' ){ + elsif (defined $meters && $weather_unit eq 'im'){ $result = "$feet $i_unit ($meters $m_unit)"; } - elsif (defined $meters && $weather_unit eq 'm' ){ + elsif (defined $meters && $weather_unit eq 'm'){ $result = "$meters $m_unit"; } - elsif (defined $feet && $weather_unit eq 'i' ){ + elsif (defined $feet && $weather_unit eq 'i'){ $result = "$feet $i_unit"; } else { @@ -20574,16 +20696,16 @@ sub process_unit { eval $start if $b_log; my ($primary,$metric,$m_unit,$imperial,$i_unit) = @_; my $result = ''; - if (defined $metric && defined $imperial && $weather_unit eq 'mi' ){ + if (defined $metric && defined $imperial && $weather_unit eq 'mi'){ $result = "$metric $m_unit ($imperial $i_unit)"; } - elsif (defined $metric && defined $imperial && $weather_unit eq 'im' ){ + elsif (defined $metric && defined $imperial && $weather_unit eq 'im'){ $result = "$imperial $i_unit ($metric $m_unit)"; } - elsif (defined $metric && $weather_unit eq 'm' ){ + elsif (defined $metric && $weather_unit eq 'm'){ $result = "$metric $m_unit"; } - elsif (defined $imperial && $weather_unit eq 'i' ){ + elsif (defined $imperial && $weather_unit eq 'i'){ $result = "$imperial $i_unit"; } elsif ($primary){ @@ -20617,30 +20739,30 @@ sub process_wind { if (!defined $mph && $primary){ $result = $primary; } - elsif (defined $mph && defined $direction ){ - if ( $weather_unit eq 'mi' ){ + elsif (defined $mph && defined $direction){ + if ($weather_unit eq 'mi'){ $result = "from $direction at $ms $m_unit ($kmh $km_unit, $mph $i_unit)"; } - elsif ( $weather_unit eq 'im' ){ + elsif ($weather_unit eq 'im'){ $result = "from $direction at $mph $i_unit ($ms $m_unit, $kmh $km_unit)"; } - elsif ( $weather_unit eq 'm' ){ + elsif ($weather_unit eq 'm'){ $result = "from $direction at $ms $m_unit ($kmh $km_unit)"; } - elsif ( $weather_unit eq 'i' ){ + elsif ($weather_unit eq 'i'){ $result = "from $direction at $mph $i_unit"; } if ($gust_mph){ - if ( $weather_unit eq 'mi' ){ + if ($weather_unit eq 'mi'){ $result .= ". Gusting to $ms $m_unit ($kmh $km_unit, $mph $i_unit)"; } - elsif ( $weather_unit eq 'im' ){ + elsif ($weather_unit eq 'im'){ $result .= ". Gusting to $mph $i_unit ($ms $m_unit, $kmh $km_unit)"; } - elsif ( $weather_unit eq 'm' ){ + elsif ($weather_unit eq 'm'){ $result .= ". Gusting to $ms $m_unit ($kmh $km_unit)"; } - elsif ( $weather_unit eq 'i' ){ + elsif ($weather_unit eq 'i'){ $result .= ". Gusting to $mph $i_unit"; } } @@ -20668,7 +20790,7 @@ sub get_weather { $freshness = (split(/\^\^/, $weather_data[0]))[1]; # print "$now:$freshness\n"; } - if (!$freshness || $freshness < ($now - 60) ) { + if (!$freshness || $freshness < ($now - 60)){ @weather_data = download_weather($now,$file_cached,$location); } # print join("\n", @weather_data), "\n"; @@ -20676,28 +20798,28 @@ sub get_weather { foreach (@weather_data){ my @working = split(/\s*\^\^\s*/, $_); next if ! defined $working[1] || $working[1] eq ''; - if ( $working[0] eq 'api_source' ){ + if ($working[0] eq 'api_source'){ $weather{'api-source'} = $working[1]; } - elsif ( $working[0] eq 'city' ){ + elsif ($working[0] eq 'city'){ $weather{'city'} = $working[1]; } - elsif ( $working[0] eq 'cloud_cover' ){ + elsif ($working[0] eq 'cloud_cover'){ $weather{'cloud-cover'} = $working[1]; } - elsif ( $working[0] eq 'country' ){ + elsif ($working[0] eq 'country'){ $weather{'country'} = $working[1]; } - elsif ( $working[0] eq 'dewpoint_string' ){ + elsif ($working[0] eq 'dewpoint_string'){ $weather{'dewpoint'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; $weather{'dewpoint-c'} = $2;; $weather{'dewpoint-f'} = $1;; } - elsif ( $working[0] eq 'dewpoint_c' ){ + elsif ($working[0] eq 'dewpoint_c'){ $weather{'dewpoint-c'} = $working[1]; } - elsif ( $working[0] eq 'dewpoint_f' ){ + elsif ($working[0] eq 'dewpoint_f'){ $weather{'dewpoint-f'} = $working[1]; } # WU: there are two elevations, we want the first one @@ -20706,81 +20828,81 @@ sub get_weather { $weather{'elevation-m'} = $working[1]; $weather{'elevation-m'} =~ s/\s*(ft|m).*$//; } - elsif ( $working[0] eq 'error' ){ + elsif ($working[0] eq 'error'){ $weather{'error'} = $working[1]; } - elsif ( $working[0] eq 'forecast' ){ + elsif ($working[0] eq 'forecast'){ $weather{'forecast'} = $working[1]; } - elsif ( $working[0] eq 'heat_index_string' ){ + elsif ($working[0] eq 'heat_index_string'){ $weather{'heat-index'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; $weather{'heat-index-c'} = $2;; $weather{'heat-index-f'} = $1; } - elsif ( $working[0] eq 'heat_index_c' ){ + elsif ($working[0] eq 'heat_index_c'){ $weather{'heat-index-c'} = $working[1]; } - elsif ( $working[0] eq 'heat_index_f' ){ + elsif ($working[0] eq 'heat_index_f'){ $weather{'heat-index-f'} = $working[1]; } - elsif ( $working[0] eq 'relative_humidity' ){ + elsif ($working[0] eq 'relative_humidity'){ $working[1] =~ s/%$//; $weather{'humidity'} = $working[1]; } - elsif ( $working[0] eq 'local_time' ){ + elsif ($working[0] eq 'local_time'){ $weather{'local-time'} = $working[1]; } - elsif ( $working[0] eq 'local_epoch' ){ + elsif ($working[0] eq 'local_epoch'){ $weather{'local-epoch'} = $working[1]; } - elsif ( $working[0] eq 'moonphase' ){ + elsif ($working[0] eq 'moonphase'){ $weather{'moonphase'} = $working[1]; } - elsif ( $working[0] eq 'moonphase_graphic' ){ + elsif ($working[0] eq 'moonphase_graphic'){ $weather{'moonphase-graphic'} = $working[1]; } - elsif ( $working[0] eq 'observation_time_rfc822' ){ + elsif ($working[0] eq 'observation_time_rfc822'){ $weather{'observation-time-rfc822'} = $working[1]; } - elsif ( $working[0] eq 'observation_epoch' ){ + elsif ($working[0] eq 'observation_epoch'){ $weather{'observation-epoch'} = $working[1]; } - elsif ( $working[0] eq 'observation_time' ){ + elsif ($working[0] eq 'observation_time'){ $weather{'observation-time-local'} = $working[1]; $weather{'observation-time-local'} =~ s/Last Updated on //; } - elsif ( $working[0] eq 'precip_mm' ){ + elsif ($working[0] eq 'precip_mm'){ $weather{'precip-1h-mm'} = $working[1]; } - elsif ( $working[0] eq 'precip_in' ){ + elsif ($working[0] eq 'precip_in'){ $weather{'precip-1h-in'} = $working[1]; } - elsif ( $working[0] eq 'pressure_string' ){ + elsif ($working[0] eq 'pressure_string'){ $weather{'pressure'} = $working[1]; } - elsif ( $working[0] eq 'pressure_mb' ){ + elsif ($working[0] eq 'pressure_mb'){ $weather{'pressure-mb'} = $working[1]; } - elsif ( $working[0] eq 'pressure_in' ){ + elsif ($working[0] eq 'pressure_in'){ $weather{'pressure-in'} = $working[1]; } - elsif ( $working[0] eq 'rain_1h_mm' ){ + elsif ($working[0] eq 'rain_1h_mm'){ $weather{'rain-1h-mm'} = $working[1]; } - elsif ( $working[0] eq 'rain_1h_in' ){ + elsif ($working[0] eq 'rain_1h_in'){ $weather{'rain-1h-in'} = $working[1]; } - elsif ( $working[0] eq 'snow_1h_mm' ){ + elsif ($working[0] eq 'snow_1h_mm'){ $weather{'snow-1h-mm'} = $working[1]; } - elsif ( $working[0] eq 'snow_1h_in' ){ + elsif ($working[0] eq 'snow_1h_in'){ $weather{'snow-1h-in'} = $working[1]; } - elsif ( $working[0] eq 'state_name' ){ + elsif ($working[0] eq 'state_name'){ $weather{'state'} = $working[1]; } - elsif ( $working[0] eq 'sunrise' ){ + elsif ($working[0] eq 'sunrise'){ if ($working[1]){ if ($working[1] !~ /^[0-9]+$/){ $weather{'sunrise'} = $working[1]; @@ -20791,7 +20913,7 @@ sub get_weather { } } } - elsif ( $working[0] eq 'sunset' ){ + elsif ($working[0] eq 'sunset'){ if ($working[1]){ if ($working[1] !~ /^[0-9]+$/){ $weather{'sunset'} = $working[1]; @@ -20802,7 +20924,7 @@ sub get_weather { } } } - elsif ( $working[0] eq 'temperature_string' ){ + elsif ($working[0] eq 'temperature_string'){ $weather{'temp'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; $weather{'temp-c'} = $2;; @@ -20811,58 +20933,58 @@ sub get_weather { # $weather{'temp'} =~ s/\sF/\x{2109}/; # $weather{'temp'} =~ s/\sC/\x{2103}/; } - elsif ( $working[0] eq 'temp_f' ){ + elsif ($working[0] eq 'temp_f'){ $weather{'temp-f'} = $working[1]; } - elsif ( $working[0] eq 'temp_c' ){ + elsif ($working[0] eq 'temp_c'){ $weather{'temp-c'} = $working[1]; } - elsif ( $working[0] eq 'timezone' ){ + elsif ($working[0] eq 'timezone'){ $weather{'timezone'} = $working[1]; } - elsif ( $working[0] eq 'visibility' ){ + elsif ($working[0] eq 'visibility'){ $weather{'visibility'} = $working[1]; } - elsif ( $working[0] eq 'visibility_km' ){ + elsif ($working[0] eq 'visibility_km'){ $weather{'visibility-km'} = $working[1]; } - elsif ( $working[0] eq 'visibility_mi' ){ + elsif ($working[0] eq 'visibility_mi'){ $weather{'visibility-mi'} = $working[1]; } - elsif ( $working[0] eq 'weather' ){ + elsif ($working[0] eq 'weather'){ $weather{'weather'} = $working[1]; } - elsif ( $working[0] eq 'wind_degrees' ){ + elsif ($working[0] eq 'wind_degrees'){ $weather{'wind-degrees'} = $working[1]; } - elsif ( $working[0] eq 'wind_dir' ){ + elsif ($working[0] eq 'wind_dir'){ $weather{'wind-direction'} = $working[1]; } - elsif ( $working[0] eq 'wind_mph' ){ + elsif ($working[0] eq 'wind_mph'){ $weather{'wind-mph'} = $working[1]; } - elsif ( $working[0] eq 'wind_gust_mph' ){ + elsif ($working[0] eq 'wind_gust_mph'){ $weather{'wind-gust-mph'} = $working[1]; } - elsif ( $working[0] eq 'wind_gust_ms' ){ + elsif ($working[0] eq 'wind_gust_ms'){ $weather{'wind-gust-ms'} = $working[1]; } - elsif ( $working[0] eq 'wind_ms' ){ + elsif ($working[0] eq 'wind_ms'){ $weather{'wind-ms'} = $working[1]; } - elsif ( $working[0] eq 'wind_string' ){ + elsif ($working[0] eq 'wind_string'){ $weather{'wind'} = $working[1]; } - elsif ( $working[0] eq 'windchill_string' ){ + elsif ($working[0] eq 'windchill_string'){ $weather{'windchill'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; $weather{'windchill-c'} = $2; $weather{'windchill-f'} = $1; } - elsif ( $working[0] eq 'windchill_c' ){ + elsif ($working[0] eq 'windchill_c'){ $weather{'windchill-c'} = $working[1]; } - elsif ( $working[0] eq 'windchill_f' ){ + elsif ($working[0] eq 'windchill_f'){ $weather{'windchill_f'} = $working[1]; } } @@ -20891,11 +21013,11 @@ sub get_weather { else { $date_time = POSIX::strftime "%c", localtime(); $date_time = test_locale_date($date_time,'',''); - $tz = ( $location->[2] ) ? " ($location->[2])" : ''; + $tz = ($location->[2]) ? " ($location->[2])" : ''; $weather{'date-time'} = $date_time . $tz; } # we get the wrong time using epoch for remote -W location - if ( !$show{'weather-location'} && $weather{'observation-epoch'}){ + if (!$show{'weather-location'} && $weather{'observation-epoch'}){ $date_time = POSIX::strftime "%c", localtime($weather{'observation-epoch'}); $date_time = test_locale_date($date_time,$show{'weather-location'},$weather{'observation-epoch'}); $weather{'observation-time-local'} = $date_time; @@ -20952,7 +21074,7 @@ sub get_location { @loc_data = main::reader($file_cached); $freshness = (split(/\^\^/, $loc_data[0]))[1]; } - if (!$freshness || $freshness < $now - 90) { + if (!$freshness || $freshness < $now - 90){ my $temp; my $url = "http://geoip.ubuntu.com/lookup"; # { @@ -20978,34 +21100,34 @@ sub get_location { foreach (@loc_data){ my @working = split(/\s*\^\^\s*/, $_); # print "$working[0]:$working[1]\n"; - if ($working[0] eq 'CountryCode3' ) { + if ($working[0] eq 'CountryCode3'){ $loc{'country3'} = $working[1]; } - elsif ($working[0] eq 'CountryCode' ) { + elsif ($working[0] eq 'CountryCode'){ $loc{'country'} = $working[1]; } - elsif ($working[0] eq 'CountryName' ) { + elsif ($working[0] eq 'CountryName'){ $loc{'country2'} = $working[1]; } - elsif ($working[0] eq 'RegionCode' ) { + elsif ($working[0] eq 'RegionCode'){ $loc{'region-id'} = $working[1]; } - elsif ($working[0] eq 'RegionName' ) { + elsif ($working[0] eq 'RegionName'){ $loc{'region'} = $working[1]; } - elsif ($working[0] eq 'City' ) { + elsif ($working[0] eq 'City'){ $loc{'city'} = $working[1]; } - elsif ($working[0] eq 'ZipPostalCode' ) { + elsif ($working[0] eq 'ZipPostalCode'){ $loc{'zip'} = $working[1]; } - elsif ($working[0] eq 'Latitude' ) { + elsif ($working[0] eq 'Latitude'){ $loc{'lat'} = $working[1]; } - elsif ($working[0] eq 'Longitude' ) { + elsif ($working[0] eq 'Longitude'){ $loc{'long'} = $working[1]; } - elsif ($working[0] eq 'TimeZone' ) { + elsif ($working[0] eq 'TimeZone'){ $loc{'tz'} = $working[1]; } } @@ -21106,10 +21228,10 @@ package CompilerVersion; sub get { eval $start if $b_log; my (@compiler); - if (my $file = $system_files{'proc-version'}) { + if (my $file = $system_files{'proc-version'}){ @compiler = version_proc($file); } - elsif ($bsd_type) { + elsif ($bsd_type){ @compiler = version_bsd(); } eval $end if $b_log; @@ -21377,7 +21499,7 @@ $xdg_desktop,@desktop,@data,@xprop); sub get { eval $start if $b_log; set_desktop_values(); - main::set_ps_gui() if ! $loaded{'ps-gui'}; + main::set_ps_gui() if !$loaded{'ps-gui'}; get_kde_trinity_data(); if (!@desktop){ get_env_de_data(); @@ -21385,7 +21507,7 @@ sub get { if (!@desktop){ get_env_xprop_gnome_based_data(); } - if (!@desktop && $b_xprop ){ + if (!@desktop && $b_xprop){ get_env_xprop_non_gnome_based_data(); } if (!@desktop){ @@ -21407,11 +21529,11 @@ sub get { sub set_desktop_values { # NOTE $XDG_CURRENT_DESKTOP envvar is not reliable, but it shows certain desktops better. # most desktops are not using it as of 2014-01-13 (KDE, UNITY, LXDE. Not Gnome) - $desktop_session = ( $ENV{'DESKTOP_SESSION'} ) ? prep_desktop_value($ENV{'DESKTOP_SESSION'}) : ''; - $xdg_desktop = ( $ENV{'XDG_CURRENT_DESKTOP'} ) ? prep_desktop_value($ENV{'XDG_CURRENT_DESKTOP'}) : ''; + $desktop_session = ($ENV{'DESKTOP_SESSION'}) ? prep_desktop_value($ENV{'DESKTOP_SESSION'}) : ''; + $xdg_desktop = ($ENV{'XDG_CURRENT_DESKTOP'}) ? prep_desktop_value($ENV{'XDG_CURRENT_DESKTOP'}) : ''; $kde_session_version = ($ENV{'KDE_SESSION_VERSION'}) ? $ENV{'KDE_SESSION_VERSION'} : ''; # for fallback to fallback protections re false gnome id - $gdmsession = ( $ENV{'GDMSESSION'} ) ? prep_desktop_value($ENV{'GDMSESSION'}) : ''; + $gdmsession = ($ENV{'GDMSESSION'}) ? prep_desktop_value($ENV{'GDMSESSION'}) : ''; } # note: an ubuntu regresssion replaces or adds 'ubuntu' string to # real value. Since ubuntu is the only distro I know that does this, @@ -21434,7 +21556,7 @@ sub get_kde_trinity_data { $kded = $program; $kded_name = 'kded'; } - if ($desktop_session eq 'trinity' || $xdg_desktop eq 'trinity' || (grep {/^tde/} @ps_gui) ){ + if ($desktop_session eq 'trinity' || $xdg_desktop eq 'trinity' || (grep {/^tde/} @ps_gui)){ $desktop[0] = 'Trinity'; if ($program = main::check_program('kdesktop')){ @version_data = main::grabber("$program --version 2>/dev/null"); @@ -21470,10 +21592,10 @@ sub get_kde_trinity_data { # KDE Frameworks: 5.11.0 # kf5-config: 1.0 # for QT, and Frameworks if we use it - if (!@version_data && ($program = main::check_program("kf$kde_session_version-config") )){ + if (!@version_data && ($program = main::check_program("kf$kde_session_version-config"))){ @version_data = main::grabber("$program --version 2>/dev/null"); } - if (!@version_data && ($program = main::check_program("kf-config") )){ + if (!@version_data && ($program = main::check_program("kf-config"))){ @version_data = main::grabber("$program --version 2>/dev/null"); } # hope we don't use this fallback, not the same version as kde always @@ -21549,9 +21671,9 @@ sub get_env_de_data { ); foreach my $item (@desktops){ # Check if in xdg_desktop OR desktop_session OR if in $item->[6] and in ps_gui - if ( (($item->[0] && ($xdg_desktop eq $item->[1] || $desktop_session eq $item->[1] )) || - (!$item->[0] && ($xdg_desktop =~ /$item->[1]/ || $desktop_session =~ /$item->[1]/ )) ) || - ($item->[5] && @ps_gui && (grep {/$item->[5]/} @ps_gui) ) ){ + if ((($item->[0] && ($xdg_desktop eq $item->[1] || $desktop_session eq $item->[1])) || + (!$item->[0] && ($xdg_desktop =~ /$item->[1]/ || $desktop_session =~ /$item->[1]/))) || + ($item->[5] && @ps_gui && (grep {/$item->[5]/} @ps_gui))){ ($desktop[0],$desktop[1]) = main::program_data($item->[2]); $b_gtk = $item->[3]; $b_qt = $item->[4]; @@ -21573,20 +21695,20 @@ sub get_env_xprop_gnome_based_data { # before gnome test eventually this needs to be better organized so all the # xprop tests are in the same section, but this is good enough for now. # NOTE: was checking for 'muffin' but that's not part of cinnamon - if ( $xdg_desktop eq 'cinnamon' || $gdmsession eq 'cinnamon' || - (main::check_program('muffin') || main::check_program('cinnamon-session') ) && - ($b_xprop && main::awk(\@xprop,'_muffin') )){ + if ($xdg_desktop eq 'cinnamon' || $gdmsession eq 'cinnamon' || + (main::check_program('muffin') || main::check_program('cinnamon-session')) && + ($b_xprop && main::awk(\@xprop,'_muffin'))){ ($desktop[0],$desktop[1]) = main::program_data('cinnamon','cinnamon',0); $b_gtk = 1; $desktop[0] ||= 'Cinnamon'; } elsif ($xdg_desktop eq 'mate' || $gdmsession eq 'mate' || - ( $b_xprop && main::awk(\@xprop,'_marco') )){ + ($b_xprop && main::awk(\@xprop,'_marco'))){ # NOTE: mate-about and mate-sesssion vary which has the higher number, neither # consistently corresponds to the actual MATE version, so check both. my %versions = ('mate-about' => '','mate-session' => ''); foreach my $key (keys %versions){ - if ($program = main::check_program($key) ) { + if ($program = main::check_program($key)){ @data = main::program_data($key,$program,0); $desktop[0] = $data[0]; $versions{$key} = $data[1]; @@ -21598,11 +21720,11 @@ sub get_env_xprop_gnome_based_data { $desktop[0] ||= 'MATE'; } # See sub for logic and comments - elsif (check_gnome() ){ - if (main::check_program('gnome-about') ) { + elsif (check_gnome()){ + if (main::check_program('gnome-about')){ ($desktop[0],$desktop[1]) = main::program_data('gnome-about'); } - elsif (main::check_program('gnome-shell') ) { + elsif (main::check_program('gnome-shell')){ ($desktop[0],$desktop[1]) = main::program_data('gnome','gnome-shell'); } $b_gtk = 1; @@ -21663,7 +21785,7 @@ sub get_env_xprop_non_gnome_based_data { # note: some distros/wm (e.g. bunsen) set xdg to xfce to solve some other # issues so don't test for that. $xdg_desktop eq 'xfce' if ($xdg_desktop eq 'xfce' || $gdmsession eq 'xfce' || - (main::check_program('xfdesktop')) && main::awk(\@xprop,'^(xfdesktop|xfce)' )){ + (main::check_program('xfdesktop')) && main::awk(\@xprop,'^(xfdesktop|xfce)')){ # this is a very expensive test that doesn't usually result in a find # talk to xfce to see what id they will be using for xfce 5 # if (main::awk(\@xprop, 'xfce4')){ @@ -21700,20 +21822,20 @@ sub get_env_xprop_non_gnome_based_data { $desktop[2] = $data[3]; } } - elsif ( $xdg_desktop eq 'moksha' || $gdmsession eq 'moksha' || - (main::check_program('enlightenment') || main::check_program('moksha') ) && main::awk(\@xprop,'moksha') ){ + elsif ($xdg_desktop eq 'moksha' || $gdmsession eq 'moksha' || + (main::check_program('enlightenment') || main::check_program('moksha')) && main::awk(\@xprop,'moksha')){ # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Moksha 0.2.0.15989" $desktop[0] = 'Moksha'; - $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+' ); + $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+'); $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1]; } - elsif ( $xdg_desktop eq 'enlightenment' || $gdmsession eq 'enlightenment' || - (main::check_program('enlightenment') && main::awk(\@xprop,'enlightenment' ) ) ){ + elsif ($xdg_desktop eq 'enlightenment' || $gdmsession eq 'enlightenment' || + (main::check_program('enlightenment') && main::awk(\@xprop,'enlightenment'))){ # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Enlightenment 0.16.999.49898" $desktop[0] = 'Enlightenment'; - $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+' ); + $desktop[1] = main::awk(\@xprop,'(enlightenment|moksha)_version',2,'\s+=\s+'); $desktop[1] =~ s/"?(Moksha|Enlightenment)\s([^"]+)"?/$2/i if $desktop[1]; } # the sequence here matters, some desktops like icewm, razor, let you set different @@ -21737,7 +21859,7 @@ sub get_env_xprop_non_gnome_based_data { ); foreach my $item (@desktops){ if (main::check_program($item->[0]) && main::awk(\@xprop,$item->[1]) && - (!$item->[4] || (@ps_gui && (grep {/$item->[4]/} @ps_gui ))) ){ + (!$item->[4] || (@ps_gui && (grep {/$item->[4]/} @ps_gui)))){ ($desktop[0],$desktop[1]) = main::program_data($item->[2]); last; } @@ -21866,10 +21988,10 @@ sub set_qt_data { my $kde_version = $kde_session_version; $program = ''; if (!$kde_version){ - if ($program = main::check_program("kded6") ){$kde_version = 6;} - elsif ($program = main::check_program("kded5") ){$kde_version = 5;} - elsif ($program = main::check_program("kded4") ){$kde_version = 4;} - elsif ($program = main::check_program("kded") ){$kde_version = '';} + if ($program = main::check_program("kded6")){$kde_version = 6;} + elsif ($program = main::check_program("kded5")){$kde_version = 5;} + elsif ($program = main::check_program("kded4")){$kde_version = 4;} + elsif ($program = main::check_program("kded")){$kde_version = '';} } # alternate: qt4-default, qt4-qmake or qt5-default, qt5-qmake # often this exists, is executable, but actually is nothing, shows error @@ -21879,7 +22001,7 @@ sub set_qt_data { if (!$desktop[3] && main::check_program('qtdiag')){ ($desktop[2],$desktop[3]) = main::program_data('qtdiag'); } - if (!$desktop[3] && ($program = main::check_program("kf$kde_version-config") )){ + if (!$desktop[3] && ($program = main::check_program("kf$kde_version-config"))){ @version_data = main::grabber("$program --version 2>/dev/null"); $desktop[2] = 'Qt'; $desktop[3] = main::awk(\@version_data,'^Qt:',2) if @version_data; @@ -21895,11 +22017,11 @@ sub set_qt_data { sub get_wm { eval $start if $b_log; - if (!$force{'wmctrl'}) { + if (!$force{'wmctrl'}){ get_wm_main(); } # note, some wm, like cinnamon muffin, do not appear in ps aux, but do in wmctrl - if ( (!$desktop[5] || $force{'wmctrl'}) && (my $program = main::check_program('wmctrl'))){ + if ((!$desktop[5] || $force{'wmctrl'}) && (my $program = main::check_program('wmctrl'))){ get_wm_wmctrl($program); } eval $end if $b_log; @@ -21921,7 +22043,7 @@ sub get_wm_main { } } if (!$desktop[5]){ - main::set_ps_gui() if ! $loaded{'ps-gui'}; + main::set_ps_gui() if !$loaded{'ps-gui'}; # order matters, see above logic # due to lisp/python starters, clfswm/stumpwm/qtile will not detect here $wms = '2bwm|9wm|aewm\+\+|aewm|afterstep|amiwm|antiwm|awesome|blackbox|'; @@ -21962,10 +22084,10 @@ sub get_wm_wmctrl { $desktop[5] =~ s/\d+\.\d\S+|[\[\(].*\d+\.\d.*[\)\]]//g; $desktop[5] = main::trimmer($desktop[5]); # change Metacity (Marco) to marco - if ($desktop[5] =~ /marco/i) {$desktop[5] = 'marco'} - elsif ($desktop[5] =~ /muffin/i) {$desktop[5] = 'muffin'} - elsif (lc($desktop[5]) eq 'gnome shell') {$desktop[5] = 'gnome-shell'} - elsif ($desktop_session eq 'trinity' && lc($desktop[5]) eq 'kwin') {$desktop[5] = 'Twin'} + if ($desktop[5] =~ /marco/i){$desktop[5] = 'marco'} + elsif ($desktop[5] =~ /muffin/i){$desktop[5] = 'muffin'} + elsif (lc($desktop[5]) eq 'gnome shell'){$desktop[5] = 'gnome-shell'} + elsif ($desktop_session eq 'trinity' && lc($desktop[5]) eq 'kwin'){$desktop[5] = 'Twin'} get_wm_version('wmctrl',$desktop[5]); } eval $end if $b_log; @@ -21975,7 +22097,7 @@ sub get_wm_version { my ($type,$wm) = @_; # we don't want the gnome-shell version, and the others have no --version # we also don't want to run --version again on stuff we already have tested - return if ! $wm || $wm =~ /^(budgie-wm|gnome-shell)$/ || ($desktop[0] && lc($desktop[0]) eq lc($wm) ); + return if !$wm || $wm =~ /^(budgie-wm|gnome-shell)$/ || ($desktop[0] && lc($desktop[0]) eq lc($wm)); my $temp = (split(/\s+/, $wm))[0]; if ($temp){ $temp = (split(/\s+/, $temp))[0]; @@ -21992,7 +22114,7 @@ sub get_wm_version { sub set_info_data { eval $start if $b_log; - main::set_ps_gui() if ! $loaded{'ps-gui'}; + main::set_ps_gui() if !$loaded{'ps-gui'}; my (@data,@info,$item); my $pattern = 'alltray|awn|bar|bmpanel|bmpanel2|budgie-panel|cairo-dock|'; $pattern .= 'dde-dock|dmenu|dockbarx|docker|docky|dzen|dzen2|'; @@ -22004,7 +22126,7 @@ sub set_info_data { $pattern .= 'razor-panel|razorqt-panel|stalonetray|swaybar|taskbar|tint2|trayer|'; $pattern .= 'ukui-panel|vala-panel|wbar|wharf|wingpanel|witray|'; $pattern .= 'xfce4-panel|xfce5-panel|xmobar|yabar'; - if (@data = grep {/^($pattern)$/} @ps_gui ) { + if (@data = grep {/^($pattern)$/} @ps_gui){ # only one entry per type, can be multiple foreach $item (@data){ if (! grep {$item =~ /$_/} @info){ @@ -22074,7 +22196,7 @@ sub set { ${$_[0]} = 1; # set check by reference if ($use{'pci'}){ if (!$bsd_type){ - if ($alerts{'lspci'}->{'action'} eq 'use' ){ + if ($alerts{'lspci'}->{'action'} eq 'use'){ lspci_data(); } # ! -d '/proc/bus/pci' @@ -22105,7 +22227,7 @@ sub set { print Data::Dumper::Dumper $devices{'timer'}; print "vm: $device_vm\n"; } - if ( $b_log){ + if ($b_log){ main::log_data('dump','$devices{audio}',$devices{'audio'}); main::log_data('dump','$devices{bluetooth}',$devices{'bluetooth'}); main::log_data('dump','$devices{graphics}',$devices{'graphics'}); @@ -22126,7 +22248,7 @@ sub lspci_data { foreach (@data){ # print "$_\n"; if ($device){ - if ($_ =~ /^~$/) { + if ($_ =~ /^~$/){ @temp = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id, $rev,$port,$driver,$modules,$driver_nu,$subsystem,$subsystem_id); assign_data('pci',\@temp); @@ -22190,7 +22312,7 @@ sub pciconf_data { my @data = pci_grabber('pciconf'); foreach (@data){ if ($driver){ - if ($_ =~ /^~$/) { + if ($_ =~ /^~$/){ $vendor = main::cleaner($vendor); $device = main::cleaner($device); # handle possible regex in device name, like [ConnectX-3] @@ -22263,7 +22385,7 @@ sub pcidump_data { my @data = pci_grabber('pcidump'); main::set_dboot_data() if !$loaded{'dboot'}; foreach (@data){ - if ($_ =~ /^~$/ && $busid && $device) { + if ($_ =~ /^~$/ && $busid && $device){ @temp = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id, $rev,$port,$driver,$modules,$driver_nu,'','','',$serial); assign_data('pci',\@temp); @@ -22277,7 +22399,7 @@ sub pcidump_data { ($driver,$driver_nu) = pcidump_driver("$busid:$busid_nu") if $dboot{'pci'}; $device = main::cleaner($3); } - elsif ($_ =~ /^0x[\S]{4}:\s+Vendor ID:\s+([0-9a-f]{4}),?\s+Product ID:\s+([0-9a-f]{4})/ ){ + elsif ($_ =~ /^0x[\S]{4}:\s+Vendor ID:\s+([0-9a-f]{4}),?\s+Product ID:\s+([0-9a-f]{4})/){ $vendor_id = $1; $chip_id = $2; } @@ -22297,7 +22419,7 @@ sub pcidump_driver { eval $start if $b_log; my $bus_id = $_[0]; my ($driver,$nu); - for (@{$dboot{'pci'}}) { + for (@{$dboot{'pci'}}){ if (/^$bus_id:([^0-9]+)([0-9]+):/){ $driver = $1; $nu = $2; @@ -22312,7 +22434,7 @@ sub pcictl_data { my @data = pci_grabber('pcictl'); my @data2 = pci_grabber('pcictl-n'); foreach (@data){ - if ($_ =~ /^~$/ && $busid && $device) { + if ($_ =~ /^~$/ && $busid && $device){ @temp = ($type,$type_id,$busid,$busid_nu,$device,$vendor_id,$chip_id, $rev,$port,$driver,$modules,$driver_nu); assign_data('pci',\@temp); @@ -22537,7 +22659,7 @@ sub soc_devicetree { my $test = (@full_names) ? join('|', sort @full_names) : 'xxxxxx'; set_bluetooth() if !$b_bt_check; foreach $file (@files){ - if ( $file !~ m%$test%){ + if ($file !~ m%$test%){ ($handle,$content,$device,$type,$type_id,$vendor_id) = ('','','','','',''); $content = main::reader($file, 'strip',0) if -r $file; $file =~ m%soc/([^@]+)@([^/]+)/compatible$%; @@ -22602,51 +22724,51 @@ sub assign_data { $use{'soc-timer'} = 1 if $tool eq 'soc'; } # not used at this point, -M comes before ANG - # $device_vm = check_vm($data[4]) if ( (!$b_ppc && !$b_mips) && !$device_vm ); + # $device_vm = check_vm($data[4]) if ((!$b_ppc && !$b_mips) && !$device_vm); push(@devices,[@$data]); } # note: for soc, these have been converted in soc_type() sub check_audio { - if ( ( $_[1] && length($_[1]) == 4 && $_[1] =~ /^04/ ) || - ( $_[0] && $_[0] =~ /^(audio|hdmi|multimedia|sound)$/i )){ + if (($_[1] && length($_[1]) == 4 && $_[1] =~ /^04/) || + ($_[0] && $_[0] =~ /^(audio|hdmi|multimedia|sound)$/i)){ return 1; } else {return 0} } sub check_bluetooth { - if ( ( $_[1] && length($_[1]) == 4 && $_[1] eq '0d11' ) || - ( $_[0] && $_[0] =~ /^(bluetooth)$/i )){ + if (($_[1] && length($_[1]) == 4 && $_[1] eq '0d11') || + ($_[0] && $_[0] =~ /^(bluetooth)$/i)){ return 1; } else {return 0} } sub check_graphics { # note: multimedia class 04 is viddeo if 0400. 'tv' is risky I think - if ( ( $_[1] && length($_[1]) == 4 && ($_[1] =~ /^03/ || $_[1] eq '0400' || - $_[1] eq '0d80' ) ) || - ( $_[0] && $_[0] =~ /^(vga|display|hdmi|3d|video|tv|television)$/i)){ + if (($_[1] && length($_[1]) == 4 && ($_[1] =~ /^03/ || $_[1] eq '0400' || + $_[1] eq '0d80')) || + ($_[0] && $_[0] =~ /^(vga|display|hdmi|3d|video|tv|television)$/i)){ return 1; } else {return 0} } sub check_hwraid { - return 1 if ( $_[1] && $_[1] eq '0104' ); + return 1 if ($_[1] && $_[1] eq '0104'); } # NOTE: class 06 subclass 80 # https://www-s.acm.illinois.edu/sigops/2007/roll_your_own/7.c.1.html # 0d20: 802.11a 0d21: 802.11b 0d80: other wireless sub check_network { - if ( ( $_[1] && length($_[1]) == 4 && ($_[1] =~/^02/ || $_[1] =~ /^0d2/ || $_[1] eq '0680' ) ) || - ( $_[0] && $_[0] =~ /^(ethernet|network|wifi|wlan)$/i ) ){ + if (($_[1] && length($_[1]) == 4 && ($_[1] =~/^02/ || $_[1] =~ /^0d2/ || $_[1] eq '0680')) || + ($_[0] && $_[0] =~ /^(ethernet|network|wifi|wlan)$/i)){ return 1; } else {return 0} } sub check_timer { - return 1 if ( $_[0] && $_[0] eq 'timer' ); + return 1 if ($_[0] && $_[0] eq 'timer'); } sub check_vm { - if ( $_[0] && $_[0] =~ /(innotek|vbox|virtualbox|vmware|qemu)/i ) { + if ($_[0] && $_[0] =~ /(innotek|vbox|virtualbox|vmware|qemu)/i){ return $1 } else {return ''} @@ -22657,7 +22779,7 @@ sub soc_type { # I2S or i2s. I2C is i2 controller |[iI]2[Ss]. note: odroid hdmi item is sound only # snd_soc_dummy. simple-audio-amplifier driver: speaker_amp if (($driver && $driver =~ /codec/) || ($info && $info =~ /codec/) || - ($type && $type =~ /codec/) ){ + ($type && $type =~ /codec/)){ $type = 'codec'; } elsif (($driver && $driver =~ /dummy/i) || ($info && $info =~ /dummy/i)){ @@ -22665,7 +22787,7 @@ sub soc_type { } elsif ($type =~ /^(daudio|.*hifi.*|.*sound[_-]card|.*dac[0-9]?)$/i || ($info && $info !~ /amp/i && $info =~ /(sound|audio)/i) || - ($driver && $driver =~ /(audio|snd|sound)/i) ){ + ($driver && $driver =~ /(audio|snd|sound)/i)){ $type = 'audio'; } # no need for bluetooth since that's only found in pi, handled above @@ -22680,7 +22802,7 @@ sub soc_type { $type = 'wifi'; } # needs to catch variants like hdmi-tx but not hdmi-connector - elsif ( $type =~ /^(.*hdmi(-?tx)?)$/i){ + elsif ($type =~ /^(.*hdmi(-?tx)?)$/i){ $type = 'hdmi'; } elsif ($type =~ /^timer$/i){ @@ -22790,7 +22912,7 @@ sub set_dboot_disks { } # don't set both, if smartctl installed, we want to use its data so having # only one of logical/physical will trip use of smartctl values - if ($row[0] =~ /[\s,]+([0-9]+)\sbytes?[\s\/]sect/ ){ + if ($row[0] =~ /[\s,]+([0-9]+)\sbytes?[\s\/]sect/){ #$disks_bsd{$id}->{'block-logical'} = $1; $disks_bsd{$id}->{'block-physical'} = $1; } @@ -22854,7 +22976,7 @@ sub bioctl_data { if ($working =~ /permission/i){ $alerts{'bioctl'}->{'action'} = 'permissions'; } - elsif ($working =~ /serial[\s-]?(number|n[ou]\.?)?\s+(\S+)$/i) { + elsif ($working =~ /serial[\s-]?(number|n[ou]\.?)?\s+(\S+)$/i){ $serial = $2; } } @@ -23009,7 +23131,7 @@ sub set_gpart_data { } } # really strange results happen if no dboot disks were found and it's zfs! - elsif (!$b_cd && $type && $type eq 'disk' && $disks_bsd{$id}->{'size'}) { + elsif (!$b_cd && $type && $type eq 'disk' && $disks_bsd{$id}->{'size'}){ # need to see raid, may be > 1 Consumers if ($working[0] =~ /^[0-9]+\.\s*Name/){ $id = $working[1]; @@ -23043,7 +23165,7 @@ sub get_display_manager { my @dms_version = qw(gdm gdm3 lightdm slim); $b_run = 1 if -d "/run"; # in most linux, /var/run is a sym link to /run, so no need to check it twice - if ( -d "/var/run" ){ + if (-d "/var/run"){ my $rdlink = readlink('/var/run'); $b_vrun = 1 if !$rdlink || ($rdlink && $rdlink ne '/run'); $b_vrunrc = 1 if -d "/var/run/rc.d"; @@ -23057,11 +23179,11 @@ sub get_display_manager { $working = $id; $working =~ s/\.\S+$//; # note: there were issues with duplicated dm's in inxi, checking @found corrects it - if ((( $b_run && ( -f "/run/$id" || -d "/run/$working" )) || - ($b_vrun && ( -f "/var/run/$id" || -d "/var/run/$working")) || - ($b_vrunrc && ( -f "/var/run/rc.d/$working" || -d "/var/run/rc.d/$id"))) && - !grep {/$working/} @found ){ - if ($extra > 2 && awk( \@dms_version, $working) && ($path = check_program($working))){} + if ((($b_run && (-f "/run/$id" || -d "/run/$working")) || + ($b_vrun && (-f "/var/run/$id" || -d "/var/run/$working")) || + ($b_vrunrc && (-f "/var/run/rc.d/$working" || -d "/var/run/rc.d/$id"))) && + !grep {/$working/} @found){ + if ($extra > 2 && awk(\@dms_version, $working) && ($path = check_program($working))){} else {$path = $working;} # print "$path $extra\n"; @data = program_data($working,$path,3); @@ -23072,15 +23194,15 @@ sub get_display_manager { } if (!@found){ # ly does not have a run/pid file - if (grep {$_ eq 'ly'} @ps_gui) { + if (grep {$_ eq 'ly'} @ps_gui){ @data = program_data('ly','ly',3); $found[0] = $data[0]; $found[0] .= ' ' . $data[1] if $data[1]; } - elsif (grep {/startx$/} @ps_gui) { + elsif (grep {/startx$/} @ps_gui){ $found[0] = 'startx'; } - elsif (grep {$_ eq 'xinit'} @ps_gui) { + elsif (grep {$_ eq 'xinit'} @ps_gui){ $found[0] = 'xinit'; } } @@ -23210,7 +23332,7 @@ sub get_linux_distro { # Note that antergos changed this around # 2018-05, and now lists # antergos in os-release, sigh... We want these distros to use os-release # if it contains their names. Last check below - if ( @osr && ( grep {/(manjaro|antergos|chakra|guix|pclinuxos|raspberry pi os|zorin)/i} @osr ) ){ + if (@osr && (grep {/(manjaro|antergos|chakra|guix|pclinuxos|raspberry pi os|zorin)/i} @osr)){ $distro_file = $os_release; } if (grep {/armbian/} @distro_files){ @@ -23222,17 +23344,17 @@ sub get_linux_distro { if (scalar @distro_files == 1){ $distro_file = $distro_files[0]; } - elsif (scalar @distro_files > 1) { + elsif (scalar @distro_files > 1){ # special case, to force manjaro/antergos which also have arch-release # manjaro should use lsb, which has the full info, arch uses os release # antergos should use /etc/issue. We've already checked os-release above - if ($distro_id eq 'antergos' || (grep {/antergos|chakra|manjaro/} @distro_files )){ + if ($distro_id eq 'antergos' || (grep {/antergos|chakra|manjaro/} @distro_files)){ @distro_files = grep {!/arch-release/} @distro_files; } my $distro_files_s = join('|', @distro_files); @working = (@derived,@primary); foreach my $file (@working){ - if ( "/etc/$file" =~ /($distro_files_s)$/){ + if ("/etc/$file" =~ /($distro_files_s)$/){ # Now lets see if the distro file is in the known-good working-lsb-list # if so, use lsb-release, if not, then just use the found file # this is for only those distro's with self named release/version files @@ -23253,7 +23375,7 @@ sub get_linux_distro { } main::log_data('data',"distro_file-2: $distro_file") if $b_log; # first test for the legacy antiX distro id file - if ( -r '/etc/antiX'){ + if (-r '/etc/antiX'){ @working = main::reader('/etc/antiX'); $distro = main::awk(\@working,'antix.*\.iso') if @working; $distro = main::clean_characters($distro) if $distro; @@ -23262,7 +23384,7 @@ sub get_linux_distro { # This would never apply for ubuntu or debian, which will filter down to the following # conditions. In general if there's a specific distro release file available, that's to # be preferred, but this is a good backup. - elsif ($distro_file && $b_lsb && ($distro_file =~ /\/etc\/($lsb_good_s)$/ || $distro_file eq $lsb_release) ){ + elsif ($distro_file && $b_lsb && ($distro_file =~ /\/etc\/($lsb_good_s)$/ || $distro_file eq $lsb_release)){ $distro = get_lsb_release(); } elsif ($distro_file && $distro_file eq $os_release){ @@ -23270,7 +23392,7 @@ sub get_linux_distro { $b_skip_osr = 1; } # if distro id file was found and it's not in the exluded primary distro file list, read it - elsif ( $distro_file && -s $distro_file && $distro_file !~ /\/etc\/($exclude_s)$/){ + elsif ($distro_file && -s $distro_file && $distro_file !~ /\/etc\/($exclude_s)$/){ # new opensuse uses os-release, but older ones may have a similar syntax, so just use # the first line if ($distro_file eq '/etc/SuSE-release'){ @@ -23298,7 +23420,7 @@ sub get_linux_distro { } # otherwise try the default debian/ubuntu/distro /etc/issue file elsif ($b_issue){ - if ( !$distro_id && $lc_issue && $lc_issue =~ /(mint|lmde)/){ + if (!$distro_id && $lc_issue && $lc_issue =~ /(mint|lmde)/){ $distro_id = $1; $b_skip_issue = 1; } @@ -23311,7 +23433,7 @@ sub get_linux_distro { elsif (!$b_skip_issue && $b_lsb){ $distro = get_lsb_release(); } - elsif ($etc_issue) { + elsif ($etc_issue){ if (-d '/etc/guix' && $lc_issue =~ /^this is the gnu system\./){ $distro = 'Guix'; # they didn't use any standard paths or files for os data, sigh, use pm version @@ -23324,7 +23446,7 @@ sub get_linux_distro { # this handles an arch bug where /etc/arch-release is empty and /etc/issue # is corrupted only older arch installs that have not been updated should # have this fallback required, new ones use os-release - if ( $distro =~ /arch linux/i){ + if ($distro =~ /arch linux/i){ $distro = 'Arch Linux'; } } @@ -23333,7 +23455,7 @@ sub get_linux_distro { # a final check. If a long value, before assigning the debugger output, if os-release # exists then let's use that if it wasn't tried already. Maybe that will be better. # not handling the corrupt data, maybe later if needed. 10 + distro: (8) + string - if ($distro && length($distro) > 60 ){ + if ($distro && length($distro) > 60){ if (!$b_skip_osr && @osr){ $distro = get_os_release(); $b_skip_osr = 1; @@ -23352,7 +23474,7 @@ sub get_linux_distro { } } # now some final null tries - if (!$distro ){ + if (!$distro){ # if the file was null but present, which can happen in some cases, then use # the file name itself to set the distro value. Why say unknown if we have # a pretty good idea, after all? @@ -23448,9 +23570,9 @@ sub system_base { my $base_upstream_osr = '/etc/upstream-release/os-release'; # first: try, some distros have upstream-release, elementary, new mint # and anyone else who uses this method for fallback ID - if ( -r $base_upstream_osr){ + if (-r $base_upstream_osr){ my @osr_working = main::reader($base_upstream_osr); - if ( @osr_working){ + if (@osr_working){ my (@osr_temp); @osr_temp = @osr; @osr = @osr_working; @@ -23459,7 +23581,7 @@ sub system_base { (@osr_temp,@osr_working) = (undef,undef); } } - elsif ( -r $base_upstream_lsb){ + elsif (-r $base_upstream_lsb){ $system_base = get_lsb_release($base_upstream_lsb); } if (!$system_base && @osr){ @@ -23585,7 +23707,7 @@ sub get_os_release { $version_id = $working[1]; } # for mint/zorin, other ubuntu base system base - if ($base_type ){ + if ($base_type){ if ($working[0] eq 'ID_LIKE' && $working[1]){ if ($base_type eq 'ubuntu'){ # popos shows debian @@ -23614,7 +23736,7 @@ sub get_os_release { } $distro .= " $version_name"; } - elsif ($pretty_name && ($pretty_name !~ /tumbleweed/i && $lc_name ne 'arcolinux') ){ + elsif ($pretty_name && ($pretty_name !~ /tumbleweed/i && $lc_name ne 'arcolinux')){ $distro = $pretty_name; } elsif ($name){ @@ -23633,14 +23755,14 @@ sub get_os_release { $base_id .= ' ' if $base_id; $distro = "$base_name $base_id$base_version"; } - elsif ($base_type eq 'default' && ($pretty_name || ($name && $version_name) ) ){ + elsif ($base_type eq 'default' && ($pretty_name || ($name && $version_name))){ $distro = ($name && $version_name) ? "$name $version_name" : $pretty_name; } # LMDE 2 has only limited data in os-release, no _LIKE values. 3 has like and debian_codename - elsif ( $base_type eq 'ubuntu' && $lc_name =~ /^(debian|ubuntu)/ && ($pretty_name || ($name && $version_name))){ + elsif ($base_type eq 'ubuntu' && $lc_name =~ /^(debian|ubuntu)/ && ($pretty_name || ($name && $version_name))){ $distro = ($name && $version_name) ? "$name $version_name": $pretty_name; } - elsif ( $base_type eq 'debian' && $base_version ){ + elsif ($base_type eq 'debian' && $base_version){ $distro = debian_id($base_version); } } @@ -23671,13 +23793,13 @@ sub debian_id { if (main::is_numeric($debian_version)){ $id .= " $debian_version " . $debians{int($debian_version)}; } - elsif ($codename) { + elsif ($codename){ my %by_value = reverse %debians; my $version = (main::is_numeric($debian_version)) ? "$debian_version $codename": $debian_version; $id .= " $version"; } # like buster/sid - elsif ($debian_version) { + elsif ($debian_version){ $id .= " $debian_version"; } eval $end if $b_log; @@ -23727,7 +23849,7 @@ package DmidecodeData; sub set { eval $start if $b_log; ${$_[0]} = 1; # set check boolean by reference - if ($fake{'dmidecode'} || $alerts{'dmidecode'}->{'action'} eq 'use' ){ + if ($fake{'dmidecode'} || $alerts{'dmidecode'}->{'action'} eq 'use'){ generate_data(); } eval $end if $b_log; @@ -23780,7 +23902,7 @@ sub generate_data { $handle = hex($1); $type = $2; $use{'slot-tool'} = 1 if $type && $type == 9; - $b_skip = ( $type > 126 )? 1 : 0; + $b_skip = ($type > 126) ? 1 : 0; next if $b_skip; # we don't need 32, system boot, or 127, end of table if (@working){ @@ -23811,7 +23933,7 @@ sub generate_data { sub get_driver_modules { eval $start if $b_log; my ($driver,$modules) = @_; - return if ! $modules; + return if !$modules; my @mods = split(/,\s+/, $modules); if ($driver){ @mods = grep {!/^$driver$/} @mods; @@ -23830,7 +23952,7 @@ sub get_gcc_data { my ($gcc,@data,@gccs,@temp); # NOTE: We can't use program_version because we don't yet know where # the version number is - if (my $program = check_program('gcc') ){ + if (my $program = check_program('gcc')){ @data = grabber("$program --version 2>/dev/null"); $gcc = awk(\@data,'^gcc'); } @@ -23871,7 +23993,7 @@ sub get { my $gptid_trimmed = $gptid; # slice off s[0-9] from end in case they use slice syntax $gptid_trimmed =~ s/s[0-9]+$//; - if (defined $temp[0] && ($temp[0] eq $gptid || $temp[0] eq $gptid_trimmed ) ){ + if (defined $temp[0] && ($temp[0] eq $gptid || $temp[0] eq $gptid_trimmed)){ $dev_id = $temp[2]; last; } @@ -23896,10 +24018,10 @@ sub set { sub get_hostname { eval $start if $b_log; my $hostname = ''; - if ( $ENV{'HOSTNAME'} ){ + if ($ENV{'HOSTNAME'}){ $hostname = $ENV{'HOSTNAME'}; } - elsif ( !$bsd_type && -r "/proc/sys/kernel/hostname" ){ + elsif (!$bsd_type && -r "/proc/sys/kernel/hostname"){ $hostname = reader('/proc/sys/kernel/hostname','',0); } # puppy removed this from core modules, sigh @@ -23908,7 +24030,7 @@ sub get_hostname { Sys::Hostname->import; $hostname = Sys::Hostname::hostname(); } - elsif (my $program = check_program('hostname')) { + elsif (my $program = check_program('hostname')){ $hostname = (grabber("$program 2>/dev/null"))[0]; } $hostname ||= 'N/A'; @@ -23921,18 +24043,18 @@ sub get_init_data { my $runlevel = get_runlevel_data(); my $default = ($extra > 1) ? get_runlevel_default() : ''; my ($init,$init_version,$rc,$rc_version,$program) = ('','','','',''); - my $comm = ( -r '/proc/1/comm' ) ? reader('/proc/1/comm','',0) : ''; + my $comm = (-r '/proc/1/comm') ? reader('/proc/1/comm','',0) : ''; my (@data); # this test is pretty solid, if pid 1 is owned by systemd, it is systemd # otherwise that is 'init', which covers the rest of the init systems. # more data may be needed for other init systems. - if ( $comm ){ - if ( $comm =~ /systemd/ ){ + if ($comm){ + if ($comm =~ /systemd/){ $init = 'systemd'; if ($program = check_program('systemd')){ $init_version = program_version($program,'^systemd','2','--version',1); } - if (!$init_version && ($program = check_program('systemctl') ) ){ + if (!$init_version && ($program = check_program('systemctl'))){ $init_version = program_version($program,'^systemd','2','--version',1); } } @@ -23961,24 +24083,24 @@ sub get_init_data { # init (upstart 0.6.3) # openwrt /sbin/init hangs on --version command, I think if ((!$b_mips && !$b_sparc && !$b_arm) && - ($init_version = program_version('init', 'upstart', '3','--version') )){ + ($init_version = program_version('init', 'upstart', '3','--version'))){ $init = 'Upstart'; } elsif (check_program('launchctl')){ $init = 'launchd'; } - elsif ( -f '/etc/inittab' ){ + elsif (-f '/etc/inittab'){ $init = 'SysVinit'; if (check_program('strings')){ @data = grabber('strings /sbin/init'); $init_version = awk(\@data,'^version\s+[0-9]',2); } } - elsif ( -f '/etc/ttys' ){ + elsif (-f '/etc/ttys'){ $init = 'init (BSD)'; } } - if ( (grep { /openrc/ } globber('/run/*openrc*')) || (grep {/openrc/} @ps_cmd) ){ + if ((grep { /openrc/ } globber('/run/*openrc*')) || (grep {/openrc/} @ps_cmd)){ $rc = 'OpenRC'; # /sbin/openrc --version == openrc (OpenRC) 0.13 if ($program = check_program('openrc')){ @@ -23988,13 +24110,13 @@ sub get_init_data { elsif ($program = check_program('rc')){ $rc_version = program_version($program, '^rc', '3','--version'); } - if ( -r '/run/openrc/softlevel' ){ + if (-r '/run/openrc/softlevel'){ $runlevel = reader('/run/openrc/softlevel','',0); } - elsif ( -r '/var/run/openrc/softlevel'){ + elsif (-r '/var/run/openrc/softlevel'){ $runlevel = reader('/var/run/openrc/softlevel','',0); } - elsif ( $program = check_program('rc-status')){ + elsif ($program = check_program('rc-status')){ $runlevel = (grabber("$program -r 2>/dev/null"))[0]; } } @@ -24015,7 +24137,7 @@ sub get_init_data { package IpData; sub set { eval $start if $b_log; - if ($alerts{'ip'}->{'action'} eq 'use' ){ + if ($alerts{'ip'}->{'action'} eq 'use'){ set_ip_addr(); } elsif ($alerts{'ifconfig'}->{'action'} eq 'use'){ @@ -24186,7 +24308,7 @@ sub get_kernel_data { # FreeBSD; siwi.pair.com; 8.2-STABLE; FreeBSD 8.2-STABLE #0: Tue May 31 14:36:14 EDT 2016 erik5@iddhi.pair.com:/usr/obj/usr/src/sys/82PAIRx-AMD64; amd64 if (@uname){ $kernel = $uname[2]; - if ( (my $program = check_program('uptrack-uname')) && $kernel){ + if ((my $program = check_program('uptrack-uname')) && $kernel){ $ksplice = qx($program -rm); $ksplice = trimmer($ksplice); $kernel = ($ksplice) ? $ksplice . ' (ksplice)' : $kernel; @@ -24210,7 +24332,7 @@ sub get_kernel_bits { # fallback test if (!$bits && @uname){ $bits = $uname[-1]; - $bits = ($bits =~ /64/ ) ? 64 : 32; + $bits = ($bits =~ /64/) ? 64 : 32; } $bits ||= 'N/A'; eval $end if $b_log; @@ -24223,10 +24345,10 @@ package KernelParameters; sub get { eval $start if $b_log; my ($parameters); - if (my $file = $system_files{'proc-cmdline'}) { + if (my $file = $system_files{'proc-cmdline'}){ $parameters = parameters_linux($file); } - elsif ($bsd_type) { + elsif ($bsd_type){ $parameters = parameters_bsd(); } eval $end if $b_log; @@ -24270,14 +24392,19 @@ sub set { eval $start if $b_log; $loaded{'lsblk'} = 1; if ($alerts{'lsblk'} && $alerts{'lsblk'}->{'path'}){ - my $cmd = $alerts{'lsblk'}->{'path'} . ' -bP --output NAME,TYPE,RM,FSTYPE,SIZE,LABEL,UUID,'; - $cmd .= 'SERIAL,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS,MAJ:MIN,PKNAME 2>/dev/null'; + # check to see if lsblk removes : - separators from accepted input syntax + my $cmd = $alerts{'lsblk'}->{'path'} . ' -bP --output NAME,TYPE,RM,FSTYPE,'; + $cmd .= 'SIZE,LABEL,UUID,SERIAL,MOUNTPOINT,PHY-SEC,LOG-SEC,PARTFLAGS,'; + $cmd .= 'MAJ:MIN,PKNAME 2>/dev/null'; + print "cmd: $cmd\n" if $dbg[32]; + my @working = main::grabber($cmd); + print Data::Dumper::Dumper \@working if $dbg[32]; + # note: lsblk 2.37 changeed - and : to _ in the output. my $pattern = 'NAME="([^"]*)"\s+TYPE="([^"]*)"\s+RM="([^"]*)"\s+'; $pattern .= 'FSTYPE="([^"]*)"\s+SIZE="([^"]*)"\s+LABEL="([^"]*)"\s+'; $pattern .= 'UUID="([^"]*)"\s+SERIAL="([^"]*)"\s+MOUNTPOINT="([^"]*)"\s+'; - $pattern .= 'PHY-SEC="([^"]*)"\s+LOG-SEC="([^"]*)"\s+PARTFLAGS="([^"]*)"\s+'; - $pattern .= 'MAJ:MIN="([^"]*)"\s+PKNAME="([^"]*)"'; - my @working = main::grabber($cmd); + $pattern .= 'PHY[_-]SEC="([^"]*)"\s+LOG[_-]SEC="([^"]*)"\s+'; + $pattern .= 'PARTFLAGS="([^"]*)"\s+MAJ[:_-]MIN="([^"]*)"\s+PKNAME="([^"]*)"'; foreach (@working){ if (/$pattern/){ my $size = ($5) ? $5/1024: 0; @@ -24344,7 +24471,7 @@ sub get { $loaded{'memory'} = 1; # netbsd uses meminfo, but it uses it in a weird way if (!$force{'vmstat'} && (!$bsd_type || ($force{'meminfo'} && $bsd_type)) && - (my $file = $system_files{'proc-meminfo'})) { + (my $file = $system_files{'proc-meminfo'})){ $memory = meminfo_data($type,$file); } else { @@ -24409,7 +24536,7 @@ sub meminfo_data { } # seen fringe cases, where total - free+buff+cach < 0 # the idea is that the OS must be using 10MiB of ram or more - elsif (($total - ($free + $buffers + $cached)) > 10000) { + elsif (($total - ($free + $buffers + $cached)) > 10000){ $not_used = ($free + $buffers + $cached); } # netbsd goes < 0, but it's wrong, so dump the cache @@ -24532,7 +24659,7 @@ sub bsd_data { } } # use openbsd/dragonfly avail mem data if available - elsif (($av_pages || $free_mem) && $real_mem) { + elsif (($av_pages || $free_mem) && $real_mem){ my $used = (!$free_mem) ? $av_pages : $real_mem - $free_mem; my $percent = ($used && $real_mem) ? sprintf("%.1f", ($used/$real_mem)*100) : ''; if ($type eq 'string'){ @@ -24573,7 +24700,7 @@ sub get_gpu_ram { sub get_module_version { eval $start if $b_log; my ($module) = @_; - return if ! $module; + return if !$module; my ($version); my $path = "/sys/module/$module/version"; if (-r $path){ @@ -24583,7 +24710,7 @@ sub get_module_version { $version = 'kernel'; } # print "version:$version\n"; - if (!$version) { + if (!$version){ if (my $path = check_program('modinfo')){ my @data = grabber("$path $module 2>/dev/null"); $version = awk(\@data,'^version',2,':\s+') if @data; @@ -24724,7 +24851,7 @@ sub package_counts { if ($_->[2] eq 'p' || ($_->[2] eq 'pkg' && $force{'pkg'})){ chomp(@list = qx($program $_->[3] 2>/dev/null)); } - elsif ($_->[2] eq 'd') { + elsif ($_->[2] eq 'd'){ @list = main::globber($_->[3]); } else { @@ -24870,7 +24997,7 @@ sub set_ps_aux { # slice out 10th to last elements of ps aux rows my $final = $#split; # some stuff has a lot of data, chrome for example - $final = ($final > ($ps_cols + 2) ) ? $ps_cols + 2 : $final; + $final = ($final > ($ps_cols + 2)) ? $ps_cols + 2 : $final; if ($split[$ps_cols] !~ /^\[/){ push(@ps_cmd,join(' ', @split[$ps_cols .. $final])); } @@ -24957,7 +25084,7 @@ sub set_ps_gui { sub get_runlevel_data { eval $start if $b_log; my $runlevel = ''; - if ( my $program = check_program('runlevel')){ + if (my $program = check_program('runlevel')){ $runlevel = (grabber("$program 2>/dev/null"))[0]; $runlevel =~ s/[^\d]//g if $runlevel; # print_line($runlevel . ";;"); @@ -24978,7 +25105,7 @@ sub get_runlevel_default { my $systemd = '/etc/systemd/system/default.target'; my $upstart = '/etc/init/rc-sysinit.conf'; # note: systemd systems do not necessarily have this link created - if ( -e $systemd){ + if (-e $systemd){ $default = readlink($systemd); $default =~ s/.*\/// if $default; $b_systemd = 1; @@ -24986,13 +25113,13 @@ sub get_runlevel_default { # http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level # note that technically default can be changed at boot but for inxi purposes # that does not matter, we just want to know the system default - elsif ( -r $upstart){ + elsif (-r $upstart){ # env DEFAULT_RUNLEVEL=2 @data = reader($upstart); $default = awk(\@data,'^env\s+DEFAULT_RUNLEVEL',2,'='); } # handle weird cases where null but inittab exists - if (!$default && -r $inittab ){ + if (!$default && -r $inittab){ @data = reader($inittab); $default = awk(\@data,'^id.*initdefault',2,':'); } @@ -25003,7 +25130,7 @@ sub get_runlevel_default { sub get_self_version { eval $start if $b_log; my $patch = $self_patch; - if ( $patch ne '' ){ + if ($patch ne ''){ # for cases where it was for example: 00-b1 clean to -b1 $patch =~ s/^[0]+-?//; $patch = "-$patch" if $patch; @@ -25239,7 +25366,7 @@ sub set { # a few manual changes for known # Note: parent when fizsh shows as zsh but SHELL is fizsh, but other times # SHELL is default shell, but in zsh, SHELL is default shell, not zfs - if ($shell eq 'zsh' && $working eq 'fizsh' ){ + if ($shell eq 'zsh' && $working eq 'fizsh'){ $shell = $working; } } @@ -25439,7 +25566,7 @@ sub console_irc_tty { eval $start if $b_log; $loaded{'con-irc-tty'} = 1; # not set for root in or out of display - if (defined $ENV{'XDG_VTNR'} ){ + if (defined $ENV{'XDG_VTNR'}){ $client{'con-irc-tty'} = $ENV{'XDG_VTNR'}; } else { @@ -25477,7 +25604,7 @@ sub tty_number { $ENV{'XDG_VTNR'} ne $client{'tty-number'}){ $client{'tty-number'} = "$client{'tty-number'} (vt $ENV{'XDG_VTNR'})"; } - elsif ($client{'tty-number'} eq '' && defined $ENV{'XDG_VTNR'}) { + elsif ($client{'tty-number'} eq '' && defined $ENV{'XDG_VTNR'}){ $client{'tty-number'} = $ENV{'XDG_VTNR'}; } main::log_data('data',"tty:$client{'tty-number'}") if $b_log; @@ -25495,7 +25622,7 @@ sub set_sysctl_data { # sleep 2x if ($use{'bsd-sleep'} && !$system_files{'proc-cpuinfo'}){ if ($b_hires){ - eval 'Time::HiRes::usleep( $sleep )'; + eval 'Time::HiRes::usleep($sleep)'; } else { select(undef, undef, undef, $cpu_sleep); @@ -25622,7 +25749,7 @@ sub get_uptime { $days = ($1 + 0) . 'd'; } if ($uptime =~ /\b([0-9]{1,2}):([0-9]{1,2})\b/){ - $hours =( $1 + 0) . 'h'; + $hours = ($1 + 0) . 'h'; $minutes = ($2 + 0) . 'm'; } else { @@ -25690,7 +25817,7 @@ sub set { usbconfig_data(); } # if user config sets USB_SYS you can override with --usb-tool - elsif ((!$force{'usb-sys'} || $force{'lsusb'}) && $alerts{'lsusb'}->{'action'} eq 'use' ){ + elsif ((!$force{'usb-sys'} || $force{'lsusb'}) && $alerts{'lsusb'}->{'action'} eq 'use'){ lsusb_data(); } elsif (-d '/sys/bus/usb/devices'){ @@ -26137,7 +26264,7 @@ sub sys_data { if ($source eq 'lsusb'){ for ($i = 0; $i < scalar @{$usb{'main'}}; $i++){ if ($usb{'main'}->[$i][0] eq $bus_id && $usb{'main'}->[$i][1] == $device_id){ - if (!$b_hub && $usb{'main'}->[$i][13] && (!$type || $type eq '' )){ + if (!$b_hub && $usb{'main'}->[$i][13] && (!$type || $type eq '')){ $type = check_type($usb{'main'}->[$i][13],$driver,$type); } # print $type,"\n"; @@ -26150,7 +26277,8 @@ sub sys_data { $usb{'main'}->[$i][8] = $usb_version; $usb{'main'}->[$i][9] = $interfaces; $usb{'main'}->[$i][10] = $ports if $ports; - if ($type && $b_hub && (!$usb{'main'}->[$i][13] || $usb{'main'}->[$i][13] =~ /^linux foundation/i )){ + if ($type && $b_hub && (!$usb{'main'}->[$i][13] || + $usb{'main'}->[$i][13] =~ /^linux foundation/i)){ $usb{'main'}->[$i][13] = "$type"; } $usb{'main'}->[$i][14] = $type if ($type && !$b_hub); @@ -26175,7 +26303,7 @@ sub sys_data { $product = main::cleaner($product) if $product; $vendor = sys_item("$_/manufacturer"); $vendor = main::cleaner($vendor) if $vendor; - if (!$b_hub && ($product || $vendor )){ + if (!$b_hub && ($product || $vendor)){ if ($vendor && $product && $product !~ /$vendor/){ $name = "$vendor $product"; } @@ -26190,7 +26318,7 @@ sub sys_data { $name = $type; } $name = main::remove_duplicates($name) if $name; - if (!$b_hub && $name && (!$type || $type eq '' )){ + if (!$b_hub && $name && (!$type || $type eq '')){ $type = check_type($name,$driver,$type); } # this isn't that useful, but save in case something shows up @@ -26251,7 +26379,7 @@ sub uevent_data { push(@interfaces, $interface); } # networking requires more data but this test is reliable - elsif (!@interfaces) { + elsif (!@interfaces){ $temp = $_; $temp =~ s/\/uevent$//; push(@interfaces, 'Network') if -d "$temp/net/"; @@ -26312,7 +26440,7 @@ sub assign_usb_type { push(@{$usb{'audio'}},$row); } if ($show{'graphic'} && ( - $row->[14] && ($row->[14] =~ /Video/ ) || + $row->[14] && ($row->[14] =~ /Video/) || ($row->[15] && $row->[15] =~ /video/) || ($row->[13] && lc($row->[13]) =~ /(camera|\bdvb-t|\b(pc)?tv\b|video|webcam)/))){ push(@{$usb{'graphics'}},$row); @@ -26336,8 +26464,8 @@ sub device_type { # note: the 3/0/0 value passed will be decimal, not hex my @types = split('/', $data) if $data; # print @types,"\n"; - if (!@types || $types[0] eq '0' || scalar @types != 3) {return '';} - elsif ($types[0] eq '255') { return '';} + if (!@types || $types[0] eq '0' || scalar @types != 3){return '';} + elsif ($types[0] eq '255'){ return '';} if (scalar @types == 3){ $class_id = $types[0]; $subclass_id = $types[1]; @@ -26425,7 +26553,7 @@ sub check_type { # linux only, will create a positive match to sound devices sub set_asound_ids { $b_asound = 1; - if (-d '/proc/asound') { + if (-d '/proc/asound'){ # note: this will double the data, but it's easier this way. # binxi tested for -L in the /proc/asound files, and used only those. my @files = main::globber('/proc/asound/*/usbid'); @@ -26683,7 +26811,7 @@ sub short_output { $cpu[1] ||= main::row_defaults('cpu-model-null'); $cpu_string = $cpu[0] . ' ' . $cpu[1] . $type; } - elsif ($bsd_type) { + elsif ($bsd_type){ if ($alerts{'sysctl'}->{'action'}){ if ($alerts{'sysctl'}->{'action'} ne 'use'){ $cpu_string = "sysctl $alerts{'sysctl'}->{'action'}"; @@ -26703,12 +26831,12 @@ sub short_output { if (@disk){ $size = ($disk[0]->{'logical-size'}) ? $disk[0]->{'logical-size'} : $disk[0]->{'size'}; # must be > 0 - if ($size && main::is_numeric($size) ){ + if ($size && main::is_numeric($size)){ $size_holder = $size; $size = main::get_size($size,'string'); } $used = $disk[0]->{'used'}; - if ($used && main::is_numeric($disk[0]->{'used'}) ){ + if ($used && main::is_numeric($disk[0]->{'used'})){ $used_holder = $disk[0]->{'used'}; $used = main::get_size($used,'string'); } @@ -26773,7 +26901,7 @@ sub info_item{ main::key($num++,1,1,'Uptime') => main::get_uptime(), },], ); - $index = scalar(@{ $data{$data_name} } ) - 1; + $index = scalar(@{$data{$data_name}}) - 1; if ($extra > 2){ my $wakeups = main::get_wakeups(); $data{$data_name}->[$index]{main::key($num++,0,2,'wakeups')} = $wakeups if defined $wakeups; @@ -26796,11 +26924,11 @@ sub info_item{ if ($gpu_ram){ $data{$data_name}->[$index]{main::key($num++,0,2,'gpu')} = $gpu_ram; } - if ( (!$b_display || $force{'display'}) || $extra > 0 ){ + if ((!$b_display || $force{'display'}) || $extra > 0){ my %init = main::get_init_data(); my $init_type = ($init{'init-type'}) ? $init{'init-type'}: 'N/A'; $data{$data_name}->[$index]{main::key($num++,1,1,'Init')} = $init_type; - if ($extra > 1 ){ + 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; } @@ -26813,9 +26941,9 @@ sub info_item{ if ($init{'runlevel'}){ $data{$data_name}->[$index]{main::key($num++,0,2,'runlevel')} = $init{'runlevel'}; } - if ($extra > 1 ){ + if ($extra > 1){ if ($init{'default'}){ - my $default = ($init{'init-type'} eq 'systemd' && $init{'default'} =~ /[^0-9]$/ ) ? 'target' : 'default'; + my $default = ($init{'init-type'} eq 'systemd' && $init{'default'} =~ /[^0-9]$/) ? 'target' : 'default'; $data{$data_name}->[$index]{main::key($num++,0,2,$default)} = $init{'default'}; } if ($b_admin && (my $tool = ServiceData::get('tool',''))){ @@ -26824,7 +26952,7 @@ sub info_item{ } } } - if ($extra > 0 ){ + if ($extra > 0){ my $b_clang; my $clang_version = ''; if (my $path = main::check_program('clang')){ @@ -26836,7 +26964,7 @@ sub info_item{ $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; - if ( $extra > 1 && $gcc_alt){ + if ($extra > 1 && $gcc_alt){ $data{$data_name}->[$index]{main::key($num++,0,3,'alt')} = $gcc_alt; } } @@ -26867,7 +26995,7 @@ sub info_item{ } # can be tty 0 so test for defined $running_in = $parent if $parent; - if ($extra > 2 && $running_in && ShellData::ssh_status() ){ + if ($extra > 2 && $running_in && ShellData::ssh_status()){ $running_in .= ' (SSH)'; } if ($extra > 2 && $client{'su-start'}){ @@ -26901,7 +27029,7 @@ sub system_item { my %data = ( $data_name => [{}], ); - $index = scalar(@{ $data{$data_name} } ) - 1; + $index = scalar(@{$data{$data_name}}) - 1; if ($show{'host'}){ $data{$data_name}->[$index]{main::key($num++,0,1,'Host')} = main::get_hostname(); } @@ -26920,12 +27048,16 @@ sub system_item { } } if ($b_admin && (my $params = KernelParameters::get())){ - $index = scalar(@{ $data{$data_name} } ); + $index = scalar(@{$data{$data_name}}); # print "$params\n"; - $params = main::apply_partition_filter('system', $params, 'label') if $use{'filter-label'}; - $params = main::apply_partition_filter('system', $params, 'uuid') if $use{'filter-uuid'}; + if ($use{'filter-label'}){ + $params = main::apply_partition_filter('system', $params, 'label'); + } + if ($use{'filter-uuid'}){ + $params = main::apply_partition_filter('system', $params, 'uuid'); + } $data{$data_name}->[$index]{main::key($num++,0,2,'parameters')} = $params; - $index = scalar(@{ $data{$data_name} } ); + $index = scalar(@{$data{$data_name}}); } # note: tty can have the value of 0 but the two tools # return '' if undefined, so we test for explicit '' @@ -26936,7 +27068,7 @@ sub system_item { $desktop .= ' ' . $desktop_version if $desktop_version; if ($extra > 0 && $desktop_data[3]){ # $desktop .= ' (' . $desktop_data[2]; - # $desktop .= ( $desktop_data[3] ) ? ' ' . $desktop_data[3] . ')' : ')'; + # $desktop .= ($desktop_data[3]) ? ' ' . $desktop_data[3] . ')' : ')'; $toolkit = "$desktop_data[2] $desktop_data[3]"; } if ($extra > 2 && $desktop_data[4]){ @@ -26945,12 +27077,12 @@ sub system_item { # don't print the desktop if it's a wm and the same if ($extra > 1 && $desktop_data[5] && (!$desktop_data[0] || $desktop_data[5] =~ /^(deepin.+|gnome[\s_-]shell|budgie.+)$/i || - index(lc($desktop_data[5]),lc($desktop_data[0])) == -1 )){ + index(lc($desktop_data[5]),lc($desktop_data[0])) == -1)){ $wm = $desktop_data[5]; $wm .= ' ' . $desktop_data[6] if $extra > 2 && $desktop_data[6]; } } - if (!$b_display || (!$desktop && $b_root)) { + if (!$b_display || (!$desktop && $b_root)){ ShellData::tty_number() if !$loaded{'tty-number'}; my $tty = $client{'tty-number'}; if (!$desktop){ @@ -26979,7 +27111,7 @@ sub system_item { } if ($extra > 1){ $data{$data_name}->[$index]{main::key($num++,0,2,'wm')} = $wm if $wm; - if ($extra > 2 && $b_display && defined $ENV{'XDG_VTNR'} ){ + if ($extra > 2 && $b_display && defined $ENV{'XDG_VTNR'}){ $data{$data_name}->[$index]{main::key($num++,0,2,'vt')} = $ENV{'XDG_VTNR'}; } my $dms = main::get_display_manager(); diff --git a/inxi.1 b/inxi.1 index baf9d2a..3d79efb 100644 --- a/inxi.1 +++ b/inxi.1 @@ -15,7 +15,7 @@ .\" with this program; if not, write to the Free Software Foundation, Inc., .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. .\" -.TH INXI 1 "2021\-07\-11" "inxi" "inxi manual" +.TH INXI 1 "2021\-07\-21" "inxi" "inxi manual" .SH NAME inxi \- Command line system information script for console and IRC @@ -337,6 +337,9 @@ this result to increase the \fBMemory:\fR amount and \fBused:\fR amounts. Shows all active swap types (partition, file, zram). When this option is used, swap partition(s) will not show on the \fB\-P\fR line to avoid redundancy. +To show partition labels or UUIDs (when available and relevant), use with +\fB\-l\fR or\fB \-u\fR. + .TP .B \-J\fR,\fB \-\-usb\fR Show USB data for attached Hubs and Devices. Hubs also show number of ports. @@ -360,8 +363,10 @@ The \fBrev: 2.0\fR item refers to the USB revision number, like \fB1.0\fR or .TP .B \-l\fR,\fB \-\-label\fR -Show partition labels. Default: main partitions \fB\-P\fR. For full \fB\-p\fR -output, use: \fB\-pl\fR. +Show partition labels. Use with \fB\-j\fR, \fB\-o\fR, \fB\-p\fR, and \fB\-P\fR +to show partition labels. Does nothing without one of those options. + +Sample: \fB\-ojpl\fR. .TP .B \-L\fR, \fB\-\-logical\fR @@ -552,11 +557,17 @@ BSD users: see \fBman doas.conf\fR for setup. Does not show components (partitions that create the md\-raid array) of md\-raid arrays. +To show partition labels or UUIDs (when available and relevant), use with +\fB\-l\fR or\fB \-u\fR. + .TP .B \-p\fR,\fB \-\-partitions\-full\fR Show full Partition information (\fB\-P\fR plus all other detected mounted partitions). +To show partition labels or UUIDs (when available and relevant), use with +\fB\-l\fR or\fB \-u\fR. + .TP .B \-P\fR,\fB \-\-partitions\fR Show basic Partition information. @@ -565,6 +576,9 @@ Shows, if detected: \fB/ /boot /boot/efi /home /opt /tmp /usr /usr/home /var If \fB\-\-swap\fR is not used, shows active swap partitions (never shows file or zram type swap). Use \fB\-p\fR to see all mounted partitions. +To show partition labels or UUIDs (when available and relevant), use with +\fB\-l\fR or\fB \-u\fR. + .TP .B \-\-processes\fR \- See \fB\-t\fR @@ -686,8 +700,10 @@ same line. .TP .B \-u\fR,\fB \-\-uuid\fR -Show partition UUIDs. Default: main partitions \fB\-P\fR. For full \fB\-p\fR -output, use: \fB\-pu\fR. +Show partition UUIDs. Use with \fB\-j\fR, \fB\-o\fR, \fB\-p\fR, and \fB\-P\fR +to show partition labels. Does nothing without one of those options. + +Sample: \fB\-opju\fR. .TP .B \-U\fR,\fB \-\-update\fR @@ -776,7 +792,8 @@ feature. DO NOT USE THIS FEATURE FOR AUTOMATED WEATHER UPDATES! Automated or excessive use will lead to your being blocked from any further access. This feature is not meant for widget type weather monitoring, or Conky type use. It is meant to get -weather when you need to see it, for example, on a remote server. +weather when you need to see it, for example, on a remote server. If you did not +type the weather option in manually, it's an automated request. .TP .B \-W\fR, \fB\-\-weather\-location \fR @@ -797,9 +814,11 @@ Use only ASCII letters in city/state/country names. Examples: \fB\-W 95623,us\fR OR \fB\-W Boston,MA\fR OR \fB\-W 45.5234,\-122.6762\fR OR \fB\-W new+york,ny\fR OR \fB\-W bodo,norway\fR. -DO NOT USE THIS FEATURE FOR AUTOMATED WEATHER UPDATES! Use of automated queries, -will result in your access being blocked. If you try to work around the ban, -you will be permanently banned from this service. +DO NOT USE THIS FEATURE FOR AUTOMATED WEATHER UPDATES! Automated or excessive +use will lead to your being blocked from any further access. This feature is not +meant for widget type weather monitoring, or Conky type use. It is meant to get +weather when you need to see it, for example, on a remote server. If you did not +type the weather option in manually, it's an automated request. .TP .B \-\-weather\-source\fR, \fB\-\-ws \fR @@ -1286,10 +1305,11 @@ Requires doas[BSDs]/sudo/root and \fBdmidecode\fR. Currently not able to detect all schemes, but handles the most common, e.g. \fBGPT\fR or \fBMBR\fR. -\- Adds disk rotation speed (in some but not all cases), e.g. -\fBrotation: 7200 rpm\fR or \fBrotation: SSD\fR if positive SSD identification -was made. If no rotation or positive SSD ID found, nothing shows. Not all disks -report this speed, so even if they are spinnning, no data will show. +\- Adds disk type (\fBHDD\fR/\fBSSD\fR), rotation speed (in some but not all +cases), e.g. \fBtype: HDD rpm: 7200\fR, or \fBtype: SSD\fR if positive SSD +identification was made. If no HDD, rotation, or positive SSD ID found, shows +\fBtype: N/A\fR. Not all HDD spinning disks report their speed, so even if they +are spinnning, no rpm data will show. .TP .B \-xxx \-E\fR (\fB\-\-bluetooth\fR) diff --git a/inxi.changelog b/inxi.changelog index 868e046..6e922a0 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,183 @@ +================================================================================ +Version: 3.3.06 +Patch: 00 +Date: 2021-07-19 +-------------------------------------------------------------------------------- +UPDATES: +-------------------------------------------------------------------------------- + +New version! Fixes!! Bug fixes! More bug fixes!! Cleanups! + +Most of these were exposed by issue #251 filed by LukasNickel, then further +revealed via his debugger data set, which showed two more bugs. Well, bugs, +changed syntaxes, same difference to end users. + +-------------------------------------------------------------------------------- +KNOWN ISSUES: + +1. Work is ongoing to add btrfs support to -R (similar to softraid or zfs), +basic stubs and debuggers added, but reporting tools are not as robust (and +often require sudo/root for reasons that escape me) as I would have hoped, so +it's slow. One of these days... Normally would not release with working stubs, +but there were enough real issues/bugs to warrant just getting 3.3.06 out the +door, then going on with the btrfs feature for -R. But so far I view the +reporting tools as inadequate, unfortunately. + +-------------------------------------------------------------------------------- +BUGS: + +1. As initially discovered in issue #251 there are alternate syntaxes which had +never been seen before for remote mounts, fuse mounts, etc. In this case, it was +fuse.sshfs that was not removed from the Disk total:... used: leading to silly +1000+% used percentage. Note that while technically inxi could try to be clever +about reporting impossible percentages, so far those have led to bugs getting +reported, then fixed, so I think it worth leaving it as is. + +2. When --swap/-j is used with no other arguments, failed to show uuid or label. +Discovered this while testing fix 2. + +3. Bug which is not a bug but will appear as such to users, nvme temps were +failing in -Dx due to a change in how those values are located in /sys. See fix +3. + +-------------------------------------------------------------------------------- +FIXES: + +1. Going along with Bug 1, and considering that only in 3.3.05 was the nfs4 +remote fs failure to identify/exclude, the entire section involving remote/ fuse +etc file systems was refactored, and extended to add many more previously +non-handled remote and fuse type file systems. Significant extension of known +remote filesystem types, distributed file systems, overlay file systems, all to +try to avoid having more distributed/remote/fuse file system issues. Also added +test to support fuse. or fuseblk. type prefixes for any of these. Hopefully +there will be fewer issues related to distributed and remote and overlay type +file systems in the future. + +2. Made all label/uuid triggers global, that is, -ol shows unmounted with +labels, -ju shows swap with uuid, and so on. This may require a bit more tweaks +to get exactly right, but in general, this is a purely cosmetic fix, that is, +try not to show label/uuid for partition/mounts that probably can't have those +values. + +3. There was a change in the way nvme /sys temperature paths were handled, an +actually understandable, albeit as always annoying, one, because inxi actually +had to do a sort of convoluted hack to get the nvme block devices temperatore +paths before, now that hack is not required for newer kernels (5.12+), though +for kernels that had the old paths (5,8, 5.9 at least, don't know when paths +changed) left in the old method. Now tests are more granular, and inxi should +find temperatures regardless of which method is used for nvme and sd type +drives. + +4. Another somewhat irksome random change, again, understandable since the new +syntax is more consistent in output than the previous one, but still breaks all +existing parsers that use the changed field names. Lsblk did NOT change the -o +input field names, but DID change the output field names, which broke the +internal inxi parser, and led to null lsblk data. + +Changes were - or : separators in input values are output as _ always. that is, +MAJ:MIN becomes MAJ_MIN. Also corrected the debugger lsblk to use the same +output fields for -P -o as the actual lsblk parser uses internally so these +failures can be spotted more readily, as it was, it was literally only because +someone submitted the debugger dataset, and was running lsblk 2.37, where I +believe this behavior change happened. Solution was to just use regex patterns +instead, [:_-], in the parser. Big fear now is that they will randomly stop +supporting the -o input field names that contain - or : and change that too +without any real warning or deprecation notice. + +-------------------------------------------------------------------------------- +ENHANCEMENTS: + +1. Going with bug and fix 1, added avfs, afs, archivemount, avfs, ceph, gfs, +glusterfs, gmailfs, hdfs, ipfs, kosmos/kfs, lafs, mergerfs, mhddfs, moosefs, +ocfs, openafs, orangefs, overlayfs, pvfs, s3fs, sheepdog, vmfs, and several +others to the exclude list for disk used and show label/uuids for partitions. + +2. A smattering of disk vendors added. + +-------------------------------------------------------------------------------- +CHANGES: + +1. Going with fix 2, -l and -u no longer will trigger -P by default, now if -l +or -u are used without -j, -o, -p, -P, an error will explain that you must use +one of those together with -l or -u. This was the only way to get the -l and -u +switches to turn off/on label/uuid reports in swap, unmounted, and partitions +consistently. Triggering -P was really a legacy behavior from when the only +options were -p or -P, and --swap and --unmounted did not exist. I found it +increasingly odd that unmounted would show label/uuid always but partitions only +with -l/-u. + +2. This was a pet peeve, sometimes field names just bug me (like 'Topology: did +for CPU, now corrected to Info:), the Drive: rotation: was one such annoyance. +I had recycled that to indicate SSD, which was a feature request, but that was +always a sloppy solution, and made no sense, since SSD isn't a rotation speed. + +Now it reports a much more logical: + +ID-1:...... type: HDD rpm: 7200 +or +ID-1:...... type: SSD +or +ID-1:...... type: N/A + +This also corresponds to the intended meaning much better. The HDD type was +always present internally if rotation speed is detected, but was not used. Now +will also show type: N/A if reliable type detection failed, which will also be +more consistent. + +-------------------------------------------------------------------------------- +DOCUMENTATION: + +1. Brought most of inxi.changelog (this file) into a consistent state, re +whitespaces, readability, consistent use of various header / section names. +Ideally while I don't expect anyone to ever sit down and read this changelog, it +will be now much easier to scan to find whatever interests you. This change goes +along with ongoing changes in docs to in general try to be usually 80 columns +wide. + +2. inxi-resources.txt, inxi-data.txt are updated with more raid, partition, file +system values and data to go along with bug, fix, enhancement 1. + +3. Man and help updated to indicate -u and -l no longer trigger -P by default. + +-------------------------------------------------------------------------------- +CODE: + +1. Ongoing refactors, bringing the codebase to the point that matches current +coding styles. Removed remainder of whitespaces in conditions and for/while +loops, for example: + +if ( condition ) { +becomes: +if (condition){ +and +if ( ( test set 1 ) && ( test set 2 ) ) { +becomes: +if ((test set 1) && (test set 2)){ + +and so on. That dropped over 2 KiB of whitespaces. This went along with fixes +that have been ongoing to change to this whitespace use style, but previously it +was only being done when that situation was hit in a local block, now it's been +completed globally. + +This continues the style refactor that has been ongoing for a while now, to +bring inxi into a consistent state, since when it started, it was more pressing +to get the bash/gawk mess translated to Perl than it was to get the Perl itself +to be as good/consistent as possible, so now those issues are being slowly +unravelled, and hopefully will set inxi on course for its next 10 years. + +It was starting to get annoying, because some parts of inxi used those spaces, +and all newer ones didn't in general. Now it's one behavior throughout the whole +program file. + +2. Refactored the entire fs exclude for disk used data, and integrated those +values into a global tool that is used either to exclude file systems from disk +used totals, or to not show uuid/labels for the excluded +remote/distributed/overlay type file systems, which in general don't have uuid +or labels. + +-------------------------------------------------------------------------------- +-- Harald Hope - Wed, 21 Jul 2021 18:23:21 -0700 + ================================================================================ Version: 3.3.05 Patch: 00 @@ -11429,5 +11609,6 @@ to derive cpu speed. Better than nothing I guess, but will be wrong in other cases, particularly with dual core arm. + -------------------------------------------------------------------------------- -- Harald Hope - Mon, 21 Jan 2013 16:24:40 -0800