summaryrefslogtreecommitdiff
path: root/vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go
blob: f7da4ce1399d50450615f3fbfa7be8c0935451a6 (plain)
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 {
		return getIOCountersAll(iocounters), nil
	}
	return iocounters, nil
}