fix(inputs.procstat): Revert unintended renaming of 'systemd_unit' option (#14440)
This commit is contained in:
parent
db204fd915
commit
d2329621dc
|
|
@ -37,7 +37,7 @@ type Procstat struct {
|
||||||
CmdLineTag bool `toml:"cmdline_tag" deprecated:"1.29.0;use 'tag_with' instead"`
|
CmdLineTag bool `toml:"cmdline_tag" deprecated:"1.29.0;use 'tag_with' instead"`
|
||||||
ProcessName string `toml:"process_name"`
|
ProcessName string `toml:"process_name"`
|
||||||
User string `toml:"user"`
|
User string `toml:"user"`
|
||||||
SystemdUnits string `toml:"systemd_units"`
|
SystemdUnit string `toml:"systemd_unit"`
|
||||||
SupervisorUnit []string `toml:"supervisor_unit" deprecated:"1.29.0;use 'supervisor_units' instead"`
|
SupervisorUnit []string `toml:"supervisor_unit" deprecated:"1.29.0;use 'supervisor_units' instead"`
|
||||||
SupervisorUnits []string `toml:"supervisor_units"`
|
SupervisorUnits []string `toml:"supervisor_units"`
|
||||||
IncludeSystemdChildren bool `toml:"include_systemd_children"`
|
IncludeSystemdChildren bool `toml:"include_systemd_children"`
|
||||||
|
|
@ -95,7 +95,7 @@ func (p *Procstat) Init() error {
|
||||||
|
|
||||||
// Check filtering
|
// Check filtering
|
||||||
switch {
|
switch {
|
||||||
case len(p.SupervisorUnits) > 0, p.SystemdUnits != "", p.WinService != "",
|
case len(p.SupervisorUnits) > 0, p.SystemdUnit != "", p.WinService != "",
|
||||||
p.CGroup != "", p.PidFile != "", p.Exe != "", p.Pattern != "",
|
p.CGroup != "", p.PidFile != "", p.Exe != "", p.Pattern != "",
|
||||||
p.User != "":
|
p.User != "":
|
||||||
// Do nothing as those are valid settings
|
// Do nothing as those are valid settings
|
||||||
|
|
@ -221,7 +221,7 @@ func (p *Procstat) findPids() ([]PidsTags, error) {
|
||||||
switch {
|
switch {
|
||||||
case len(p.SupervisorUnits) > 0:
|
case len(p.SupervisorUnits) > 0:
|
||||||
return p.findSupervisorUnits()
|
return p.findSupervisorUnits()
|
||||||
case p.SystemdUnits != "":
|
case p.SystemdUnit != "":
|
||||||
return p.systemdUnitPIDs()
|
return p.systemdUnitPIDs()
|
||||||
case p.WinService != "":
|
case p.WinService != "":
|
||||||
pids, err := p.winServicePIDs()
|
pids, err := p.winServicePIDs()
|
||||||
|
|
@ -356,7 +356,7 @@ func (p *Procstat) supervisorPIDs() ([]string, map[string]map[string]string, err
|
||||||
|
|
||||||
func (p *Procstat) systemdUnitPIDs() ([]PidsTags, error) {
|
func (p *Procstat) systemdUnitPIDs() ([]PidsTags, error) {
|
||||||
if p.IncludeSystemdChildren {
|
if p.IncludeSystemdChildren {
|
||||||
p.CGroup = fmt.Sprintf("systemd/system.slice/%s", p.SystemdUnits)
|
p.CGroup = fmt.Sprintf("systemd/system.slice/%s", p.SystemdUnit)
|
||||||
return p.cgroupPIDs()
|
return p.cgroupPIDs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -365,13 +365,13 @@ func (p *Procstat) systemdUnitPIDs() ([]PidsTags, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tags := map[string]string{"systemd_unit": p.SystemdUnits}
|
tags := map[string]string{"systemd_unit": p.SystemdUnit}
|
||||||
pidTags = append(pidTags, PidsTags{pids, tags})
|
pidTags = append(pidTags, PidsTags{pids, tags})
|
||||||
return pidTags, nil
|
return pidTags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Procstat) simpleSystemdUnitPIDs() ([]PID, error) {
|
func (p *Procstat) simpleSystemdUnitPIDs() ([]PID, error) {
|
||||||
out, err := execCommand("systemctl", "show", p.SystemdUnits).Output()
|
out, err := execCommand("systemctl", "show", p.SystemdUnit).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -460,10 +460,10 @@ func TestGather_PercentSecondPass(t *testing.T) {
|
||||||
|
|
||||||
func TestGather_systemdUnitPIDs(t *testing.T) {
|
func TestGather_systemdUnitPIDs(t *testing.T) {
|
||||||
p := Procstat{
|
p := Procstat{
|
||||||
SystemdUnits: "TestGather_systemdUnitPIDs",
|
SystemdUnit: "TestGather_systemdUnitPIDs",
|
||||||
PidFinder: "test",
|
PidFinder: "test",
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
finder: newTestFinder([]PID{pid}),
|
finder: newTestFinder([]PID{pid}),
|
||||||
}
|
}
|
||||||
require.NoError(t, p.Init())
|
require.NoError(t, p.Init())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue