fix: Cleanup and add sample.conf embedding (#12244)
This commit is contained in:
parent
c7a1d9e28e
commit
973db8c517
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package ethtool
|
package ethtool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
//go:generate ../../../tools/readme_config_includer/generator
|
|
||||||
//go:build linux
|
//go:build linux
|
||||||
|
|
||||||
package ethtool
|
package ethtool
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
# The libvirt plugin collects statistics from virtualized guests using virtualization libvirt API.
|
# The libvirt plugin collects statistics from virtualized guests using virtualization libvirt API.
|
||||||
[[inputs.libvirt]]
|
[[inputs.libvirt]]
|
||||||
## Domain names from which libvirt gather statistics.
|
## Domain names from which libvirt gather statistics.
|
||||||
|
|
@ -62,6 +62,7 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
## Supported additional statistics: vcpu_mapping
|
## Supported additional statistics: vcpu_mapping
|
||||||
## By default (empty or missing array) the plugin will not collect additional statistics.
|
## By default (empty or missing array) the plugin will not collect additional statistics.
|
||||||
# additional_statistics = []
|
# additional_statistics = []
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Useful links:
|
Useful links:
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package libvirt
|
package libvirt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
golibvirt "github.com/digitalocean/go-libvirt"
|
golibvirt "github.com/digitalocean/go-libvirt"
|
||||||
libvirtutils "github.com/thomasklein94/packer-plugin-libvirt/libvirt-utils"
|
libvirtutils "github.com/thomasklein94/packer-plugin-libvirt/libvirt-utils"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml @sample.conf
|
```toml @sample.conf
|
||||||
# Collects CPU metrics exposed on Linux
|
# Provides Linux CPU metrics
|
||||||
[[inputs.linux_cpu]]
|
[[inputs.linux_cpu]]
|
||||||
## Path for sysfs filesystem.
|
## Path for sysfs filesystem.
|
||||||
## See https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
|
## See https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
//go:build linux
|
//go:build linux
|
||||||
|
|
||||||
package linux_cpu
|
package linux_cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
``` toml
|
```toml @sample.conf
|
||||||
# Read TCP metrics such as established, time wait and sockets counts.
|
# Read TCP metrics such as established, time wait and sockets counts.
|
||||||
[[inputs.netstat]]
|
[[inputs.netstat]]
|
||||||
# no configuration
|
# no configuration
|
||||||
|
|
@ -69,3 +69,9 @@ Meta:
|
||||||
Measurement names:
|
Measurement names:
|
||||||
|
|
||||||
- udp_socket
|
- udp_socket
|
||||||
|
|
||||||
|
## Example Output
|
||||||
|
|
||||||
|
```text
|
||||||
|
netstat tcp_close=0i,tcp_close_wait=0i,tcp_closing=0i,tcp_established=14i,tcp_fin_wait1=0i,tcp_fin_wait2=0i,tcp_last_ack=0i,tcp_listen=1i,tcp_none=46i,tcp_syn_recv=0i,tcp_syn_sent=0i,tcp_time_wait=0i,udp_socket=10i 1668520568000000000
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package opcua_listener
|
package opcua_listener
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/common/opcua"
|
"github.com/influxdata/telegraf/plugins/common/opcua"
|
||||||
"github.com/influxdata/telegraf/plugins/common/opcua/input"
|
"github.com/influxdata/telegraf/plugins/common/opcua/input"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpcUaListener struct {
|
type OpcUaListener struct {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Retrieve data from OPCUA devices
|
# Retrieve data from OPCUA devices
|
||||||
[[inputs.opcua]]
|
[[inputs.opcua_listener]]
|
||||||
## Metric name
|
## Metric name
|
||||||
# name = "opcua"
|
# name = "opcua_listener"
|
||||||
#
|
#
|
||||||
## OPC UA Endpoint URL
|
## OPC UA Endpoint URL
|
||||||
# endpoint = "opc.tcp://localhost:4840"
|
# endpoint = "opc.tcp://localhost:4840"
|
||||||
|
|
@ -68,14 +68,14 @@
|
||||||
# ]
|
# ]
|
||||||
#
|
#
|
||||||
## Bracketed notation
|
## Bracketed notation
|
||||||
# [[inputs.opcua.nodes]]
|
# [[inputs.opcua_listener.nodes]]
|
||||||
# name = "node1"
|
# name = "node1"
|
||||||
# namespace = ""
|
# namespace = ""
|
||||||
# identifier_type = ""
|
# identifier_type = ""
|
||||||
# identifier = ""
|
# identifier = ""
|
||||||
# default_tags = { tag1 = "value1", tag2 = "value2" }
|
# default_tags = { tag1 = "value1", tag2 = "value2" }
|
||||||
#
|
#
|
||||||
# [[inputs.opcua.nodes]]
|
# [[inputs.opcua_listener.nodes]]
|
||||||
# name = "node2"
|
# name = "node2"
|
||||||
# namespace = ""
|
# namespace = ""
|
||||||
# identifier_type = ""
|
# identifier_type = ""
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
## * Default tags
|
## * Default tags
|
||||||
##
|
##
|
||||||
## Multiple node groups are allowed
|
## Multiple node groups are allowed
|
||||||
#[[inputs.opcua.group]]
|
#[[inputs.opcua_listener.group]]
|
||||||
## Group Metric name. Overrides the top level name. If unset, the
|
## Group Metric name. Overrides the top level name. If unset, the
|
||||||
## top level name is used.
|
## top level name is used.
|
||||||
# name =
|
# name =
|
||||||
|
|
@ -118,24 +118,24 @@
|
||||||
#]
|
#]
|
||||||
#
|
#
|
||||||
## Bracketed notation
|
## Bracketed notation
|
||||||
# [[inputs.opcua.group.nodes]]
|
# [[inputs.opcua_listener.group.nodes]]
|
||||||
# name = "node1"
|
# name = "node1"
|
||||||
# namespace = ""
|
# namespace = ""
|
||||||
# identifier_type = ""
|
# identifier_type = ""
|
||||||
# identifier = ""
|
# identifier = ""
|
||||||
# default_tags = { tag1 = "override1", tag2 = "value2" }
|
# default_tags = { tag1 = "override1", tag2 = "value2" }
|
||||||
#
|
#
|
||||||
# [[inputs.opcua.group.nodes]]
|
# [[inputs.opcua_listener.group.nodes]]
|
||||||
# name = "node2"
|
# name = "node2"
|
||||||
# namespace = ""
|
# namespace = ""
|
||||||
# identifier_type = ""
|
# identifier_type = ""
|
||||||
# identifier = ""
|
# identifier = ""
|
||||||
|
|
||||||
## Enable workarounds required by some devices to work correctly
|
## Enable workarounds required by some devices to work correctly
|
||||||
# [inputs.opcua.workarounds]
|
# [inputs.opcua_listener.workarounds]
|
||||||
## Set additional valid status codes, StatusOK (0x0) is always considered valid
|
## Set additional valid status codes, StatusOK (0x0) is always considered valid
|
||||||
# additional_valid_status_codes = ["0xC0"]
|
# additional_valid_status_codes = ["0xC0"]
|
||||||
|
|
||||||
# [inputs.opcua.request_workarounds]
|
# [inputs.opcua_listener.request_workarounds]
|
||||||
## Use unregistered reads instead of registered reads
|
## Use unregistered reads instead of registered reads
|
||||||
# use_unregistered_reads = false
|
# use_unregistered_reads = false
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package processes
|
package processes
|
||||||
|
|
||||||
import _ "embed"
|
import _ "embed"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
//go:generate ../../../tools/readme_config_includer/generator
|
|
||||||
//go:build !windows
|
//go:build !windows
|
||||||
|
|
||||||
package processes
|
package processes
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,9 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
[inputs.supervisor]
|
# Gathers information about processes that running under supervisor using XML-RPC API
|
||||||
|
[[inputs.supervisor]]
|
||||||
## Url of supervisor's XML-RPC endpoint if basic auth enabled in supervisor http server,
|
## Url of supervisor's XML-RPC endpoint if basic auth enabled in supervisor http server,
|
||||||
## than you have to add credentials to url (ex. http://login:pass@localhost:9001/RPC2)
|
## than you have to add credentials to url (ex. http://login:pass@localhost:9001/RPC2)
|
||||||
# url="http://localhost:9001/RPC2"
|
# url="http://localhost:9001/RPC2"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package supervisor
|
package supervisor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,18 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```toml
|
```toml @sample.conf
|
||||||
|
# Publishes metrics to a redis timeseries server
|
||||||
[[outputs.redistimeseries]]
|
[[outputs.redistimeseries]]
|
||||||
## The address of the RedisTimeSeries server.
|
## The address of the RedisTimeSeries server.
|
||||||
address = "127.0.0.1:6379"
|
address = "127.0.0.1:6379"
|
||||||
## password to login Redis
|
|
||||||
password = ""
|
|
||||||
|
|
||||||
## username (optional)
|
## Redis ACL credentials
|
||||||
# username = ""
|
# username = ""
|
||||||
# redis database number (optional, must be an integer)
|
# password = ""
|
||||||
# database = 0
|
# database = 0
|
||||||
|
|
||||||
## optional TLS configurations
|
## Optional TLS Config
|
||||||
# tls_ca = "/etc/telegraf/ca.pem"
|
# tls_ca = "/etc/telegraf/ca.pem"
|
||||||
# tls_cert = "/etc/telegraf/cert.pem"
|
# tls_cert = "/etc/telegraf/cert.pem"
|
||||||
# tls_key = "/etc/telegraf/key.pem"
|
# tls_key = "/etc/telegraf/key.pem"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//go:generate ../../../tools/readme_config_includer/generator
|
||||||
package redistimeseries
|
package redistimeseries
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
|
@ -10,21 +12,8 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sampleConfig = `
|
//go:embed sample.conf
|
||||||
## The address of the RedisTimeSeries server.
|
var sampleConfig string
|
||||||
address = "127.0.0.1:6379"
|
|
||||||
|
|
||||||
## Redis ACL credentials
|
|
||||||
# username = ""
|
|
||||||
# password = ""
|
|
||||||
# database = 0
|
|
||||||
|
|
||||||
## Optional TLS Config
|
|
||||||
# tls_ca = "/etc/telegraf/ca.pem"
|
|
||||||
# tls_cert = "/etc/telegraf/cert.pem"
|
|
||||||
# tls_key = "/etc/telegraf/key.pem"
|
|
||||||
# insecure_skip_verify = false
|
|
||||||
`
|
|
||||||
|
|
||||||
type RedisTimeSeries struct {
|
type RedisTimeSeries struct {
|
||||||
Address string `toml:"address"`
|
Address string `toml:"address"`
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Publishes metrics to a redis timeseries server
|
||||||
|
[[outputs.redistimeseries]]
|
||||||
|
## The address of the RedisTimeSeries server.
|
||||||
|
address = "127.0.0.1:6379"
|
||||||
|
|
||||||
|
## Redis ACL credentials
|
||||||
|
# username = ""
|
||||||
|
# password = ""
|
||||||
|
# database = 0
|
||||||
|
|
||||||
|
## Optional TLS Config
|
||||||
|
# tls_ca = "/etc/telegraf/ca.pem"
|
||||||
|
# tls_cert = "/etc/telegraf/cert.pem"
|
||||||
|
# tls_key = "/etc/telegraf/key.pem"
|
||||||
|
# insecure_skip_verify = false
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
plugin="${1}"
|
||||||
|
|
||||||
|
if [ ! -d "${plugin}" ]; then
|
||||||
|
echo "ERR: ${plugin} is not a directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pluginname=$(basename "${plugin}")
|
||||||
|
if [[ ":all:" =~ .*:${pluginname}:.* ]]; then
|
||||||
|
echo "INF: ${plugin} ignored"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the sample.conf file
|
||||||
|
if [ ! -f "${plugin}/sample.conf" ] && [ "${pluginname}" != "modbus" ]; then
|
||||||
|
echo "ERR: ${plugin} does not contain a sample.conf file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the sample.conf embedding into the README.md
|
||||||
|
readme="^\`\`\`toml @sample.*\.conf\b"
|
||||||
|
if ! grep -q "${readme}" "${plugin}/README.md" ; then
|
||||||
|
echo "ERR: ${plugin} is missing embedding in README"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the generator
|
||||||
|
generator="//go:generate ../../../tools/readme_config_includer/generator"
|
||||||
|
found=false
|
||||||
|
for filename in "${plugin}/"*.go; do
|
||||||
|
if [[ "${filename}" == *_test.go ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! grep -q "SampleConfig(" "${filename}"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "^${generator}\$" "${filename}"; then
|
||||||
|
found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! ${found}; then
|
||||||
|
echo "ERR: ${plugin} is missing generator statement!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the embedding
|
||||||
|
embedding="//go:embed sample.*\.conf"
|
||||||
|
found=false
|
||||||
|
for filename in "${plugin}/"*.go; do
|
||||||
|
if [[ "${filename}" == *_test.go ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! grep -q "SampleConfig(" "${filename}"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "^${embedding}\$" "${filename}"; then
|
||||||
|
found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! ${found}; then
|
||||||
|
echo "ERR: ${plugin} is missing embedding statement!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Loading…
Reference in New Issue