-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreportFragmentation.pl
More file actions
executable file
·59 lines (54 loc) · 1.34 KB
/
reportFragmentation.pl
File metadata and controls
executable file
·59 lines (54 loc) · 1.34 KB
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
#!/usr/bin/perl -w
#
# This script will run a full integrity on the provided backup database file.
# It will create a CSV report of the fragmentation percent of the globals.
#
use strict;
use warnings;
print "Which database file should I examine? ";
my $dbfile = <STDIN>;
chomp $dbfile;
die "Database file $dbfile error: $!\n" unless -f $dbfile;
chomp(my $TMP = `mktemp -u`);
my $cmd = "mupip integ -full -nomap -file $dbfile > $TMP 2>&1";
print "Running command: $cmd\n";
system($cmd) or warn "Error: $?\n";
sleep(2);
open(TMP,"$TMP") or die "Can't open file: $TMP $!\n";
print "Examining output file: $TMP\n";
while(<TMP>) {
chomp;
s/^\s+//; # remove leadin spaces
next if (/^\s+$/); # skip blank lines
if (/Integ/) {
print $_, "\n";
print "Global Variable,None-Adjacent Blocks,Total Blocks,Fragmentation %", "\n";
next;
}
if (/Global variable (.*)/) { print"$1"; }
if (/^0/) {
my @pieces = ();
@pieces = split;
my $fragPercent = "Unknown";
if($pieces[4] eq "NA") { next; }
else {
$fragPercent = 100-100*$pieces[4]/$pieces[1];
}
print ",";
print $pieces[1]-$pieces[4];
print ",";
print $pieces[1];
print ",";
if($fragPercent ne "Unknown") {
$fragPercent = sprintf("%5.2f", $fragPercent);
print $fragPercent;
}
else {
print $fragPercent;
}
print "\n";
}
}
close (TMP);
sleep(2);
unlink $TMP;