telegraf/plugins/inputs/ethtool/ethtool.go

54 lines
1.1 KiB
Go
Raw Normal View History

2019-11-09 03:55:37 +08:00
package ethtool
import (
_ "embed"
2019-11-09 03:55:37 +08:00
"net"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter"
2019-11-09 03:55:37 +08:00
)
//go:embed sample.conf
var sampleConfig string
var downInterfacesBehaviors = []string{"expose", "skip"}
2019-11-09 03:55:37 +08:00
type Command interface {
Init() error
DriverName(intf string) (string, error)
Interfaces() ([]net.Interface, error)
Stats(intf string) (map[string]uint64, error)
}
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"`
// Behavior regarding metrics for downed interfaces
DownInterfaces string `toml:" down_interfaces"`
// Normalization on the key names
NormalizeKeys []string `toml:"normalize_keys"`
Log telegraf.Logger `toml:"-"`
interfaceFilter filter.Filter
2019-11-09 03:55:37 +08:00
// the ethtool command
command Command
}
func (*Ethtool) SampleConfig() string {
return sampleConfig
}
2019-11-09 03:55:37 +08:00
const (
pluginName = "ethtool"
tagInterface = "interface"
tagDriverName = "driver"
fieldInterfaceUp = "interface_up"
2019-11-09 03:55:37 +08:00
)