Commit dfcf92f4 authored by Fulvio Galeazzi's avatar Fulvio Galeazzi
Browse files

2019-08-29: FG; Update to new structure of ceph_df_detail output, fix...

2019-08-29:  FG;  Update to new structure of ceph_df_detail output, fix fraction used, fix when size is 0B.
parent 382e53b0
......@@ -31,6 +31,7 @@ sub convertNumber
if ($toWhat eq 'size') {
# return unit: T
$string =~ s/iB$//;
$string =~ s/B$//;
$value = $string;
my $lastChar = lc(chop($string));
if ($lastChar eq "p") {
......@@ -178,19 +179,25 @@ foreach my $_line (@_data)
$poolTest = $fields[1];
}
if (exists $poolHash{$poolTest}) {
$poolHash{$poolTest}{'size'} += convertNumber($fields[6],'size');
$poolHash{$poolTest}{'tot'} = convertNumber($fields[8],'size') unless ($poolHash{$poolTest}{'tot'} > convertNumber($fields[8],'size'));
if ( $poolHash{$poolTest}{'tot'} > 0. ) {
$poolHash{$poolTest}{'frac'} = $poolHash{$poolTest}{'size'} / $poolHash{$poolTest}{'tot'};
$poolHash{$poolTest}{'used'} += convertNumber($fields[5],'size');
$poolHash{$poolTest}{'size'} += convertNumber($fields[12],'size');
my $tempFrac = $fields[6];
my $tempMax = convertNumber($fields[7],'size');
$tempMax = $poolHash{$poolTest}{'used'}/$tempFrac/0.01 if ($tempFrac > 1.);
$poolHash{$poolTest}{'max'} = $tempMax unless ($poolHash{$poolTest}{'max'} > $tempMax);
if ( $poolHash{$poolTest}{'max'} > 0. ) {
$poolHash{$poolTest}{'frac'} = $poolHash{$poolTest}{'used'} / $poolHash{$poolTest}{'max'};
}
$poolHash{$poolTest}{'objs'} += convertNumber($fields[9],'count');
} else {
$poolHash{$poolTest}{'size'} = convertNumber($fields[6],'size');
$poolHash{$poolTest}{'frac'} = 0.;
$poolHash{$poolTest}{'tot'} = convertNumber($fields[8],'size');
$poolHash{$poolTest}{'used'} = convertNumber($fields[5],'size');
$poolHash{$poolTest}{'size'} = convertNumber($fields[12],'size');
$poolHash{$poolTest}{'frac'} = $fields[6];
$poolHash{$poolTest}{'max'} = convertNumber($fields[7],'size');
$poolHash{$poolTest}{'max'} = $poolHash{$poolTest}{'used'}/$poolHash{$poolTest}{'frac'}/0.01 if ($poolHash{$poolTest}{'frac'} > 1.);
$poolHash{$poolTest}{'objs'} = convertNumber($fields[9],'count');
}
print "POOL: $poolTest ".$poolHash{$poolTest}{'size'}." ".$poolHash{$poolTest}{'frac'}." ".$poolHash{$poolTest}{'objs'}."\n" if (defined $opt_debug);
print "POOL: $poolTest ".$poolHash{$poolTest}{'used'}." ".$poolHash{$poolTest}{'max'}." ".$poolHash{$poolTest}{'size'}." ".$poolHash{$poolTest}{'frac'}." ".$poolHash{$poolTest}{'objs'}."\n" if (defined $opt_debug);
}
if (defined $opt_debug) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment