Skip to content
Snippets Groups Projects
getInfo.pl 2.29 KiB
#!/usr/bin/perl


my $file = $ARGV[0];

open(FILE,"<$file") || die "Cannot open file $file: $!\n";

$testName = "";
$blockSize= "";
$testEngine="";
$ioDepth=0;
$cpuU=0;
$cpuS=0;
$i=0;
$nProc=0;
%hashTest = ();

my @clat = ("50.00th", "90.00th", "95.00th", "99.00th");


while (<FILE>) {
    $line = $_;
    $i++;
    if ($i == 1) {
	if ($line =~ /.*rw=(\S+),\s+bs=.* (\S+)-\S+.*, ioengine=(\S+),\s+iodepth=(\d+)/) {
	    ( $testName, $blockSize, $testEngine, $ioDepth ) = ( $1, $2, $3, $4);
	    $hashTest{'all'}{'aType'} = $testName;
	    $hashTest{'all'}{'aBsize'} = $blockSize;
	    $hashTest{'all'}{'aTestEngine'} = $testEngine;
	    $hashTest{'all'}{'aIOdepth'} = $ioDepth;
	}
    }
    if ($line =~ /^Starting (\d+)/) {
	$hashTest{'all'}{'aNproc'} = $1;
    }
    if ($line =~ /.*cpu.*usr=([0-9]*\.[0-9]+)%,\s+sys=([0-9]*\.[0-9]+)%,/) {
	$hashTest{'all'}{'aCpuU'} = $1;
	$hashTest{'all'}{'aCpuS'} = $2;
    }
    if ($line =~ /(\S+)\s*: IOPS=(\d+), BW=([0-9]*\.?[0-9]+)(\S+)\s+\(\S+\)\(([0-9]*\.?[0-9]+)(\S+)\/(\d+)(\S+)\)/) {
	$theTest = $1;
	$hashTest{$theTest}{'iot'} = $5;
	$hashTest{$theTest}{'iotunit'} = $6;
	$hashTest{$theTest}{'bw'} = $3;
	$hashTest{$theTest}{'bwunit'} = $4;
	$hashTest{$theTest}{'iops'} = $2;
	$hashTest{$theTest}{'rt'} = $7;
	$hashTest{$theTest}{'rtunit'} = $8;
	$clatUnit = "";
	do {
	    my $l = <FILE>;
	    if ( $l =~ /clat percentiles \((\w+)\)/ ) {
		$clatUnit = $1;
		$hashTest{$theTest}{"clatUnit"} = $clatUnit;
		$endClat = 0;
		do {
		    my $l2 = <FILE>;
		    $endClat = 1 if ( $l2 !~ /,\s+$/);
		    for $aClat ( @clat ) {
			if ( $l2 =~ /$aClat=\[\s*(\d+)\]/) {
			    $hashTest{$theTest}{"clat".$aClat} = $1;
			}
		    }
		} while (! $endClat);
	    }
	} while ($clatUnit eq "");
    }
}

my $lineT = "";