From 4912350de6d87eb80a9312edcfd8a82dafa7f840 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 21 Jun 2012 13:21:19 -0700 Subject: [PATCH] mogadm check shows "N/A" util on hosts w/o iostat Instead of falsely reporting zero I/O utilization, this helps admins detect broken configurations where iostat reporting is not available or misconfigured Tested on both a properly configured cluster and a misconfigured cluster (which I'm sad to admit I have one lying around :x). ref: http://code.google.com/p/mogilefs/issues/detail?id=9 --- mogadm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mogadm b/mogadm index 7673c7d..c1406db 100755 --- a/mogadm +++ b/mogadm @@ -507,12 +507,15 @@ sub cmd_check { $total{avail} += $data{avail}; $total{total} += $data{total}; - $dev->{utilization} = 0 if (!defined($dev->{utilization}) || - $dev->{utilization} !~ /\A\d+(\.\d+)?\Z/); - printf(" %10.3f %10.3f %10.3f %6.2f%% %-7s %5.1f\n", + my $util = "N/A"; + if (defined($dev->{utilization}) && $dev->{utilization} =~ /\A\d+(\.\d+)?\Z/) { + $util = sprintf("%.1f", $dev->{utilization}); + } + + printf(" %10.3f %10.3f %10.3f %6.2f%% %-7s %5s\n", (map { $data{$_} } qw(total used avail)), $pct, ($dev->{observed_state} || "?"), - $dev->{utilization}); + $util); } } my $pct = 0;