From 3bfc71ac24b9ab16a8741cfb37d5dfe085fdb284 Mon Sep 17 00:00:00 2001 From: Paul Jensen Date: Tue, 27 Oct 2020 12:45:18 -0700 Subject: [PATCH 1/2] Script to convert an ACT log file to .csv format, enabling it to be read by Excel (e.g. for charts, further analysis, etc.) --- analysis/log-to-csv.pl | 84 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 analysis/log-to-csv.pl diff --git a/analysis/log-to-csv.pl b/analysis/log-to-csv.pl new file mode 100755 index 0000000..15a506b --- /dev/null +++ b/analysis/log-to-csv.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# +# pjensen@aerospike.com +# +# Script to convert an ACT log file to .csv format, enabling it to +# be read by Excel (e.g. for charts, further analysis, etc.) +# +# Usage: log-to-csv.pl [-l [-o]] + +use Getopt::Std; +my %options = (); +getopts("l:o", \%options); + + +my $fh, $ofh; +if (defined $options{l}) { + open($fh, "<", $options{l}) || die "can't open $options{l}\n"; + if (defined $options{o}) { + $options{l} =~ s/\.log$//; + $options{l} .= ".csv"; + open($ofh, ">", "$options{l}"); + } +} else { + die "-o requires -l\n" if (defined $options{o}); + $fh = *STDIN; + $ofh = *STDOUT; +} + +#exit(0); + +while (<$fh>) { + last if (/^HISTOGRAM NAMES/); +} + +my @devs = (); +my @cur = (); + +while (<$fh>) { + chomp; + next if (/^device-reads$/); + last if (/^\s*$/); + s/\/dev\///; + push(@devs, $_); + print $ofh "$_,1 ms,2 ms,4 ms,8 ms,16 ms,32 ms,64 ms,"; +} +print $ofh "\n"; + +my @prev = (0) x (8 * ($#devs + 1)); +my $n; + +while (<$fh>) { + chomp; + if (/^after/) { + print $ofh "\n"; + $n = -8; + @cur = (); + } elsif (/^.* \((\d+) total/) { + if ($#cur >= 0) { + for (my $i=0; $i<7; $i++) { + print $ofh "$cur[$i],"; + $cur[$i] = 0; + } + } + $n += 8; + my $delta = $1 - $prev[$n]; + print $ofh "$delta,"; + $prev[$n] = $1; + } elsif (/^ \(/) { + while (s/ \((\d\d): (\d+)\)//) { + my $delta = $2 - $prev[$n + $1 + 1]; + $cur[$1] = $delta; + $prev[$n + $1 + 1] = $2; + } + } elsif (/^$/) { + if ($#cur >= 0) { + for (my $i=0; $i<7; $i++) { + print $ofh "$cur[$i],"; + $cur[$i] = 0; + } + } + } +} +print $ofh "\n"; +close $fh if (defined $options{l}); From d5055a2b8bd21ede73074aa74a92b615c9527a92 Mon Sep 17 00:00:00 2001 From: Paul Jensen Date: Tue, 27 Oct 2020 13:18:01 -0700 Subject: [PATCH 2/2] tweaks --- analysis/log-to-csv.pl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/analysis/log-to-csv.pl b/analysis/log-to-csv.pl index 15a506b..b67ed8c 100755 --- a/analysis/log-to-csv.pl +++ b/analysis/log-to-csv.pl @@ -3,7 +3,7 @@ # pjensen@aerospike.com # # Script to convert an ACT log file to .csv format, enabling it to -# be read by Excel (e.g. for charts, further analysis, etc.) +# be imported into spreadsheets (e.g. for charts, further analysis, etc.) # # Usage: log-to-csv.pl [-l [-o]] @@ -26,8 +26,6 @@ $ofh = *STDOUT; } -#exit(0); - while (<$fh>) { last if (/^HISTOGRAM NAMES/); } @@ -43,7 +41,6 @@ push(@devs, $_); print $ofh "$_,1 ms,2 ms,4 ms,8 ms,16 ms,32 ms,64 ms,"; } -print $ofh "\n"; my @prev = (0) x (8 * ($#devs + 1)); my $n;