diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/systemdunits/client.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/systemdunits/client.go | 34 |
1 files changed, 34 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..e6363d132 --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/systemdunits/client.go @@ -0,0 +1,34 @@ +// 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) + GetUnitPropertyContext(ctx context.Context, unit string, propertyName string) (*dbus.Property, error) + ListUnitsContext(ctx context.Context) ([]dbus.UnitStatus, error) + ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error) + ListUnitFilesByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitFile, error) +} + +type systemdDBusClient struct{} + +func (systemdDBusClient) connect() (systemdConnection, error) { + return dbus.NewWithContext(context.Background()) +} + +func newSystemdDBusClient() *systemdDBusClient { + return &systemdDBusClient{} +} |