diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2024-07-02 15:32:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 15:32:34 +0300 |
commit | 7fee1e522262104b75a5f8d7e38b9299275d87bc (patch) | |
tree | f2999f9ca7d5017182d82d3e99d19bb6ce429f4f /src/go/collectors/go.d.plugin/modules/systemdunits | |
parent | e99da8b64b1588a4ccf19f89953ee83c49584bb7 (diff) |
restructure go.d (#18058)
* restruture go.d
* update gitignore
* update ci files
* update gen_docs_integrations.py
* update link in go.d conf files
* update go.d modules metadata files
* update metadata files
* update packaging
* add log files
* integrations commit
* update get-go-version.py
* go fmt
* fix packaging
* update go.d readme
---------
Co-authored-by: Fotis Voutsas <fotis@netdata.cloud>
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/systemdunits')
15 files changed, 0 insertions, 2660 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 deleted file mode 120000 index 68dd433bf2..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/README.md +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 18d8838fbc..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/charts.go +++ /dev/null @@ -1,118 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//go:build linux -// +build linux - -package systemdunits - -import ( - "fmt" - "path/filepath" - "strings" - - "github.com/netdata/netdata/go/go.d.plugin/agent/module" - - "golang.org/x/text/cases" - "golang.org/x/text/language" -) - -const ( - prioUnitState = module.Priority + iota - prioUnitFileState -) - -func (s *SystemdUnits) addUnitCharts(name, typ string) { - chart := module.Chart{ - ID: "unit_%s_%s_state", - Title: "%s Unit State", - Units: "state", - Fam: "%s units", - Ctx: "systemd.%s_unit_state", - Priority: prioUnitState, - Labels: []module.Label{ - {Key: "unit_name", Value: name}, - }, - Dims: module.Dims{ - {ID: "unit_%s_%s_state_%s", Name: unitStateActive}, - {ID: "unit_%s_%s_state_%s", Name: unitStateInactive}, - {ID: "unit_%s_%s_state_%s", Name: unitStateActivating}, - {ID: "unit_%s_%s_state_%s", Name: unitStateDeactivating}, - {ID: "unit_%s_%s_state_%s", Name: unitStateFailed}, - }, - } - - chart.ID = fmt.Sprintf(chart.ID, name, typ) - chart.Title = fmt.Sprintf(chart.Title, cases.Title(language.English, cases.Compact).String(typ)) - chart.Fam = fmt.Sprintf(chart.Fam, typ) - chart.Ctx = fmt.Sprintf(chart.Ctx, typ) - - for _, d := range chart.Dims { - d.ID = fmt.Sprintf(d.ID, name, typ, d.Name) - } - - if err := s.Charts().Add(&chart); err != nil { - s.Warning(err) - } -} - -func (s *SystemdUnits) removeUnitCharts(name, typ string) { - px := fmt.Sprintf("unit_%s_%s_", name, typ) - s.removeCharts(px) -} - -func (s *SystemdUnits) addUnitFileCharts(unitPath string) { - _, unitName := filepath.Split(unitPath) - unitType := strings.TrimPrefix(filepath.Ext(unitPath), ".") - - chart := module.Chart{ - ID: "unit_file_%s_state", - Title: "Unit File State", - Units: "state", - Fam: "unit files", - Ctx: "systemd.unit_file_state", - Type: module.Line, - Priority: prioUnitFileState, - Labels: []module.Label{ - {Key: "unit_file_name", Value: unitName}, - {Key: "unit_file_type", Value: unitType}, - }, - Dims: module.Dims{ - {ID: "unit_file_%s_state_enabled", Name: "enabled"}, - {ID: "unit_file_%s_state_enabled-runtime", Name: "enabled-runtime"}, - {ID: "unit_file_%s_state_linked", Name: "linked"}, - {ID: "unit_file_%s_state_linked-runtime", Name: "linked-runtime"}, - {ID: "unit_file_%s_state_alias", Name: "alias"}, - {ID: "unit_file_%s_state_masked", Name: "masked"}, - {ID: "unit_file_%s_state_masked-runtime", Name: "masked-runtime"}, - {ID: "unit_file_%s_state_static", Name: "static"}, - {ID: "unit_file_%s_state_disabled", Name: "disabled"}, - {ID: "unit_file_%s_state_indirect", Name: "indirect"}, - {ID: "unit_file_%s_state_generated", Name: "generated"}, - {ID: "unit_file_%s_state_transient", Name: "transient"}, - {ID: "unit_file_%s_state_bad", Name: "bad"}, - }, - } - - chart.ID = fmt.Sprintf(chart.ID, strings.ReplaceAll(unitPath, ".", "_")) - for _, dim := range chart.Dims { - dim.ID = fmt.Sprintf(dim.ID, unitPath) - } - - if err := s.Charts().Add(&chart); err != nil { - s.Warning(err) - } -} - -func (s *SystemdUnits) removeUnitFileCharts(unitPath string) { - px := fmt.Sprintf("unit_file_%s_", strings.ReplaceAll(unitPath, ".", "_")) - s.removeCharts(px) -} - -func (s *SystemdUnits) removeCharts(prefix string) { - for _, chart := range *s.Charts() { - if strings.HasPrefix(chart.ID, prefix) { - chart.MarkRemove() - chart.MarkNotCreated() - } - } -} diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/client.go b/src/go/collectors/go.d.plugin/modules/systemdunits/client.go deleted file mode 100644 index e6363d1329..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/client.go +++ /dev/null @@ -1,34 +0,0 @@ -// 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{} -} diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go b/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go deleted file mode 100644 index 0d61c9998e..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/collect.go +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//go:build linux -// +build linux - -package systemdunits - -import ( - "fmt" - "regexp" - "strconv" -) - -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 - } - - mx := make(map[string]int64) - - if err := s.collectUnits(mx, conn); err != nil { - s.closeConnection() - return nil, err - } - - if s.CollectUnitFiles && len(s.IncludeUnitFiles) > 0 { - if err := s.collectUnitFiles(mx, conn); err != nil { - s.closeConnection() - return mx, err - } - } - - return mx, nil -} - -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 -} diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/collect_unit_files.go b/src/go/collectors/go.d.plugin/modules/systemdunits/collect_unit_files.go deleted file mode 100644 index eff2d6ecb6..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/collect_unit_files.go +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//go:build linux -// +build linux - -package systemdunits - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/coreos/go-systemd/v22/dbus" -) - -// https://github.com/systemd/systemd/blob/3d320785c4bbba74459096b07e85a79c4f0cdffb/src/shared/install.c#L3785 -// see "is-enabled" in https://www.man7.org/linux/man-pages/man1/systemctl.1.html -var unitFileStates = []string{ - "enabled", - "enabled-runtime", - "linked", - "linked-runtime", - "alias", - "masked", - "masked-runtime", - "static", - "disabled", - "indirect", - "generated", - "transient", - "bad", -} - -func (s *SystemdUnits) collectUnitFiles(mx map[string]int64, conn systemdConnection) error { - if s.systemdVersion < 230 { - return nil - } - - if now := time.Now(); now.After(s.lastListUnitFilesTime.Add(s.CollectUnitFilesEvery.Duration())) { - unitFiles, err := s.getUnitFilesByPatterns(conn) - if err != nil { - return err - } - s.lastListUnitFilesTime = now - s.cachedUnitFiles = unitFiles - } - - seen := make(map[string]bool) - - for _, unitFile := range s.cachedUnitFiles { - seen[unitFile.Path] = true - - if !s.seenUnitFiles[unitFile.Path] { - s.seenUnitFiles[unitFile.Path] = true - s.addUnitFileCharts(unitFile.Path) - } - - px := fmt.Sprintf("unit_file_%s_state_", unitFile.Path) - for _, st := range unitFileStates { - mx[px+st] = 0 - } - mx[px+strings.ToLower(unitFile.Type)] = 1 - } - - for k := range s.seenUnitFiles { - if !seen[k] { - delete(s.seenUnitFiles, k) - s.removeUnitFileCharts(k) - } - } - - return nil -} - -func (s *SystemdUnits) getUnitFilesByPatterns(conn systemdConnection) ([]dbus.UnitFile, error) { - ctx, cancel := context.WithTimeout(context.Background(), s.Timeout.Duration()) - defer cancel() - - s.Debugf("calling function 'ListUnitFilesByPatterns'") - - unitFiles, err := conn.ListUnitFilesByPatternsContext(ctx, nil, s.IncludeUnitFiles) - if err != nil { - return nil, fmt.Errorf("error on ListUnitFilesByPatterns: %v", err) - } - - for i := range unitFiles { - unitFiles[i].Path = cleanUnitName(unitFiles[i].Path) - } - - s.Debugf("got %d unit files", len(unitFiles)) - - return unitFiles, nil -} diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/collect_units.go b/src/go/collectors/go.d.plugin/modules/systemdunits/collect_units.go deleted file mode 100644 index 0cf97af03f..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/collect_units.go +++ /dev/null @@ -1,187 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//go:build linux -// +build linux - -package systemdunits - -import ( - "context" - "fmt" - "strconv" - "strings" - - "github.com/coreos/go-systemd/v22/dbus" -) - -const transientProperty = "Transient" - -const ( - // https://www.freedesktop.org/software/systemd/man/systemd.html - unitStateActive = "active" - unitStateInactive = "inactive" - unitStateActivating = "activating" - unitStateDeactivating = "deactivating" - unitStateFailed = "failed" -) - -var unitStates = []string{ - unitStateActive, - unitStateActivating, - unitStateFailed, - unitStateInactive, - unitStateDeactivating, -} - -func (s *SystemdUnits) collectUnits(mx map[string]int64, conn systemdConnection) error { - var units []dbus.UnitStatus - var err error - - 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 { - return err - } - - seen := make(map[string]bool) - - for _, unit := range units { - name, typ, ok := extractUnitNameType(unit.Name) - if !ok { - continue - } - - seen[unit.Name] = true - - if s.SkipTransient { - if _, ok := s.unitTransient[unit.Name]; !ok { - prop, err := s.getUnitTransientProperty(conn, unit.Name) - if err != nil { - return err - } - prop = strings.Trim(prop, "\"") - s.unitTransient[unit.Name] = prop == "true" - } - if s.unitTransient[unit.Name] { - continue - } - } - - if !s.seenUnits[unit.Name] { - s.seenUnits[unit.Name] = true - s.addUnitCharts(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 - } - - for k := range s.seenUnits { - if !seen[k] { - delete(s.seenUnits, k) - if name, typ, ok := extractUnitNameType(k); ok { - s.removeUnitCharts(name, typ) - } - } - } - - for k := range s.unitTransient { - if !seen[k] { - delete(s.unitTransient, k) - } - } - - return 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) - } - - for i := range units { - units[i].Name = cleanUnitName(units[i].Name) - } - - loaded := units[:0] - for _, unit := range units { - if unit.LoadState == "loaded" && s.unitSr.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) - } - - for i := range units { - units[i].Name = cleanUnitName(units[i].Name) - } - - 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 (s *SystemdUnits) getUnitTransientProperty(conn systemdConnection, unit string) (string, error) { - ctx, cancel := context.WithTimeout(context.Background(), s.Timeout.Duration()) - defer cancel() - - s.Debugf("calling function 'GetUnitProperty' for unit '%s'", unit) - - prop, err := conn.GetUnitPropertyContext(ctx, unit, transientProperty) - if err != nil { - return "", fmt.Errorf("error on GetUnitProperty: %v", err) - } - - return prop.Value.String(), nil -} - -func extractUnitNameType(name string) (string, string, bool) { - idx := strings.LastIndexByte(name, '.') - if idx <= 0 { - return "", "", false - } - return name[:idx], name[idx+1:], true -} - -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 deleted file mode 100644 index 016e984ced..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/config_schema.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "jsonSchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Systemdunits collector configuration.", - "type": "object", - "properties": { - "update_every": { - "title": "Update every", - "description": "Data collection interval, measured in seconds.", - "type": "integer", - "minimum": 1, - "default": 10 - }, - "timeout": { - "title": "Timeout", - "description": "The timeout, in seconds, for connecting and querying systemd's D-Bus endpoint.", - "type": "number", - "minimum": 0.5, - "default": 2 - }, - "skip_transient": { - "title": "Skip transient units", - "description": "If set, skip data collection for systemd transient units.", - "type": "boolean", - "default": false - }, - "include": { - "title": "Include", - "description": "Configuration for monitoring specific systemd units. Include systemd units whose names match any of the specified [patterns](https://golang.org/pkg/path/filepath/#Match).", - "type": [ - "array", - "null" - ], - "uniqueItems": true, - "minItems": 1, - "items": { - "title": "Unit pattern", - "type": "string" - }, - "default": [ - "*.service" - ] - }, - "collect_unit_files": { - "title": "Collect unit files", - "description": "If set, collect the state of installed unit files. **Enabling this may increase system overhead**, particularly if the pattern matches a large number of unit files.", - "type": "boolean", - "default": false - }, - "collect_unit_files_every": { - "title": "Unit files polling interval", - "description": "Interval for querying systemd about unit files and their enablement state, measured in seconds. Data is cached for this interval to reduce system overhead.", - "type": "number", - "minimum": 1, - "default": 300 - }, - "include_unit_files": { - "title": "Include unit files", - "description": "Configuration for monitoring specific systemd unit files. Include systemd unit files whose names match any of the specified [patterns](https://golang.org/pkg/path/filepath/#Match).", - "type": [ - "array", - "null" - ], - "uniqueItems": true, - "minItems": 1, - "items": { - "title": "Unit file name pattern", - "type": "string" - }, - "default": [ - "*.service" - ] - } - }, - "required": [ - "include" - ], - "additionalProperties": false, - "patternProperties": { - "^name$": {} - } - }, - "uiSchema": { - "uiOptions": { - "fullPage": true - }, - "ui:flavour": "tabs", - "ui:options": { - "tabs": [ - { - "title": "Base", - "fields": [ - "update_every", - "timeout", - "skip_transient", - "include" - ] - }, - { - "title": "Unit Files", - "fields": [ - "collect_unit_files", - "collect_unit_files_every", - "include_unit_files" - ] - } - ] - }, - "timeout": { - "ui:help": "Accepts decimals for precise control (e.g., type 1.5 for 1.5 seconds)." - }, - "skip_transient": { - "ui:help": "A systemd transient unit is a temporary unit created on-the-fly, typically used for ad-hoc tasks or testing purposes. They are created using the `systemd-run` command, which allows you to specify unit properties directly on the command line." - }, - "include": { - "ui:listFlavour": "list" - }, - "include_unit_files": { - "ui:listFlavour": "list" - } - } -} diff --git a/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go b/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go deleted file mode 100644 index 8bb45fab91..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// 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 deleted file mode 100644 index ea3d21d379..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/init.go +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//go:build linux -// +build linux - -package systemdunits - -import ( - "errors" - "strings" - - "github.com/netdata/netdata/go/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) initUnitSelector() (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 deleted file mode 100644 index f87f3cc073..0000000000 --- a/src/go/collectors/go.d.plugin/modules/systemdunits/integrations/systemd_units.md +++ /dev/null @@ -1,322 +0,0 @@ -<!--startmeta -custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/systemdunits/README.md" -meta_yaml: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/systemdunits/metadata.yaml" -sidebar_label: "Systemd Units" -learn_status: "Published" -learn_rel_path: "Collecting Metrics/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 the state of Systemd units and unit files. - - - - -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 | - -### Per unit file - -These metrics refer to the systemd unit file. - -Labels: - -| Label | Description | -|:-----------|:----------------| -| unit_file_name | systemd unit file name | -| unit_file_type | systemd unit file type | - -Metrics: - -| Metric | Dimensions | Unit | -|:------|:----------|:----| -| systemd.unit_file_state | enabled, enabled-runtime, linked, linked-runtime, alias, masked, masked-runtime, static, disabled, indirect, generated, transient, bad | 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](/docs/netdata-agent/configuration/README.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 open><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 | -| timeout | System bus requests timeout. | 1 | no | -| include | Systemd units selector. | *.service | no | -| skip_transient | If set, skip data collection fo |