User Tools

Site Tools


unix:chromeos:systemreport

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
unix:chromeos:systemreport [2023/07/04 15:32] rodolicounix:chromeos:systemreport [2023/07/04 17:06] (current) rodolico
Line 18: Line 18:
   - Save as your_nameChrome.pdf (ie, RodChrome.pdf)   - Save as your_nameChrome.pdf (ie, RodChrome.pdf)
  
-You now have two large files in your downloads folder, and mhtml file and a PDF. The following Perl script parses the mhtml file, using ====CATEGORY==== as headers, with the contents afterwards. I have written it to NOT include the logs. Use the command: +You now have two large files in your downloads folder, and mhtml file and a PDF. The following Perl script parses the mhtml file, using ====CATEGORY==== as headers, with the contents afterwards. I have written it to NOT include the logs. 
-<code bash>tr -d '\r' < filename | ./processChrome.pl > filename.txt</code>+ 
 +Note: The mhtml output uses Windows line endings, so if you're running this on a Unix machine, you'll want to run it through tr to get convert it to Unix line endings. 
 + 
 +Use the command: 
 +<code bash>tr -d '\r' < filename | perl processChrome.pl > filename.txt</code>
  
 <code perl processChrome.pl> <code perl processChrome.pl>
Line 29: Line 33:
 # tr -d '\r' < filename | ./processChrome.pl # tr -d '\r' < filename | ./processChrome.pl
  
 +# anything matching these keys will be include, and all else 
 +# will be excluded. If empty, will include everything not 
 +# matching $ignoreKeys. In this case, we've commented out 
 +# everything, so it will output everything not ignored
 my %lookFor = (  my %lookFor = ( 
-   'div-bios-info-value' => 'bios_info', +#   'div-bios-info-value' => 'bios_info', 
-   'div-blkid-value' => 'blkid', +  'div-blkid-value' => 'blkid', 
-   'div-cpuinfo-value' => 'cpuinfo', +  'div-cpuinfo-value' => 'cpuinfo', 
-   'div-disk-usage-value' => 'disk_usage', +  'div-disk-usage-value' => 'disk_usage', 
-   'div-ifconfig-value' => 'ifconfig', +  'div-ifconfig-value' => 'ifconfig', 
-   'div-lsblk-value' => 'lsblk', +  'div-lsblk-value' => 'lsblk', 
-   'div-meminfo-value' => 'meminfo', +  'div-meminfo-value' => 'meminfo', 
-   'div-network-devices-value' => 'network_devices', +  'div-network-devices-value' => 'network_devices', 
-   'div-os-release-NAME-value' => 'os-release NAME', +  'div-os-release-NAME-value' => 'os-release NAME', 
-   'div-os-release-VERSION-value' => 'os-release VERSION', +  'div-os-release-VERSION-value' => 'os-release VERSION', 
-   'div-uname-value' => 'uname', +  'div-uname-value' => 'uname', 
-   'div-vpd-2-0-value' => 'vpd_2.0'+  'div-vpd-2-0-value' => 'vpd_2.0'
 ); );
  
 +# anything matching this regex will be ignored
 +# this matches anything with log, profile or ui-heirarchy in 
 +# the key. NOTE: match is case insensitive
 +my $ignoreRegex = qr'.*(log)|(profile)|(ui-hierarchy).*'i;
 +
 +
 +# get a single line. This is more difficult since the output
 +# takes very long lines and separates them into 80 column blocks
 +# the indicator for this continuation is an equals sign (=)
 +# at the end of the line. Thus, we continue to read lines from
 +# STDIN so long as the current line ends with an equal sign
 +# and we concatinate all of the lines together
 sub getLine { sub getLine {
    my @lines;    my @lines;
Line 59: Line 78:
       }       }
    }    }
 +}
 +
 +# makes a category name from the div name
 +sub makeCategory {
 +   my $initValue = shift;
 +   $initValue =~ m/div-(.*)-value/;
 +   $initValue = $1;
 +   $initValue =~ s/-/ /g;
 +   return $initValue;
 } }
  
Line 72: Line 100:
    # Ok, if we have a category already, and have found a </div>, clear the category    # Ok, if we have a category already, and have found a </div>, clear the category
    $category = '' if $category && $line =~ m"</div>";    $category = '' if $category && $line =~ m"</div>";
-   if ( $line =~ m/^.*<div.*id="(div-[^"]+-value)">(.*)$/ ) { +   # check for a line like <div id="div-something-value"> and begin processing if found 
-      my $key = $1+   # $matches[0] has the key name (ie, something), and $matches[1] has any subsequent 
-      $line = $2; +   # information, generally the beginning of the actual block 
-      #print "$key\n$line\n"; die+   if ( my @matches = ($line =~ m/^.*<div.*id="(div-[^"]+-value)">(.*)$/ ) { 
-      # this is one of the ones we wantso start using it +     print "Found div $matches[0]\n"
-      if ( $lookFor{$key} ) { +      # skip if $ignoreRegex defined has matches. Note, this is case insensitive 
-         $category = $lookFor{$key}; +     die "Checking $matches[0]\nagainst\n$ignoreRegex\n"; 
-         #print "$key\n$line\n"; die; +      next if $ignoreRegex && $matches[0] =~ m/.*($ignoreRegex).*/
-         $found{$category} = $line . "\n";+      # if %lookFor empty, or not empty and has matching keyinlcude it 
 +      if ( ! %lookFor || $lookFor{$matches[0]} ) { 
 +         # Create the category 
 +         $category = defined( $lookFor{$matches[0]) ? $lookFor{$matches[0]} : &makeCategory( $matches[0] ) 
 +         # include any information beginning the div 
 +         $found{$category} = $matches[1] . "\n";
       }       }
    } elsif ( $category ) {    } elsif ( $category ) {
 +      # we're in the middle of a div, so just add the line.
       $found{$category} .= $line;       $found{$category} .= $line;
    }    }
unix/chromeos/systemreport.1688502742.txt.gz · Last modified: 2023/07/04 15:32 by rodolico