Sanitatier (sanitatier) wrote,
Sanitatier
sanitatier

Транспонирование отчета

Переворот отчёта DP по сессиям, мне удобно в одну строку читать...

использовать так: omnidb -session -datalist "Oracle8 SpecName" -since 2015/03/01 -detail | perl sessiontotable.pl

sessiontotable.pl

my %SESSION;
my $SessionID;
while (<>){
chomp;
next if $_ eq "";
if (/^SessionID.* (\d+.*)/){
#print $1;
$SessionID=($1);
next;
}
~m/^\s*(\S[^:]+?)\s*:+?\s+(.*)\s*$/;
$SESSION{$SessionID}{$1}=$2;
}

local $,="\t"; $\="\n";
print "SessionID", "Backup Specification", "Session type", "Started", "Finished", "Status", "Number of warnings", "Number of errors", "User", "Group", "Host";
foreach my $key1 (sort keys %SESSION) {
foreach my $key2 (keys %{$SESSION{$key1}}) {
$sbspec=$SESSION{$key1}{$key2} if $key2 eq "Backup Specification";
$sstype=$SESSION{$key1}{$key2} if $key2 eq "Session type";
$sstart=$SESSION{$key1}{$key2} if $key2 eq "Started";
$sfinis=$SESSION{$key1}{$key2} if $key2 eq "Finished";
$sstats=$SESSION{$key1}{$key2} if $key2 eq "Status";
$snowrn=$SESSION{$key1}{$key2} if $key2 eq "Number of warnings";
$noerrs=$SESSION{$key1}{$key2} if $key2 eq "Number of errors";
$ssuser=$SESSION{$key1}{$key2} if $key2 eq "User";
$sgroup=$SESSION{$key1}{$key2} if $key2 eq "Group";
$sehost=$SESSION{$key1}{$key2} if $key2 eq "Host";
}
print $key1, $sbspec, $sstype,$sstart,$sfinis,$sstats,$snowrn,$noerrs,$ssuser,$sgroup,$sehost;
}
Tags: #print, dataprotector, perl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 0 comments