Output channel utilization as percentage

This commit is contained in:
Julian Kornberger 2016-07-14 12:31:11 +02:00
parent 92aac7b7ca
commit c30d6bc281
2 changed files with 8 additions and 8 deletions

View File

@ -44,8 +44,8 @@ func (cur *WirelessAirtime) SetUtilization(prev *WirelessAirtime) {
// Calculate utilizations
if active > 0 {
cur.ChanUtil = (busy + rx + tx) / active
cur.RxUtil = rx / active
cur.TxUtil = tx / active
cur.ChanUtil = 100 * (busy + rx + tx) / active
cur.RxUtil = 100 * rx / active
cur.TxUtil = 100 * tx / active
}
}

View File

@ -35,12 +35,12 @@ func TestUtilization(t *testing.T) {
t2.SetUtilization(t1)
assert.NotZero(t2.ChanUtil)
assert.EqualValues(0.45, t2.ChanUtil)
assert.EqualValues(0.2, t2.RxUtil)
assert.EqualValues(0.15, t2.TxUtil)
assert.EqualValues(45, t2.ChanUtil)
assert.EqualValues(20, t2.RxUtil)
assert.EqualValues(15, t2.TxUtil)
t3.SetUtilization(t2)
assert.EqualValues(0.5, t3.ChanUtil)
assert.EqualValues(0.125, t3.RxUtil)
assert.EqualValues(50, t3.ChanUtil)
assert.EqualValues(12.5, t3.RxUtil)
assert.EqualValues(0, t3.TxUtil)
}