systemd_units: add --plain to command invocation (#7990) (#7991)

This commit is contained in:
Kevin R 2020-11-12 12:51:44 -08:00 committed by GitHub
parent e0938382b1
commit 97fb465c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
# systemd Units Input Plugin
The systemd_units plugin gathers systemd unit status on Linux. It relies on
`systemctl list-units --all --type=service` to collect data on service status.
`systemctl list-units --all --plain --type=service` to collect data on service status.
The results are tagged with the unit name and provide enumerated fields for
loaded, active and running fields, indicating the unit health.

View File

@ -198,13 +198,13 @@ func setSystemctl(Timeout internal.Duration, UnitType string) (*bytes.Buffer, er
return nil, err
}
cmd := exec.Command(systemctlPath, "list-units", "--all", fmt.Sprintf("--type=%s", UnitType), "--no-legend")
cmd := exec.Command(systemctlPath, "list-units", "--all", "--plain", fmt.Sprintf("--type=%s", UnitType), "--no-legend")
var out bytes.Buffer
cmd.Stdout = &out
err = internal.RunTimeout(cmd, Timeout.Duration)
if err != nil {
return &out, fmt.Errorf("error running systemctl list-units --all --type=%s --no-legend: %s", UnitType, err)
return &out, fmt.Errorf("error running systemctl list-units --all --plain --type=%s --no-legend: %s", UnitType, err)
}
return &out, nil