summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/systemdunits/client.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/client.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/client.go b/src/go/collectors/go.d.plugin/modules/systemdunits/client.go
new file mode 100644
index 000000000..a2787c4ec
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/client.go
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+//go:build linux
+// +build linux
+
+package systemdunits
+
+import (
+ "context"
+
+ "github.com/coreos/go-systemd/v22/dbus"
+)
+
+type systemdClient interface {
+ connect() (systemdConnection, error)
+}
+type systemdConnection interface {
+ Close()
+ GetManagerProperty(string) (string, error)
+ ListUnitsContext(ctx context.Context) ([]dbus.UnitStatus, error)
+ ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error)
+}
+
+type systemdDBusClient struct{}
+
+func (systemdDBusClient) connect() (systemdConnection, error) {
+ return dbus.NewWithContext(context.Background())
+}
+
+func newSystemdDBusClient() *systemdDBusClient {
+ return &systemdDBusClient{}
+}