| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package ethtool |
| 4 | |
| 5 | import ( |
| 6 | "time" |
| 7 | |
| 8 | "github.com/netdata/netdata/go/plugins/logger" |
| 9 | "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/ndexec" |
| 10 | ) |
| 11 | |
| 12 | type ethtoolCli interface { |
| 13 | moduleEeprom(iface string) ([]byte, error) |
| 14 | } |
| 15 | |
| 16 | func newEthtoolExec(timeout time.Duration, logger *logger.Logger) *ethtoolCLIExec { |
| 17 | return ðtoolCLIExec{ |
| 18 | Logger: logger, |
| 19 | timeout: timeout, |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | type ethtoolCLIExec struct { |
| 24 | *logger.Logger |
| 25 | |
| 26 | timeout time.Duration |
| 27 | } |
| 28 | |
| 29 | func (e *ethtoolCLIExec) moduleEeprom(iface string) ([]byte, error) { |
| 30 | return ndexec.RunNDSudo(e.Logger, e.timeout, "ethtool-module-info", "--devname", iface) |
| 31 | } |