forked from shirou/gopsutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
net_aix_cgo.go
36 lines (31 loc) · 841 Bytes
/
net_aix_cgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: BSD-3-Clause
//go:build aix && cgo
package net
import (
"context"
"github.com/power-devops/perfstat"
)
func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
ifs, err := perfstat.NetIfaceStat()
if err != nil {
return nil, err
}
iocounters := make([]IOCountersStat, 0, len(ifs))
for _, netif := range ifs {
n := IOCountersStat{
Name: netif.Name,
BytesSent: uint64(netif.OBytes),
BytesRecv: uint64(netif.IBytes),
PacketsSent: uint64(netif.OPackets),
PacketsRecv: uint64(netif.IPackets),
Errin: uint64(netif.OErrors),
Errout: uint64(netif.IErrors),
Dropout: uint64(netif.XmitDrops),
}
iocounters = append(iocounters, n)
}
if pernic == false {
return getIOCountersAll(iocounters)
}
return iocounters, nil
}