From 97fb465c2dd9d6ddf413182dad0137a661a470d3 Mon Sep 17 00:00:00 2001 From: Kevin R Date: Thu, 12 Nov 2020 12:51:44 -0800 Subject: [PATCH] systemd_units: add --plain to command invocation (#7990) (#7991) --- plugins/inputs/systemd_units/README.md | 2 +- plugins/inputs/systemd_units/systemd_units_linux.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/systemd_units/README.md b/plugins/inputs/systemd_units/README.md index fc8306dee..7fe09e224 100644 --- a/plugins/inputs/systemd_units/README.md +++ b/plugins/inputs/systemd_units/README.md @@ -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. diff --git a/plugins/inputs/systemd_units/systemd_units_linux.go b/plugins/inputs/systemd_units/systemd_units_linux.go index 64caf03d0..8df21efa6 100644 --- a/plugins/inputs/systemd_units/systemd_units_linux.go +++ b/plugins/inputs/systemd_units/systemd_units_linux.go @@ -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