From 3d437dc78d3aad3eb82b982ce67a3b4418f0d4e8 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 15 Feb 2009 20:23:45 -0800 Subject: [PATCH] catch file_system_usage exceptions --- bindings/ruby/examples/df.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bindings/ruby/examples/df.rb b/bindings/ruby/examples/df.rb index 3d404d35..38a02014 100644 --- a/bindings/ruby/examples/df.rb +++ b/bindings/ruby/examples/df.rb @@ -11,12 +11,16 @@ puts "Filesystem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n" fslist.each do |fs| dir_name = fs.dir_name - usage = sigar.file_system_usage(dir_name) - - total = usage.total - used = total - usage.free - avail = usage.avail - pct = usage.use_percent * 100 + begin + usage = sigar.file_system_usage(dir_name) + total = usage.total + used = total - usage.free + avail = usage.avail + pct = usage.use_percent * 100 + rescue Exception => e + #e.g. floppy or cdrom drive + used = avail = total = pct = 0; + end puts fs.dev_name + "\t" + format_size(total) + "\t" +