Prevent division by zero errors.

This commit is contained in:
facetoe 2014-10-12 11:58:52 +08:00
parent 1b3db989ed
commit 296d26f432

View File

@ -67,7 +67,10 @@ class CpuUsage(IntervalModule):
self.prev_total[cpu] = total self.prev_total[cpu] = total
self.prev_busy[cpu] = busy self.prev_busy[cpu] = busy
return int(diff_busy / diff_total * 100) if diff_total == 0:
return 0
else:
return int(diff_busy / diff_total * 100)
def gen_format_all(self, usage): def gen_format_all(self, usage):
""" """