|
|
@ -76,17 +76,31 @@ func loadDiskIO() { |
|
|
|
if io2.Name == io1.Name { |
|
|
|
if io2.Name == io1.Name { |
|
|
|
var itemIO model.MonitorIO |
|
|
|
var itemIO model.MonitorIO |
|
|
|
itemIO.Name = io1.Name |
|
|
|
itemIO.Name = io1.Name |
|
|
|
|
|
|
|
if io2.ReadBytes != 0 && io1.ReadBytes != 0 { |
|
|
|
itemIO.Read = uint64(float64(io2.ReadBytes-io1.ReadBytes) / 60) |
|
|
|
itemIO.Read = uint64(float64(io2.ReadBytes-io1.ReadBytes) / 60) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if io2.WriteBytes != 0 && io1.WriteBytes != 0 { |
|
|
|
itemIO.Write = uint64(float64(io2.WriteBytes-io1.WriteBytes) / 60) |
|
|
|
itemIO.Write = uint64(float64(io2.WriteBytes-io1.WriteBytes) / 60) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if io2.ReadCount != 0 && io1.ReadCount != 0 { |
|
|
|
itemIO.Count = uint64(float64(io2.ReadCount-io1.ReadCount) / 60) |
|
|
|
itemIO.Count = uint64(float64(io2.ReadCount-io1.ReadCount) / 60) |
|
|
|
writeCount := uint64(float64(io2.WriteCount-io1.WriteCount) / 60) |
|
|
|
} |
|
|
|
|
|
|
|
writeCount := uint64(0) |
|
|
|
|
|
|
|
if io2.WriteCount != 0 && io1.WriteCount != 0 { |
|
|
|
|
|
|
|
writeCount = uint64(float64(io2.WriteCount-io1.WriteCount) / 60) |
|
|
|
|
|
|
|
} |
|
|
|
if writeCount > itemIO.Count { |
|
|
|
if writeCount > itemIO.Count { |
|
|
|
itemIO.Count = writeCount |
|
|
|
itemIO.Count = writeCount |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if io2.ReadTime != 0 && io1.ReadTime != 0 { |
|
|
|
itemIO.Time = uint64(float64(io2.ReadTime-io1.ReadTime) / 60) |
|
|
|
itemIO.Time = uint64(float64(io2.ReadTime-io1.ReadTime) / 60) |
|
|
|
writeTime := uint64(float64(io2.WriteTime-io1.WriteTime) / 60) |
|
|
|
} |
|
|
|
|
|
|
|
writeTime := uint64(0) |
|
|
|
|
|
|
|
if io2.WriteTime != 0 && io1.WriteTime != 0 { |
|
|
|
|
|
|
|
writeTime = uint64(float64(io2.WriteTime-io1.WriteTime) / 60) |
|
|
|
|
|
|
|
} |
|
|
|
if writeTime > itemIO.Time { |
|
|
|
if writeTime > itemIO.Time { |
|
|
|
itemIO.Time = writeTime |
|
|
|
itemIO.Time = writeTime |
|
|
|
} |
|
|
|
} |
|
|
@ -113,8 +127,13 @@ func loadNetIO() { |
|
|
|
if net2.Name == net1.Name { |
|
|
|
if net2.Name == net1.Name { |
|
|
|
var itemNet model.MonitorNetwork |
|
|
|
var itemNet model.MonitorNetwork |
|
|
|
itemNet.Name = net1.Name |
|
|
|
itemNet.Name = net1.Name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if net2.BytesSent != 0 && net1.BytesSent != 0 { |
|
|
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60 |
|
|
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if net2.BytesRecv != 0 && net1.BytesRecv != 0 { |
|
|
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60 |
|
|
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60 |
|
|
|
|
|
|
|
} |
|
|
|
netList = append(netList, itemNet) |
|
|
|
netList = append(netList, itemNet) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
@ -123,14 +142,16 @@ func loadNetIO() { |
|
|
|
netStatAll2, _ := net.IOCounters(false) |
|
|
|
netStatAll2, _ := net.IOCounters(false) |
|
|
|
for _, net2 := range netStatAll2 { |
|
|
|
for _, net2 := range netStatAll2 { |
|
|
|
for _, net1 := range netStatAll { |
|
|
|
for _, net1 := range netStatAll { |
|
|
|
if net1.BytesSent == 0 || net1.BytesRecv == 0 { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if net2.Name == net1.Name { |
|
|
|
if net2.Name == net1.Name { |
|
|
|
var itemNet model.MonitorNetwork |
|
|
|
var itemNet model.MonitorNetwork |
|
|
|
itemNet.Name = net1.Name |
|
|
|
itemNet.Name = net1.Name |
|
|
|
|
|
|
|
if net2.BytesSent != 0 && net1.BytesSent != 0 { |
|
|
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60 |
|
|
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if net2.BytesRecv != 0 && net1.BytesRecv != 0 { |
|
|
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60 |
|
|
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60 |
|
|
|
|
|
|
|
} |
|
|
|
netList = append(netList, itemNet) |
|
|
|
netList = append(netList, itemNet) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|