Skip to content

Commit

Permalink
systemd_units: add --plain to command invocation (#7990) (#7991)
Browse files Browse the repository at this point in the history
(cherry picked from commit 97fb465)
  • Loading branch information
squidpickles authored and ssoroka committed Nov 13, 2020
1 parent ecc3307 commit 5046a61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/systemd_units/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/systemd_units/systemd_units_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5046a61

Please sign in to comment.