Catch ZeroDivisionError when f_files=0
On BTRFS, f_files and f_ffree are always 0. For now, assume there is no limit by setting files_percent_avail to 100%. Change-Id: I53455e46101130596ae178a5933fe51ebaee206f
This commit is contained in:
parent
2c2a2d61a5
commit
5933704a6a
@ -26,9 +26,12 @@ def get_avail_hdd_inode_pct(path):
|
||||
blocks_percent = (blocks_used / s.f_blocks) * 100
|
||||
blocks_percent_avail = 100.0 - blocks_percent
|
||||
|
||||
files_used = float(s.f_files - s.f_ffree)
|
||||
files_percent = (files_used / s.f_files) * 100
|
||||
files_percent_avail = 100.0 - files_percent
|
||||
try:
|
||||
files_used = float(s.f_files - s.f_ffree)
|
||||
files_percent = (files_used / s.f_files) * 100
|
||||
files_percent_avail = 100.0 - files_percent
|
||||
except ZeroDivisionError:
|
||||
files_percent_avail = 100.0 # Assume no limit if f_files=0.
|
||||
|
||||
return (blocks_percent_avail, files_percent_avail)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user