From: Tom Hughes Date: Mon, 30 Nov 2015 14:43:38 +0000 (+0000) Subject: Round disk sizes X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/8032a5079b464ae4047aae90a4effebc6c2ff1d9?ds=sidebyside Round disk sizes --- diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 2874f3d65..150efae45 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -25,14 +25,17 @@ Ohai.plugin(:Hardware) do if kb == 0 "" else - kblog10 = Math.log10(kb) + kblog10 = Math.log10(kb).floor + + kb = kb.to_f * 2 / 10**kblog10 + kb = kb.round.to_f / 2 if kblog10 >= 9 - format "%gTB", 10**(kblog10 - 9) + format "%gTB", kb * 10**(kblog10 - 9) elsif kblog10 >= 6 - format "%dGB", 10**(kblog10 - 6) + format "%dGB", kb * 10**(kblog10 - 6) else - format "%dMB", 10**(kblog10 - 3) + format "%dMB", kb * 10**(kblog10 - 3) end end end