2022-05-24 21:49:47 +08:00
|
|
|
//go:generate ../../../tools/readme_config_includer/generator
|
2019-12-03 08:05:50 +08:00
|
|
|
package systemd_units
|
|
|
|
|
|
|
|
|
|
import (
|
2022-05-24 21:49:47 +08:00
|
|
|
_ "embed"
|
2019-12-03 08:05:50 +08:00
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/influxdata/telegraf"
|
2021-04-10 01:15:04 +08:00
|
|
|
"github.com/influxdata/telegraf/config"
|
2019-12-03 08:05:50 +08:00
|
|
|
"github.com/influxdata/telegraf/plugins/inputs"
|
|
|
|
|
)
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
//go:embed sample.conf
|
|
|
|
|
var sampleConfig string
|
|
|
|
|
|
2024-01-17 21:56:12 +08:00
|
|
|
// SystemdUnits is a telegraf plugin to gather systemd unit status
|
|
|
|
|
type SystemdUnits struct {
|
2024-04-13 04:19:23 +08:00
|
|
|
Pattern string `toml:"pattern"`
|
|
|
|
|
UnitType string `toml:"unittype"`
|
2024-06-25 21:51:51 +08:00
|
|
|
Scope string `toml:"scope"`
|
2024-04-13 04:19:23 +08:00
|
|
|
Details bool `toml:"details"`
|
|
|
|
|
CollectDisabled bool `toml:"collect_disabled_units"`
|
|
|
|
|
Timeout config.Duration `toml:"timeout"`
|
|
|
|
|
Log telegraf.Logger `toml:"-"`
|
2024-03-05 23:34:36 +08:00
|
|
|
archParams
|
2024-01-17 21:56:12 +08:00
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
func (*SystemdUnits) SampleConfig() string {
|
|
|
|
|
return sampleConfig
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-03 08:05:50 +08:00
|
|
|
func init() {
|
|
|
|
|
inputs.Add("systemd_units", func() telegraf.Input {
|
2024-03-14 23:19:27 +08:00
|
|
|
return &SystemdUnits{Timeout: config.Duration(5 * time.Second)}
|
2019-12-03 08:05:50 +08:00
|
|
|
})
|
|
|
|
|
}
|