diff --git a/utils/disk.py b/utils/disk.py index 808e14d..84c18b1 100644 --- a/utils/disk.py +++ b/utils/disk.py @@ -12,13 +12,13 @@ def get_disk_usage(path): try: stat_res = os.statvfs(path) total = stat_res.f_blocks * stat_res.f_bsize - free = stat_res.f_bfree * stat_res.f_bsize + free = stat_res.f_bavail * stat_res.f_bsize used = (stat_res.f_blocks - stat_res.f_bfree) * stat_res.f_bsize total_space = misc.bytes_to_string(total) free_space = misc.bytes_to_string(free) used_space = misc.bytes_to_string(used) - used_percent = "%.2f%%" % (100 * (float(used) / float(total))) + used_percent = "%.2f%%" % (100 * (float(used) / float(free+used))) except Exception: pass return total_space, used_space, used_percent, free_space