catch file_system_usage exceptions
This commit is contained in:
parent
9e2576f7d6
commit
3d437dc78d
@ -11,12 +11,16 @@ puts "Filesystem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n"
|
|||||||
|
|
||||||
fslist.each do |fs|
|
fslist.each do |fs|
|
||||||
dir_name = fs.dir_name
|
dir_name = fs.dir_name
|
||||||
usage = sigar.file_system_usage(dir_name)
|
begin
|
||||||
|
usage = sigar.file_system_usage(dir_name)
|
||||||
total = usage.total
|
total = usage.total
|
||||||
used = total - usage.free
|
used = total - usage.free
|
||||||
avail = usage.avail
|
avail = usage.avail
|
||||||
pct = usage.use_percent * 100
|
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" +
|
puts fs.dev_name + "\t" +
|
||||||
format_size(total) + "\t" +
|
format_size(total) + "\t" +
|
||||||
|
Loading…
Reference in New Issue
Block a user