#!/usr/bin/perl -w require 5.003; use strict; # uses `lx' to extract various stats from polygraph binary logs # assigns those stats a `label' for future reference # see also: plot_results and report_results if (`pwd` =~ 'ReportGen') { use lib '..'; } use ReportGen::Opts; use ReportGen::Globs; # Configuration my @ObjsToTrace = qw( time req.rate rep.rate cachable.ratio.obj offered.hit.ratio.obj offered.hit.ratio.byte hit.ratio.obj hit.ratio.byte rep.size.mean rep.rptm.mean hit.rptm.mean miss.rptm.mean fill.size.sum err_xact.ratio err_xact.count xact.level.mean wait.level.mean conn.open.level.mean conn.estb.level.mean conn.open.started conn.estb.started conn.use.mean icp.req.rate icp.rep.rate icp.rep.rptm.mean icp.hit.rptm.mean icp.miss.rptm.mean icp.timeout.count duration ); my %Opts = ( log_extractor => undef(), log_extractor_opts => undef(), log_trace_extractor => undef(), log_trace_extractor_opts => undef(), log_dir => undef(), use_cache => undef(), ); my %SavedOpts = %Opts; # globals my $Label; # identifier for the logs my @Logs = (); # logs to label &init(); exit(&main()); sub main { &extract($Opts{log_extractor}, 'clt.All', $Opts{log_extractor_opts}); &extract($Opts{log_trace_extractor}, 'clt.Traces', $Opts{log_trace_extractor_opts}. ' --objects '. join(',', @ObjsToTrace)); return 0; } sub extract { my ($lx, $groupName, $options) = @_; $options = '' unless defined $options; my $oname = &FullOutFName($Label, $groupName, '.lx'); if (&upToDate($oname)) { warn("$0: `$oname' is up-to-date, using cached copy\n"); return; } warn("$0: creating: `$oname'\n"); my $cmd = sprintf("%s %s --out %s %s", $lx, $options, $oname, join(' ', @Logs)); &System($cmd); } sub upToDate { my $fname = shift; return 0 unless $Opts{use_cache} =~ /^y(es)?$/i; return 0 unless -f $fname || -z $fname; my $fmt = (stat($fname))[9]; return 0 unless $fmt; foreach my $log (@Logs) { my $logmt = (stat($log))[9]; return 0 unless $logmt; return 0 if $logmt >= $fmt; } return 1; } sub init { my @anon; ($Label, @Logs) = @anon if ParseOpts(\%Opts, \@anon, @ARGV); die("usage: $0 [options]