fix: Convert slab plugin to new sample.conf. (#11181)

This commit is contained in:
Sven Rebhan 2022-05-24 17:55:36 +02:00 committed by GitHub
parent 59a7f76117
commit 15fd1133c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 12 deletions

View File

@ -13,7 +13,7 @@ If the HOST_PROC environment variable is set, Telegraf will use its value instea
## Configuration
```toml
```toml @sample.conf
# Get slab statistics from procfs
[[inputs.slab]]
# no configuration - please see the plugin's README for steps to configure

View File

@ -0,0 +1,4 @@
# Get slab statistics from procfs
[[inputs.slab]]
# no configuration - please see the plugin's README for steps to configure
# sudo properly

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
//go:build linux
// +build linux
@ -6,6 +7,7 @@ package slab
import (
"bufio"
"bytes"
_ "embed"
"errors"
"fmt"
"os"
@ -20,6 +22,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type SlabStats struct {
Log telegraf.Logger `toml:"-"`
@ -27,6 +33,10 @@ type SlabStats struct {
useSudo bool
}
func (*SlabStats) SampleConfig() string {
return sampleConfig
}
func (ss *SlabStats) Init() error {
return nil
}

View File

@ -1,11 +0,0 @@
//go:build linux
// +build linux
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package slab
func (ss *SlabStats) SampleConfig() string {
return `{{ .SampleConfig }}`
}