master
go 39 lines 824 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 //go:build linux
4
5 package ap
6
7 import (
8 "time"
9
10 "github.com/netdata/netdata/go/plugins/logger"
11 "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/ndexec"
12 )
13
14 type iwBinary interface {
15 devices() ([]byte, error)
16 stationStatistics(ifaceName string) ([]byte, error)
17 }
18
19 func newIwExec(binPath string, timeout time.Duration) *iwCliExec {
20 return &iwCliExec{
21 binPath: binPath,
22 timeout: timeout,
23 }
24 }
25
26 type iwCliExec struct {
27 *logger.Logger
28
29 binPath string
30 timeout time.Duration
31 }
32
33 func (e *iwCliExec) devices() ([]byte, error) {
34 return ndexec.RunUnprivileged(e.Logger, e.timeout, e.binPath, "dev")
35 }
36
37 func (e *iwCliExec) stationStatistics(ifaceName string) ([]byte, error) {
38 return ndexec.RunUnprivileged(e.Logger, e.timeout, e.binPath, ifaceName, "station", "dump")
39 }