2022-11-16 00:15:35 +08:00
|
|
|
//go:generate ../../../tools/readme_config_includer/generator
|
2019-11-09 03:55:37 +08:00
|
|
|
package ethtool
|
|
|
|
|
|
|
|
|
|
import (
|
2022-05-24 21:49:47 +08:00
|
|
|
_ "embed"
|
2020-01-03 08:15:48 +08:00
|
|
|
|
|
|
|
|
"github.com/influxdata/telegraf"
|
2022-10-25 19:02:41 +08:00
|
|
|
"github.com/influxdata/telegraf/filter"
|
2019-11-09 03:55:37 +08:00
|
|
|
)
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
//go:embed sample.conf
|
|
|
|
|
var sampleConfig string
|
|
|
|
|
|
2022-10-25 19:02:41 +08:00
|
|
|
var downInterfacesBehaviors = []string{"expose", "skip"}
|
|
|
|
|
|
2019-11-09 03:55:37 +08:00
|
|
|
type Command interface {
|
|
|
|
|
Init() error
|
2022-11-15 23:54:58 +08:00
|
|
|
DriverName(intf NamespacedInterface) (string, error)
|
|
|
|
|
Interfaces(includeNamespaces bool) ([]NamespacedInterface, error)
|
|
|
|
|
Stats(intf NamespacedInterface) (map[string]uint64, error)
|
2019-11-09 03:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Ethtool struct {
|
|
|
|
|
// This is the list of interface names to include
|
|
|
|
|
InterfaceInclude []string `toml:"interface_include"`
|
|
|
|
|
|
|
|
|
|
// This is the list of interface names to ignore
|
|
|
|
|
InterfaceExclude []string `toml:"interface_exclude"`
|
|
|
|
|
|
2022-10-25 19:02:41 +08:00
|
|
|
// Behavior regarding metrics for downed interfaces
|
|
|
|
|
DownInterfaces string `toml:" down_interfaces"`
|
|
|
|
|
|
2022-11-15 23:54:58 +08:00
|
|
|
// This is the list of namespace names to include
|
|
|
|
|
NamespaceInclude []string `toml:"namespace_include"`
|
|
|
|
|
|
|
|
|
|
// This is the list of namespace names to ignore
|
|
|
|
|
NamespaceExclude []string `toml:"namespace_exclude"`
|
|
|
|
|
|
2021-10-20 04:44:36 +08:00
|
|
|
// Normalization on the key names
|
|
|
|
|
NormalizeKeys []string `toml:"normalize_keys"`
|
|
|
|
|
|
2020-01-03 08:15:48 +08:00
|
|
|
Log telegraf.Logger `toml:"-"`
|
|
|
|
|
|
2022-11-15 23:54:58 +08:00
|
|
|
interfaceFilter filter.Filter
|
|
|
|
|
namespaceFilter filter.Filter
|
|
|
|
|
includeNamespaces bool
|
2022-10-25 19:02:41 +08:00
|
|
|
|
2019-11-09 03:55:37 +08:00
|
|
|
// the ethtool command
|
|
|
|
|
command Command
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
func (*Ethtool) SampleConfig() string {
|
|
|
|
|
return sampleConfig
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 03:55:37 +08:00
|
|
|
const (
|
2020-12-19 01:04:02 +08:00
|
|
|
pluginName = "ethtool"
|
|
|
|
|
tagInterface = "interface"
|
2022-11-15 23:54:58 +08:00
|
|
|
tagNamespace = "namespace"
|
2020-12-19 01:04:02 +08:00
|
|
|
tagDriverName = "driver"
|
|
|
|
|
fieldInterfaceUp = "interface_up"
|
2019-11-09 03:55:37 +08:00
|
|
|
)
|