#!/opt/perl5//bin/perl =head1 FILE stat-upg-sap.pl =head1 AUTHOR E-MAIL: matteo.redaelli@libero.it WEB: http://digilander.iol.it/reda =head1 USAGE type 'stat-upg-sap.pl -h' =head1 DESCRIPTION During a SAP R/3 upgrade, the file /usr/sap/put/log/R4ip.log is created and it contains information about when a phase starts and ends. You can use this script to extract statistics from this file. The output is PHASE_NAME DURATION_TIME PARTIAL_TOTAL_TIME where the time is output as days,hours,minutes and seconds With the unix command paste and cut, you can build a spreadsheet document with a comarison of the statistics of severa upgrades. For example, stat-upg-sap.pl R3up-p00.log > p00.txt stat-upg-sap.pl R3up-p01.log > p01.txt paste p00.txt p01.txt | cut -f1,2,3,5,6 =head1 REQUIREMENT Perl 5 + Module Date::Calc Yow can download the from http://www.perl.com http://www.cpan.org =head1 TESTED I have tested this script on: the operating systems Linux, HP-UX 11, NT 4.0 perl 5.6.1 and R3up.log written by several SAP R/3 upgrade (3.1I -> 4.6C) I and others did in Pirelli on HP-UX 11 systems. =head1 MODIFIED Summer 2001, Matteo - The first release of this script. 2001-11-13, Matteo - I've used the package Date::Calc instead of Date::Manip 2001-11-15, Matteo - Added a column about the total time of the upgrade until that time 2002-03-30, Matteo - The output must be done when a new "UPGRADEPHASE " is met and not when a phase is finished with status SUCCESSED because when you choose "ignore errors"... (eg. ACT_46C phase of P03 upgrade) 2002-03-31, Matteo - Added option -s to print time in seconds 2002-07-05, Matteo - Added options -n -p -t -b =head1 BUGS 2002-03-30 - Dialog time should be skipped... =head1 LICENSE This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License". The C library at the core of this Perl module can additionally be redistributed and/or modified under the terms of the "GNU Library General Public License". =head1 DISCLAIMER This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "GNU General Public License" for more details. =cut use Getopt::Std; use Date::Calc::Object qw(:all); use strict; sub usage { my $rc = @_[0]; die <) { if (/^UPGRADEPHASE (.+)$/) { $fase = $1; # # If a phase goes wrong, it is repeated: # the phase time is printed only if the name of the phase changes... # if ( $oldphase cmp $fase && ($oldphase cmp "") ) { ($day_buf,$hour_buf,$min_buf,$sec_buf) = Normalize_DHMS($day_buf, $hour_buf, $min_buf, $sec_buf); ($day_tot,$hour_tot,$min_tot,$sec_tot) = Normalize_DHMS($day_tot+$day_buf, $hour_tot+$hour_buf, $min_tot+$min_buf, $sec_tot+$sec_buf); my $out_partial = "$day_buf,$hour_buf:$min_buf:$sec_buf"; my $out_tot = "$day_tot,$hour_tot:$min_tot:$sec_tot"; if ( $opts{'s'} ) { $out_partial = "" . DHMS2sec($day_buf, $hour_buf, $min_buf, $sec_buf); $out_tot = "" . DHMS2sec($day_tot, $hour_tot, $min_tot, $sec_tot); } print("$oldphase\t") if ( $opts{'n'} ); print("$out_partial") if ( $opts{'p'} ); print("\t$out_tot") if ( $opts{'t'} ); print("\n"); ($day_buf,$hour_buf,$min_buf,$sec_buf) = 0; } $oldphase = $fase; } elsif ( /^\.\.\.started at (....)(..)(..)(..)(..)(..)$/) { ($year1, $month1, $day1,$hour1, $min1, $sec1) = ($1,$2,$3,$4,$5,$6); } elsif ( /^\.\.finished at (....)(..)(..)(..)(..)(..) with status (.+)\.$/) { ($year2, $month2, $day2,$hour2, $min2, $sec2) = ($1,$2,$3,$4,$5,$6); $rc = $7; ($day,$hour,$min,$sec) = Delta_DHMS($year1,$month1, $day1,$hour1,$min1,$sec1, $year2,$month2,$day2, $hour2,$min2,$sec2); $day_buf += $day; $hour_buf += $hour; $min_buf += $min; $sec_buf += $sec; } } close $FILE; }