[modules/memory] Fix "percentage used" calculation
For some reason, using "used/total" is more accurate than "(total - free)/total". Probably there's some missing gap of what is counted as used vs. what is counted as free. fixes #229
This commit is contained in:
parent
519dc1dafe
commit
b77fee4af2
1 changed files with 3 additions and 2 deletions
|
@ -50,12 +50,13 @@ class Module(bumblebee.engine.Module):
|
||||||
if tmp[2] == "mB": value = value*1024*1024
|
if tmp[2] == "mB": value = value*1024*1024
|
||||||
if tmp[2] == "gB": value = value*1024*1024*1024
|
if tmp[2] == "gB": value = value*1024*1024*1024
|
||||||
data[tmp[0]] = value
|
data[tmp[0]] = value
|
||||||
|
used = data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]
|
||||||
self._mem = {
|
self._mem = {
|
||||||
"total": bumblebee.util.bytefmt(data["MemTotal"]),
|
"total": bumblebee.util.bytefmt(data["MemTotal"]),
|
||||||
"available": bumblebee.util.bytefmt(data["MemAvailable"]),
|
"available": bumblebee.util.bytefmt(data["MemAvailable"]),
|
||||||
"free": bumblebee.util.bytefmt(data["MemFree"]),
|
"free": bumblebee.util.bytefmt(data["MemFree"]),
|
||||||
"used": bumblebee.util.bytefmt(data["MemTotal"] - data["MemFree"] - data["Buffers"] - data["Cached"] - data["Slab"]),
|
"used": bumblebee.util.bytefmt(used),
|
||||||
"percent": (float(data["MemTotal"] - data["MemAvailable"])/data["MemTotal"])*100
|
"percent": float(used)/float(data["MemTotal"])*100.0
|
||||||
}
|
}
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
|
|
Loading…
Reference in a new issue