diff options
author | xginn8 <xginn8@users.noreply.github.com> | 2018-07-22 03:20:03 -0400 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-07-22 09:20:03 +0200 |
commit | 140b8b85c37553f5baebf433ac9be284cd1dd80d (patch) | |
tree | 6bb3e85356eb7ddd8d301a570cbd086454bf66a1 | |
parent | 2ae8c1c7a7c6a82b2c779aaf84a02899b0ada21b (diff) | |
download | prometheus_node_collector-140b8b85c37553f5baebf433ac9be284cd1dd80d.tar.bz2 prometheus_node_collector-140b8b85c37553f5baebf433ac9be284cd1dd80d.tar.xz prometheus_node_collector-140b8b85c37553f5baebf433ac9be284cd1dd80d.zip |
Filter out uninstalled systemd units when collecting all units (#1011)
fixes #567
Signed-off-by: Matthew McGinn <mamcgi@gmail.com>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | collector/systemd_linux.go | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cb808d..45f7e26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | **Breaking changes** | 3 | **Breaking changes** |
4 | 4 | ||
5 | * [CHANGE] | 5 | * [CHANGE] Filter out non-installed units when collecting all systemd units #1011 |
6 | * [FEATURE] Collect NRefused property for systemd socket units (available as of systemd v239) | 6 | * [FEATURE] Collect NRefused property for systemd socket units (available as of systemd v239) |
7 | * [FEATURE] Collect NRestarts property for systemd service units | 7 | * [FEATURE] Collect NRestarts property for systemd service units |
8 | * [FEATURE] Add socket unit stats to systemd collector #968 | 8 | * [FEATURE] Add socket unit stats to systemd collector #968 |
diff --git a/collector/systemd_linux.go b/collector/systemd_linux.go index 99a10de..6aee624 100644 --- a/collector/systemd_linux.go +++ b/collector/systemd_linux.go | |||
@@ -227,7 +227,9 @@ func (c *systemdCollector) getAllUnits() ([]unit, error) { | |||
227 | } | 227 | } |
228 | defer conn.Close() | 228 | defer conn.Close() |
229 | 229 | ||
230 | allUnits, err := conn.ListUnits() | 230 | // Filter out any units that are not installed and are pulled in only as dependencies. |
231 | allUnits, err := conn.ListUnitsFiltered([]string{"loaded"}) | ||
232 | |||
231 | if err != nil { | 233 | if err != nil { |
232 | return nil, err | 234 | return nil, err |
233 | } | 235 | } |