#!/usr/bin/perl -w # # @(#)$Id: ipa.info.pl,v 1.10 2004/10/21 19:46:44 jleffler Exp $ # # Extract outstanding IPA information from 'oncheck -pT' output # # Usage: # ipa.info [-V][-a][-l][-d N] [file...] # By default, only list only table fragments with outstanding # IPAs (database:owner.table, with partition and dbspace # information if available). Input files should be the output # from 'oncheck -pT'. # -a - list all fragments and whether there is an outstanding IPA. # -l - list all IPA version records # -d N - set debug to level N (0, 1, 2 are relevant). Level 0 is # default. Level 1 lists all IPA version records and implies # '-a'. Level 2 tracks the input data too. # -V - print version information and exit. # # Based on sample output from IDS 9.50.UC1, 9.40.UC4, 7.31.UD5, 9.30.UC3. # Examples included non-fragmented tables, fragmented tables, and tables # partitioned (fragmented) with multiple fragments in a single dbspace # (9.50 feature), with and without outstanding IPAs. Some of the # fragmented tables only had IPAs outstanding on some fragments. # # Tested with Perl 5.005_03, 5.6.1, 5.8.0, 5.8.5. use strict; use Getopt::Std; use File::Basename; my %opts; getopts('ald:V', \%opts); if (defined $opts{V}) { my $VERSION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/); my $arg0 = basename $0; print "$arg0 version $VERSION\n"; exit 0; } my $aflag = (defined $opts{a}) ? 1 : 0; my $lflag = (defined $opts{l}) ? 1 : 0; my $debug = (defined $opts{d}) ? $opts{d} : 0; sub debug { return $debug; } # Read and discard a line - with optional trace. sub read_discard { my($n) = @_; $_ = <>; chomp; print "XX discard $n: $_\n" if debug > 1; } # Array or hash for versions? Advantages and disadvantages to both. my($dbase, $owner, $table, $partition, $dbspace, %versions); my $stage = 0; while (<>) { chomp; if (/^TBLspace Report for (\w+):(\w+)\.(\w+)/) { $stage = 1; print "== retain 1: $_\n" if debug > 1; $dbase = $1; $owner = $2; $table = $3; $partition = ""; $dbspace = ""; %versions = (); # Necessary for non-fragmented tables. } elsif (/Table fragment( partition (\w+))? in DBspace (\w+)/) { # 9.50 - Table fragment partition p0 in DBspace rootdbs # 9.40 - Table fragment in DBspace rootdbs print "== retain 2: $_\n" if debug > 1; $partition = $2; $dbspace = $3; $stage = 2; %versions = (); # Necessary for fragmented tables. } elsif (/Home Data Page Version Summary/ && $stage > 0) { print "== retain 3: $_\n" if debug > 1; read_discard(1); # Blank line read_discard(2); # Version/Count header read_discard(3); # Blank line my($pages, $sum, $min, $max) = (0, 0, undef, 0); while (<>) { chomp; last if (/^\s*$/); last unless m/(\d+)\s+(\((oldest|current)\)\s+)?(\d+)/; print "== retain 4: $_\n" if debug > 1; $pages = $4; $versions{$1} = $pages; $sum += $pages; $min = $1 unless defined $min; $max = $1; #printf "i = %d, v = %d, s = %d, p = %d\n", $i, $versions{$i}, $sum, $pages; } print "XX discard 4: $_\n" if debug > 1; $stage = 0; next unless defined $min; if ($aflag || $sum != $pages || debug > 0) { my($dbinfo) = ""; $dbinfo .= " - partition $partition" if ($partition); $dbinfo .= " - dbspace $dbspace" if ($dbspace); my $ipainfo = ""; $ipainfo = " -" . (($sum == $pages) ? " No" : "" ) . " Outstanding IPA" if ($aflag || $lflag || debug); printf "$dbase:$owner.$table$dbinfo$ipainfo\n"; } if (($lflag && $sum != $pages) || debug > 0) { foreach my $v ($min..$max) { printf "%15s version $v: $versions{$v} pages\n", " "; } } } else { print "XX discard 5: $_\n" if debug > 1; } } exit 0 __END__ =pod =head1 NAME ipa.info - print information about outstanding in-place alters (IPA). =head1 SYNOPSIS ipa.info [-a][-l][-d N] [file ...] =head1 DESCRIPTION The ipa.info script analyzes the output from 'oncheck -pT' and reveals which tables have outstanding in-place alters (henceforth, IPAs) remaining. When the table is fragmented, it identifies the dbspace in which the fragment with outstanding IPAs is located. When the table is partitioned (fragmented) with several partitions in a single dbspace (new feature in IDS 9.50), the partition name is identified too. Using this information plus the fragmentation scheme (when it is not ROUND ROBIN) can make the process of removing outstanding IPAs more efficient. By default, it simply lists those fragments (tables) identified in its input that have outstanding IPAs. Specifying '-a' means that each table analyzed is listed, along with a verdict ("Outstanding IPA" or "No Outstanding IPA"). Specifying '-l' means that when a table is listed with outstanding IPAs, the details of the versions are printed. Specifying '-d 0' is the default debugging level (no extra information). Specifying '-d 1' yields the verdict and version information for each table. Specifying '-d 2' shows how each input line is processed. =head1 AUTHOR Jonathan Leffler (C). =cut