2019-11-21 19:26:59 +00:00
|
|
|
package synproxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"github.com/influxdata/telegraf"
|
|
|
|
"github.com/influxdata/telegraf/plugins/inputs"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Synproxy struct {
|
2020-01-03 00:15:48 +00:00
|
|
|
Log telegraf.Logger `toml:"-"`
|
|
|
|
|
2019-11-21 19:26:59 +00:00
|
|
|
// Synproxy stats filename (proc filesystem)
|
|
|
|
statFile string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *Synproxy) Description() string {
|
|
|
|
return "Get synproxy counter statistics from procfs"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *Synproxy) SampleConfig() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func getHostProc() string {
|
|
|
|
procPath := "/proc"
|
|
|
|
if os.Getenv("HOST_PROC") != "" {
|
|
|
|
procPath = os.Getenv("HOST_PROC")
|
|
|
|
}
|
|
|
|
return procPath
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
inputs.Add("synproxy", func() telegraf.Input {
|
|
|
|
return &Synproxy{
|
|
|
|
statFile: path.Join(getHostProc(), "/net/stat/synproxy"),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|