mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
account for no swap detected
This commit is contained in:
parent
51c98236e4
commit
30a8ce6c69
@ -79,7 +79,10 @@ func MakeGraph(widget *Widget) {
|
|||||||
|
|
||||||
swapIndex := len(cpuStats) + 1
|
swapIndex := len(cpuStats) + 1
|
||||||
swapUsed := memInfo.SwapTotal - memInfo.SwapFree
|
swapUsed := memInfo.SwapTotal - memInfo.SwapFree
|
||||||
swapPercent := float64(swapUsed) / float64(memInfo.SwapTotal)
|
var swapPercent float64
|
||||||
|
if memInfo.SwapTotal > 0 {
|
||||||
|
swapPercent = float64(swapUsed) / float64(memInfo.SwapTotal)
|
||||||
|
}
|
||||||
|
|
||||||
usedSwapLabel := bytefmt.ByteSize(swapUsed)
|
usedSwapLabel := bytefmt.ByteSize(swapUsed)
|
||||||
totalSwapLabel := bytefmt.ByteSize(memInfo.SwapTotal)
|
totalSwapLabel := bytefmt.ByteSize(memInfo.SwapTotal)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user