1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#!/usr/bin/perl
#
# FCP adapter trace utility
#
# Script to collect all system information required for analysis
#
# Copyright IBM Corp. 2008, 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
use strict;
use warnings;
use English;
use Cwd;
use File::Temp qw/ tempdir /;
use File::Spec::Functions;
use Getopt::Long;
sub version {
print "$PROGRAM_NAME: version %S390_TOOLS_VERSION%\n";
print "Copyright IBM Corp. 2008, 2017\n";
}
sub usage
{
print <<MSG
Usage: $PROGRAM_NAME [<options>]
$PROGRAM_NAME collects all system information required for analysis.
Options:
-h, --help
print this help text and exit.
-v, --version
print version information and exit.
-o, --output
specify the name of the output file
MSG
}
sub dir_content
{
my @temp_dir;
opendir(DH, shift()) or return 0;
@temp_dir = readdir(DH);
closedir(DH);
return @temp_dir;
}
sub store_mapper_devices
{
my $dest_dir = shift();
my $src_dir = shift();
my @entries = grep { ! /^\./ } dir_content($src_dir);
foreach my $map_dev (@entries) {
my $tf = catfile($src_dir, "$map_dev");
my $mm = `stat -L -c%t:%T $tf`;
chomp($mm);
$mm = join(":", map { hex($_) } split(":", $mm));
system("echo $mm > " . catfile($dest_dir, $src_dir, $map_dev));
}
}
my $out_file="config";
my $temp_dir = tempdir( CLEANUP => 1);
Getopt::Long::Configure(qw/ bundling /);
GetOptions('h|help' => sub {usage(); exit 0;},
'v|version' => sub {version(); exit 0;},
'o|output=s' => \$out_file,
) or do {
print "Invalid usage !\n";
usage();
exit 1;
};
system("mkdir -p $temp_dir/sys/block");
system("mkdir -p $temp_dir/sys/devices/virtual/block");
system("mkdir -p $temp_dir/sys/class");
system("mkdir -p $temp_dir/dev/mapper");
system("rsync -a --inplace /sys/block/dm* /sys/block/sd* $temp_dir/sys/block 2>/dev/null");
system("rsync -a --inplace --exclude=chpd* /sys/devices/css0 $temp_dir/sys/devices 2>/dev/null");
system("rsync -a --inplace /sys/devices/virtual/block/dm* $temp_dir/sys/devices/virtual/block 2>/dev/null");
system("rsync -a --inplace /sys/class/fc_host /sys/class/scsi_device /sys/class/scsi_tape /sys/class/scsi_generic /sys/class/fc_remote_ports $temp_dir/sys/class 2>/dev/null");
store_mapper_devices($temp_dir,"/dev/mapper");
system("tar -czf $out_file.cfg -C $temp_dir sys dev 2>/dev/null");
|