1
0
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:
Nicholas Eden 2018-11-25 12:06:02 -08:00
parent 51c98236e4
commit 30a8ce6c69

View File

@ -79,7 +79,10 @@ func MakeGraph(widget *Widget) {
swapIndex := len(cpuStats) + 1
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)
totalSwapLabel := bytefmt.ByteSize(memInfo.SwapTotal)