summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/systemdunits
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2024-02-13 06:56:20 -0500
committerGitHub <noreply@github.com>2024-02-13 06:56:20 -0500
commit3a29b66132f561c910d827e8c7ae82997f7c1f30 (patch)
treea9306156631b6b188de8877f7c1dbdbe8b067804 /src/go/collectors/go.d.plugin/modules/systemdunits
parent57eec3da0e51baa400037ccc4b547cb839ab6ffa (diff)
Include Go plugin sources in main repository. (#16997)
* Include Go plugin sources in main repository. * Fix CI issues. * Rename source tree.
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/systemdunits')
l---------src/go/collectors/go.d.plugin/modules/systemdunits/README.md1
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/charts.go76
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/client.go32
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/collect.go211
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/config_schema.json27
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/doc.go4
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/init.go29
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/integrations/systemd_units.md253
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/metadata.yaml290
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/systemdunits.go105
-rw-r--r--src/go/collectors/go.d.plugin/modules/systemdunits/systemdunits_test.go891
11 files changed, 1919 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/README.md b/src/go/collectors/go.d.plugin/modules/systemdunits/README.md
new file mode 120000
index 0000000000..68dd433bf2
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/README.md
@@ -0,0 +1 @@
+integrations/systemd_units.md \ No newline at end of file
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/charts.go b/src/go/collectors/go.d.plugin/modules/systemdunits/charts.go
new file mode 100644
index 0000000000..23a1bf75e7
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/charts.go
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+//go:build linux
+// +build linux
+
+package systemdunits
+
+import (
+ "fmt"
+
+ "github.com/netdata/go.d.plugin/agent/module"
+
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
+)
+
+const (
+ prioServiceUnitState = module.Priority + iota
+ prioSocketUnitState
+ prioTargetUnitState
+ prioPathUnitState
+ prioDeviceUnitState
+ prioMountUnitState
+ prioAutomountUnitState
+ prioSwapUnitState
+ prioTimerUnitState
+ prioScopeUnitState
+ prioSliceUnitState
+)
+
+var prioMap = map[string]int{
+ unitTypeService: prioServiceUnitState,
+ unitTypeSocket: prioSocketUnitState,
+ unitTypeTarget: prioTargetUnitState,
+ unitTypePath: prioPathUnitState,
+ unitTypeDevice: prioDeviceUnitState,
+ unitTypeMount: prioMountUnitState,
+ unitTypeAutomount: prioAutomountUnitState,
+ unitTypeSwap: prioSwapUnitState,
+ unitTypeTimer: prioTimerUnitState,
+ unitTypeScope: prioScopeUnitState,
+ unitTypeSlice: prioSliceUnitState,
+}
+
+func newTypedUnitStateChartTmpl(name, typ string) *module.Chart {
+ chart := module.Chart{
+ ID: fmt.Sprintf("unit_%s_%s_state", name, typ),
+ Title: fmt.Sprintf("%s Unit State", cases.Title(language.English, cases.Compact).String(typ)),
+ Units: "state",
+ Fam: fmt.Sprintf("%s units", typ),
+ Ctx: fmt.Sprintf("systemd.%s_unit_state", typ),
+ Priority: prioMap[typ],
+ Labels: []module.Label{
+ {Key: "unit_name", Value: name},
+ },
+ Dims: module.Dims{
+ {Name: unitStateActive},
+ {Name: unitStateInactive},
+ {Name: unitStateActivating},
+ {Name: unitStateDeactivating},
+ {Name: unitStateFailed},
+ },
+ }
+ for _, d := range chart.Dims {
+ d.ID = fmt.Sprintf("unit_%s_%s_state_%s", name, typ, d.Name)
+ }
+ return &chart
+}
+
+func (s *SystemdUnits) addUnitToCharts(name, typ string) {
+ chart := newTypedUnitStateChartTmpl(name, typ)
+
+ if err := s.Charts().Add(chart); err != nil {
+ s.Warning(err)
+ }
+}
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 0000000000..a2787c4ec1
--- /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{}
+}
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go b/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go
new file mode 100644
index 0000000000..2843a42302
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go
@@ -0,0 +1,211 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+//go:build linux
+// +build linux
+
+package systemdunits
+
+import (
+ "context"
+ "fmt"
+ "regexp"
+ "strconv"
+ "strings"
+
+ "github.com/coreos/go-systemd/v22/dbus"
+)
+
+const (
+ // https://www.freedesktop.org/software/systemd/man/systemd.html
+ unitStateActive = "active"
+ unitStateInactive = "inactive"
+ unitStateActivating = "activating"
+ unitStateDeactivating = "deactivating"
+ unitStateFailed = "failed"
+
+ // https://www.freedesktop.org/software/systemd/man/systemd.html
+ unitTypeService = "service"
+ unitTypeSocket = "socket"
+ unitTypeTarget = "target"
+ unitTypePath = "path"
+ unitTypeDevice = "device"
+ unitTypeMount = "mount"
+ unitTypeAutomount = "automount"
+ unitTypeSwap = "swap"
+ unitTypeTimer = "timer"
+ unitTypeScope = "scope"
+ unitTypeSlice = "slice"
+)
+
+var (
+ unitStates = []string{
+ unitStateActive,
+ unitStateActivating,
+ unitStateFailed,
+ unitStateInactive,
+ unitStateDeactivating,
+ }
+)
+
+func (s *SystemdUnits) collect() (map[string]int64, error) {
+ conn, err := s.getConnection()
+ if err != nil {
+ return nil, err
+ }
+
+ if s.systemdVersion == 0 {
+ ver, err := s.getSystemdVersion(conn)
+ if err != nil {
+ s.closeConnection()
+ return nil, err
+ }
+ s.systemdVersion = ver
+ }
+
+ var units []dbus.UnitStatus
+ if s.systemdVersion >= 230 {
+ // https://github.com/systemd/systemd/pull/3142
+ units, err = s.getLoadedUnitsByPatterns(conn)
+ } else {
+ units, err = s.getLoadedUnits(conn)
+ }
+ if err != nil {
+ s.closeConnection()
+ return nil, err
+ }
+
+ if len(units) == 0 {
+ return nil, nil
+ }
+
+ mx := make(map[string]int64)
+ s.collectUnitsStates(mx, units)
+
+ return mx, nil
+}
+
+func (s *SystemdUnits) collectUnitsStates(mx map[string]int64, units []dbus.UnitStatus) {
+ for _, unit := range units {
+ name, typ := extractUnitNameType(cleanUnitName(unit.Name))
+ if name == "" || typ == "" {
+ continue
+ }
+
+ if !s.units[unit.Name] {
+ s.units[unit.Name] = true
+ s.addUnitToCharts(name, typ)
+ }
+
+ for _, s := range unitStates {
+ mx[fmt.Sprintf("unit_%s_%s_state_%s", name, typ, s)] = 0
+ }
+ mx[fmt.Sprintf("unit_%s_%s_state_%s", name, typ, unit.ActiveState)] = 1
+ }
+}
+
+func (s *SystemdUnits) getConnection() (systemdConnection, error) {
+ if s.conn == nil {
+ conn, err := s.client.connect()
+ if err != nil {
+ return nil, fmt.Errorf("error on creating a connection: %v", err)
+ }
+ s.conn = conn
+ }
+ return s.conn, nil
+}
+
+func (s *SystemdUnits) closeConnection() {
+ if s.conn != nil {
+ s.conn.Close()
+ s.conn = nil
+ }
+}
+
+var reVersion = regexp.MustCompile(`[0-9][0-9][0-9]`)
+
+const versionProperty = "Version"
+
+func (s *SystemdUnits) getSystemdVersion(conn systemdConnection) (int, error) {
+ s.Debugf("calling function 'GetManagerProperty'")
+ version, err := conn.GetManagerProperty(versionProperty)
+ if err != nil {
+ return 0, fmt.Errorf("error on getting '%s' manager property: %v", versionProperty, err)
+ }
+
+ s.Debugf("systemd version: %s", version)
+
+ major := reVersion.FindString(version)
+ if major == "" {
+ return 0, fmt.Errorf("couldn't parse systemd version string '%s'", version)
+ }
+
+ ver, err := strconv.Atoi(major)
+ if err != nil {
+ return 0, fmt.Errorf("couldn't parse systemd version string '%s': %v", version, err)
+ }
+
+ return ver, nil
+}
+
+func (s *SystemdUnits) getLoadedUnits(conn systemdConnection) ([]dbus.UnitStatus, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), s.Timeout.Duration)
+ defer cancel()
+
+ s.Debugf("calling function 'ListUnits'")
+ units, err := conn.ListUnitsContext(ctx)
+ if err != nil {
+ return nil, fmt.Errorf("error on ListUnits: %v", err)
+ }
+
+ loaded := units[:0]
+ for _, unit := range units {
+ if unit.LoadState == "loaded" && s.sr.MatchString(unit.Name) {
+ loaded = append(loaded, unit)
+ }
+ }
+ s.Debugf("got total/loaded %d/%d units", len(units), len(loaded))
+
+ return loaded, nil
+}
+
+func (s *SystemdUnits) getLoadedUnitsByPatterns(conn systemdConnection) ([]dbus.UnitStatus, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), s.Timeout.Duration)
+ defer cancel()
+
+ s.Debugf("calling function 'ListUnitsByPatterns'")
+
+ units, err := conn.ListUnitsByPatternsContext(ctx, unitStates, s.Include)
+ if err != nil {
+ return nil, fmt.Errorf("error on ListUnitsByPatterns: %v", err)
+ }
+
+ loaded := units[:0]
+ for _, unit := range units {
+ if unit.LoadState == "loaded" {
+ loaded = append(loaded, unit)
+ }
+ }
+ s.Debugf("got total/loaded %d/%d units", len(units), len(loaded))
+
+ return loaded, nil
+}
+
+func extractUnitNameType(name string) (string, string) {
+ idx := strings.LastIndexByte(name, '.')
+ if idx <= 0 {
+ return "", ""
+ }
+ return name[:idx], name[idx+1:]
+}
+
+func cleanUnitName(name string) string {
+ // dev-disk-by\x2duuid-DE44\x2dCEE0.device => dev-disk-by-uuid-DE44-CEE0.device
+ if strings.IndexByte(name, '\\') == -1 {
+ return name
+ }
+ v, err := strconv.Unquote("\"" + name + "\"")
+ if err != nil {
+ return name
+ }
+ return v
+}
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/config_schema.json b/src/go/collectors/go.d.plugin/modules/systemdunits/config_schema.json
new file mode 100644
index 0000000000..5a9df2571b
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/config_schema.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "go.d/systemdunits job configuration schema.",
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "include": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1
+ },
+ "timeout": {
+ "type": [
+ "string",
+ "integer"
+ ]
+ }
+ },
+ "required": [
+ "name",
+ "include"
+ ]
+} \ No newline at end of file
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go b/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go
new file mode 100644
index 0000000000..8bb45fab91
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+// Package systemdunits is a systemd units states collector
+package systemdunits
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/init.go b/src/go/collectors/go.d.plugin/modules/systemdunits/init.go
new file mode 100644
index 0000000000..d079443b15
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/init.go
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+//go:build linux
+// +build linux
+
+package systemdunits
+
+import (
+ "errors"
+ "strings"
+
+ "github.com/netdata/go.d.plugin/pkg/matcher"
+)
+
+func (s *SystemdUnits) validateConfig() error {
+ if len(s.Include) == 0 {
+ return errors.New("'include' option not set")
+ }
+ return nil
+}
+
+func (s *SystemdUnits) initSelector() (matcher.Matcher, error) {
+ if len(s.Include) == 0 {
+ return matcher.TRUE(), nil
+ }
+
+ expr := strings.Join(s.Include, " ")
+ return matcher.NewSimplePatternsMatcher(expr)
+}
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/integrations/systemd_units.md b/src/go/collectors/go.d.plugin/modules/systemdunits/integrations/systemd_units.md
new file mode 100644
index 0000000000..9fae020c8a
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/integrations/systemd_units.md
@@ -0,0 +1,253 @@
+<!--startmeta
+custom_edit_url: "https://github.com/netdata/go.d.plugin/edit/master/modules/systemdunits/README.md"
+meta_yaml: "https://github.com/netdata/go.d.plugin/edit/master/modules/systemdunits/metadata.yaml"
+sidebar_label: "Systemd Units"
+learn_status: "Published"
+learn_rel_path: "Data Collection/Systemd"
+most_popular: False
+message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
+endmeta-->
+
+# Systemd Units
+
+
+<img src="https://netdata.cloud/img/systemd.svg" width="150"/>
+
+
+Plugin: go.d.plugin
+Module: systemdunits
+
+<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
+
+## Overview
+
+This collector monitors Systemd units state.
+
+
+
+
+This collector is supported on all platforms.
+
+This collector supports collecting metrics from multiple instances of this integration, including remote instances.
+
+
+### Default Behavior
+
+#### Auto-Detection
+
+This integration doesn't support auto-detection.
+
+#### Limits
+
+The default configuration for this integration does not impose any limits on data collection.
+
+#### Performance Impact
+
+The default configuration for this integration is not expected to impose a significant performance impact on the system.
+
+
+## Metrics
+
+Metrics grouped by *scope*.
+
+The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
+
+
+
+### Per unit
+
+These metrics refer to the systemd unit.
+
+Labels:
+
+| Label | Description |
+|:-----------|:----------------|
+| unit_name | systemd unit name |
+
+Metrics:
+
+| Metric | Dimensions | Unit |
+|:------|:----------|:----|
+| systemd.service_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.socket_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.target_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.path_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.device_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.mount_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.automount_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.swap_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.timer_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.scope_unit_state | active, inactive, activating, deactivating, failed | state |
+| systemd.slice_unit_state | active, inactive, activating, deactivating, failed | state |
+
+
+
+## Alerts
+
+
+The following alerts are available:
+
+| Alert name | On metric | Description |
+|:------------|:----------|:------------|
+| [ systemd_service_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.service_unit_state | systemd service unit in the failed state |
+| [ systemd_socket_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.socket_unit_state | systemd socket unit in the failed state |
+| [ systemd_target_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.target_unit_state | systemd target unit in the failed state |
+| [ systemd_path_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.path_unit_state | systemd path unit in the failed state |
+| [ systemd_device_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.device_unit_state | systemd device unit in the failed state |
+| [ systemd_mount_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.mount_unit_state | systemd mount unit in the failed state |
+| [ systemd_automount_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.automount_unit_state | systemd automount unit in the failed state |
+| [ systemd_swap_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.swap_unit_state | systemd swap unit in the failed state |
+| [ systemd_scope_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.scope_unit_state | systemd scope unit in the failed state |
+| [ systemd_slice_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.slice_unit_state | systemd slice unit in the failed state |
+| [ systemd_timer_unit_failed_state ](https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf) | systemd.timer_unit_state | systemd timer unit in the failed state |
+
+
+## Setup
+
+### Prerequisites
+
+No action required.
+
+### Configuration
+
+#### File
+
+The configuration file name for this integration is `go.d/systemdunits.conf`.
+
+
+You can edit the configuration file using the `edit-config` script from the
+Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/configure/nodes.md#the-netdata-config-directory).
+
+```bash
+cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
+sudo ./edit-config go.d/systemdunits.conf
+```
+#### Options
+
+The following options can be defined globally: update_every, autodetection_retry.
+
+
+<details><summary>Config options</summary>
+
+| Name | Description | Default | Required |
+|:----|:-----------|:-------|:--------:|
+| update_every | Data collection frequency. | 1 | no |
+| autodetection_retry | Recheck interval in seconds. Zero means no recheck will be scheduled. | 0 | no |
+| include | Systemd units filter. | *.service | no |
+| timeout | System bus requests timeout. | 1 | no |
+
+##### include
+
+Systemd units matching the selector will be monitored.
+
+- Logic: (pattern1 OR pattern2)
+- Pattern syntax: [shell file name pattern](https://golang.org/pkg/path/filepath/#Match)
+- Syntax:
+
+```yaml
+includes:
+ - pattern1
+ - pattern2
+```
+
+
+</details>
+
+#### Examples
+
+##### Service units
+
+Collect state of all service type units.
+
+<details><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: service
+ include:
+ - '*.service'
+
+```
+</details>
+
+##### One specific unit
+
+Collect state of one specific unit.
+
+<details><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: my-specific-service
+ include:
+ - 'my-specific.service'
+
+```
+</details>
+
+##### All unit types
+
+Collect state of all units.
+
+<details><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: my-specific-service-unit
+ include:
+ - '*'
+
+```
+</details>
+
+##### Multi-instance
+
+> **Note**: When you define multiple jobs, their names must be unique.
+
+Collect state of all service and socket type units.
+
+
+<details><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: service
+ include:
+ - '*.service'
+
+ - name: socket
+ include:
+ - '*.socket'
+
+```
+</details>
+
+
+
+## Troubleshooting
+
+### Debug Mode
+
+To troubleshoot issues with the `systemdunits` collector, run the `go.d.plugin` with the debug option enabled. The output
+should give you clues as to why the collector isn't working.
+
+- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
+ your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
+
+ ```bash
+ cd /usr/libexec/netdata/plugins.d/
+ ```
+
+- Switch to the `netdata` user.
+
+ ```bash
+ sudo -u netdata -s
+ ```
+
+- Run the `go.d.plugin` to debug the collector:
+
+ ```bash
+ ./go.d.plugin -d -m systemdunits
+ ```
+
+
diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/metadata.yaml b/src/go/collectors/go.d.plugin/modules/systemdunits/metadata.yaml
new file mode 100644
index 0000000000..21755bb698
--- /dev/null
+++ b/src/go/collectors/go.d.plugin/modules/systemdunits/metadata.yaml
@@ -0,0 +1,290 @@
+plugin_name: go.d.plugin
+modules:
+ - meta:
+ id: collector-go.d.plugin-systemdunits
+ plugin_name: go.d.plugin
+ module_name: systemdunits
+ monitored_instance:
+ name: Systemd Units
+ link: https://www.freedesktop.org/wiki/Software/systemd/
+ icon_filename: systemd.svg
+ categories:
+ - data-collection.systemd
+ keywords:
+ - systemd
+ related_resources:
+ integrations:
+ list: []
+ info_provided_to_referring_integrations:
+ description: ""
+ most_popular: false
+ overview:
+ data_collection:
+ metrics_description: |
+ This collector monitors Systemd units state.
+ method_description: ""
+ supported_platforms:
+ include: []
+ exclude: []
+ multi_instance: true
+ additional_permissions:
+ description: ""
+ default_behavior:
+ auto_detection:
+ description: ""
+ limits:
+ description: ""
+ performance_impact:
+ description: ""
+ setup:
+ prerequisites:
+ list: []
+ configuration:
+ file:
+ name: go.d/systemdunits.conf
+ options:
+ description: |
+ The following options can be defined globally: update_every, autodetection_retry.
+ folding:
+ title: Config options
+ enabled: true
+ list:
+ - name: update_every
+ description: Data collection frequency.
+ default_value: 1
+ required: false
+ - name: autodetection_retry
+ description: Recheck interval in seconds. Zero means no recheck will be scheduled.
+ default_value: 0
+ required: false
+ - name: include
+ description: Systemd units filter.
+ default_value: "*.service"
+ required: false
+ detailed_description: |
+ Systemd units matching the selector will be monitored.
+
+ - Logic: (pattern1 OR pattern2)
+ - Pattern syntax: [shell file name pattern](https://golang.org/pkg/path/filepath/#Match)
+ - Syntax:
+
+ ```yaml
+ includes:
+ - pattern1
+ - pattern2
+ ```
+ - name: timeout
+ description: System bus requests timeout.
+ default_value: 1
+ required: false
+ examples:
+ folding:
+ title: Config
+ enabled: true
+ list:
+ - name: Service units
+ description: Collect state of all service type units.
+ config: |
+ jobs:
+ - name: service
+ include:
+ - '*.service'
+ - name: One specific unit
+ description: Collect state of one specific unit.
+ config: |
+ jobs:
+ - name: my-specific-service
+ include:
+ - 'my-specific.service'
+ - name: All unit types
+ description: Collect state of all units.
+ config: |
+ jobs:
+ - name: my-specific-service-unit
+ include:
+ - '*'
+ - name: Multi-instance
+ description: |
+ > **Note**: When you define multiple jobs, their names must be unique.
+
+ Collect state of all service and socket type units.
+ config: |
+ jobs:
+ - name: service
+ include:
+ - '*.service'
+
+ - name: socket
+ include:
+ - '*.socket'
+ troubleshooting:
+ problems:
+ list: []
+ alerts:
+ - name: systemd_service_unit_failed_state
+ metric: systemd.service_unit_state
+ info: systemd service unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_socket_unit_failed_state
+ metric: systemd.socket_unit_state
+ info: systemd socket unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_target_unit_failed_state
+ metric: systemd.target_unit_state
+ info: systemd target unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_path_unit_failed_state
+ metric: systemd.path_unit_state
+ info: systemd path unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_device_unit_failed_state
+ metric: systemd.device_unit_state
+ info: systemd device unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_mount_unit_failed_state
+ metric: systemd.mount_unit_state
+ info: systemd mount unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_automount_unit_failed_state
+ metric: systemd.automount_unit_state
+ info: systemd automount unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_swap_unit_failed_state
+ metric: systemd.swap_unit_state
+ info: systemd swap unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_scope_unit_failed_state
+ metric: systemd.scope_unit_state
+ info: systemd scope unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_slice_unit_failed_state
+ metric: systemd.slice_unit_state
+ info: systemd slice unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ - name: systemd_timer_unit_failed_state
+ metric: systemd.timer_unit_state
+ info: systemd timer unit in the failed state
+ link: https://github.com/netdata/netdata/blob/master/src/health/health.d/systemdunits.conf
+ metrics:
+ folding:
+ title: Metrics
+ enabled: false
+ description: ""
+ availability: []
+ scopes:
+ - name: unit
+ description: These metrics refer to the systemd unit.
+ labels:
+ - name: unit_name
+ description: systemd unit name
+ metrics:
+ - name: systemd.service_unit_state
+ description: Service Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.socket_unit_state
+ description: Socket Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.target_unit_state
+ description: Target Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.path_unit_state
+ description: Path Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.device_unit_state
+ description: Device Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.mount_unit_state
+ description: Mount Unit State
+ unit: state
+ chart_type: line
+ dimensions:
+ - name: active
+ - name: inactive
+ - name: activating
+ - name: deactivating
+ - name: failed
+ - name: systemd.automount_unit_state
+ description