From fd86aed42c913e8a6f055c5f90086b21c07b9fb5 Mon Sep 17 00:00:00 2001
From: Fulvio Galeazzi <fulvio.galeazzi@garr.it>
Date: Fri, 26 Nov 2021 17:09:27 +0100
Subject: [PATCH] 2021-11-26:  FG;  Fix Ceph numObjects, ensure queryTotDisk is
 not hindered by messages to stderr.

---
 Ceph/Script/cephUsage.pl       | 8 ++++++--
 DiskIO/Script/queryTotDisks.pl | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Ceph/Script/cephUsage.pl b/Ceph/Script/cephUsage.pl
index 703a773..cb94238 100755
--- a/Ceph/Script/cephUsage.pl
+++ b/Ceph/Script/cephUsage.pl
@@ -167,9 +167,13 @@ foreach my $_line (@_data)
 	    $poolHash{'GLOBAL'}{'size'} = convertNumber($fields[7].$fields[8],'size');
 	    $poolHash{'GLOBAL'}{'frac'} = $fields[9];
 ### In Nautilus, total number of objects is not available
+	    my @_tmpDfOut = `$cephCmd -s | grep objects:`;
+	    my $tmpLine = $_tmpDfOut[0];
+	    $tmpLine =~ s/^\s*//;
+	    my @tmpArr = split(/\s+/, $tmpLine);
+	    $poolHash{'GLOBAL'}{'objs'} = convertNumber($tmpArr[1],'count');
 #	    $poolHash{'GLOBAL'}{'objs'} = convertNumber($fields[5],'count');
-#	    print "GLOBAL: ".$poolHash{'GLOBAL'}{'size'}." ".$poolHash{'GLOBAL'}{'frac'}." ".$poolHash{'GLOBAL'}{'objs'}."\n" if (defined $opt_debug);
-	    print "GLOBAL: ".$poolHash{'GLOBAL'}{'size'}." ".$poolHash{'GLOBAL'}{'frac'}."\n" if (defined $opt_debug);
+	    print "GLOBAL: ".$poolHash{'GLOBAL'}{'size'}." ".$poolHash{'GLOBAL'}{'frac'}." ".$poolHash{'GLOBAL'}{'objs'}."\n" if (defined $opt_debug);
 	    $inGlobal = 0;
 	    next;
 	}
diff --git a/DiskIO/Script/queryTotDisks.pl b/DiskIO/Script/queryTotDisks.pl
index 6f7b18e..62d0e1f 100755
--- a/DiskIO/Script/queryTotDisks.pl
+++ b/DiskIO/Script/queryTotDisks.pl
@@ -72,7 +72,7 @@ if ( -e $_multipathd && $checkMultipath ) {
     }
 }
 
-my @_lsblk = `lsblk | grep disk | cut -d' ' -f1 | grep -v -e ^fd -e ^sr0 `;
+my @_lsblk = `lsblk 2>/dev/null | grep disk | cut -d' ' -f1 | grep -v -e ^fd -e ^sr0 `;
 chomp @_lsblk;
 my @_data = `cat $_proc`;
 s{^\s+|\s+$}{}g foreach @_data;
-- 
GitLab