Skip to content

Commit 3c71098

Browse files
Add AIX netdev collector
Signed-off-by: Johannes Ziemke <[email protected]>
1 parent 0a2a54f commit 3c71098

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

collector/netdev_aix.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2024 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
//go:build !nonetdev
15+
// +build !nonetdev
16+
17+
package collector
18+
19+
import (
20+
"log/slog"
21+
22+
"github.com/power-devops/perfstat"
23+
)
24+
25+
func getNetDevStats(filter *deviceFilter, logger *slog.Logger) (netDevStats, error) {
26+
netDev := netDevStats{}
27+
28+
stats, err := perfstat.NetAdapterStat()
29+
if err != nil {
30+
return nil, err
31+
}
32+
33+
for _, stat := range stats {
34+
netDev[stat.Name] = map[string]uint64{
35+
"receive_packets": uint64(stat.RxPackets),
36+
"transmit_packets": uint64(stat.TxPackets),
37+
"receive_bytes": uint64(stat.RxBytes),
38+
"transmit_bytes": uint64(stat.TxBytes),
39+
"receive_errors": uint64(stat.RxErrors),
40+
"transmit_errors": uint64(stat.TxErrors),
41+
"receive_dropped": uint64(stat.RxPacketsDropped),
42+
"transmit_dropped": uint64(stat.TxPacketsDropped),
43+
"receive_multicast": uint64(stat.RxMulticastPackets),
44+
"transmit_multicast": uint64(stat.TxMulticastPackets),
45+
}
46+
}
47+
48+
return netDev, nil
49+
}
50+
51+
func getNetDevLabels() (map[string]map[string]string, error) {
52+
// to be implemented if needed
53+
return nil, nil
54+
}

collector/netdev_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nonetdev && (linux || freebsd || openbsd || dragonfly || darwin)
14+
//go:build !nonetdev && (linux || freebsd || openbsd || dragonfly || darwin || aix)
1515
// +build !nonetdev
16-
// +build linux freebsd openbsd dragonfly darwin
16+
// +build linux freebsd openbsd dragonfly darwin aix
1717

1818
package collector
1919

0 commit comments

Comments
 (0)