#!/usr/bin/perl -w =head1 NAME compare-lpps - compares the LPPs from multiple AIX systems =head1 SYNOPSIS B I I ... I<[ fileN ]> =head1 DESCRIPTION B parses the output of the "lslpp" command from two or more AIX systems and generates a tabular report, detailing the version of each LPP (Licensed Program Product) on each system in an easy to compare format. =head1 USAGE Before using this program, the user will need to run the "lslpp -Lc" command on each system to be included in the report. The output of the above command should be saved to a file whose name is that of the system it was run on. For example, if you have three AIX systems, named "buffy", "kendra", and "faith", you could generate these files by running: $ for host in buffy kendra faith; do \ > ssh $host lslpp -Lc > $host \ > done Once those files are saved, you can then generate the report by running: $ compare-lpps buffy kendra faith The report will be written to STDOUT, and can be imported as a space-delimited file into Excel, if desired. The output will be similar to ... LPP buffy kendra faith ======================= ============= ============= ============= AIX-rpm-5.2.0.10-1 -- 5.2.0.10 5.2.0.10 CLArrayS3 -- 5.1.0.6 -- EMC.CLARiiON.fcp.rte 5.2.0.1 -- 5.2.0.1 (output abreviated.) =head1 AUTHOR B was writen by Sandor W. Sklar . =head1 COPYRIGHT AND LICENSE Copyright 2006 Board of Trustees, Leland Stanford Jr. University. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. =head1 VERSION $Id$ =cut use strict; use File::Basename; ####################################################################### my (@hosts, %all_lpps, %lpps); my @files = @ARGV; unless (scalar (@files) > 1) { print "Usage: compare_lpps host1 host2 [ ... hostN ]\n"; exit 1 }; foreach (@files) { my $host = basename($_); push (@hosts, $host); open (FILE, "$_") or die "Couldn't read file $_: $!"; while () { next if /^#/; my @fields = split (/:/, $_); $all_lpps{$fields[1]} = $fields[7]; $lpps{$host}{$fields[1]} = $fields[2]; }; close FILE; }; ####################################################################### printf ("%-36s", "LPP"); for (0 .. $#hosts) { printf ("%-14s", $hosts[$_]); }; print "\n"; print "=" x 35 . " "; for (0 .. $#hosts) { print "=" x 13 . " "; }; print "\n"; foreach my $lpp (sort keys %all_lpps) { printf ("%-36s", "$lpp"); foreach my $host (@hosts) { if (exists $lpps{$host}{$lpp}) { printf ("%-14s", $lpps{$host}{$lpp}); } else { printf ("%-14s", "--"); }; } print "\n"; #print "$all_lpps{$lpp}\n"; }; exit 0;