package
1.33.2
Repository: https://github.com/influxdata/telegraf.git
Documentation: pkg.go.dev

# README

Systemd-Units Input Plugin

This plugin gathers the status of systemd-units on Linux, using systemd's DBus interface.

Please note: At least systemd v230 is required!

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Configuration

# Gather information about systemd-unit states
# This plugin ONLY supports Linux
[[inputs.systemd_units]]
  ## Pattern of units to collect
  ## A space-separated list of unit-patterns including wildcards determining
  ## the units to collect.
  ##  ex: pattern = "telegraf* influxdb* user@*"
  # pattern = "*"

  ## Filter for a specific unit type
  ## Available settings are: service, socket, target, device, mount,
  ## automount, swap, timer, path, slice and scope
  # unittype = "service"

  ## Collect system or user scoped units
  ##  ex: scope = "user"
  # scope = "system"

  ## Collect also units not loaded by systemd, i.e. disabled or static units
  ## Enabling this feature might introduce significant load when used with
  ## unspecific patterns (such as '*') as systemd will need to load all
  ## matching unit files.
  # collect_disabled_units = false

  ## Collect detailed information for the units
  # details = false

  ## Timeout for state-collection
  # timeout = "5s"

This plugin supports two modes of operation:

Non-detailed mode

This is the default mode, collecting data on the unit's status only without further details on the unit.

Detailed mode

This mode can be enabled by setting the configuration option details to true. In this mode the plugin collects all information of the non-detailed mode but provides additional unit information such as memory usage, restart-counts, PID, etc. See the metrics section below for a list of all properties collected.

Metrics

These metrics are available in both modes:

  • systemd_units:
    • tags:
      • name (string, unit name)
      • load (string, load state)
      • active (string, active state)
      • sub (string, sub state)
      • user (string, username only for user scope)
    • fields:
      • load_code (int, see below)
      • active_code (int, see below)
      • sub_code (int, see below)

The following additional metrics are available with details = true:

  • systemd_units:
    • tags:
      • state (string, unit file state)
      • preset (string, unit file preset state)
    • fields:
      • status_errno (int, last error)
      • restarts (int, number of restarts)
      • pid (int, pid of the main process)
      • mem_current (uint, current memory usage)
      • mem_peak (uint, peak memory usage)
      • swap_current (uint, current swap usage)
      • swap_peak (uint, peak swap usage)
      • mem_avail (uint, available memory for this unit)

Load

Enumeration of unit_load_state_table

ValueMeaningDescription
0loadedunit is ~
1stubunit is ~
2not-foundunit is ~
3bad-settingunit is ~
4errorunit is ~
5mergedunit is ~
6maskedunit is ~

Active

Enumeration of unit_active_state_table

ValueMeaningDescription
0activeunit is ~
1reloadingunit is ~
2inactiveunit is ~
3failedunit is ~
4activatingunit is ~
5deactivatingunit is ~

Sub

enumeration of sub states, see various unittype_state_tables; duplicates were removed, tables are hex aligned to keep some space for future values

ValueMeaningDescription
service_state_table start at 0x0000
0x0000runningunit is ~
0x0001deadunit is ~
0x0002start-preunit is ~
0x0003startunit is ~
0x0004exitedunit is ~
0x0005reloadunit is ~
0x0006stopunit is ~
0x0007stop-watchdogunit is ~
0x0008stop-sigtermunit is ~
0x0009stop-sigkillunit is ~
0x000astop-postunit is ~
0x000bfinal-sigtermunit is ~
0x000cfailedunit is ~
0x000dauto-restartunit is ~
0x000econditionunit is ~
0x000fcleaningunit is ~
service_state_table start at 0x0010
0x0010waitingunit is ~
0x0011reload-signalunit is ~
0x0012reload-notifyunit is ~
0x0013final-watchdogunit is ~
0x0014dead-before-auto-restartunit is ~
0x0015failed-before-auto-restartunit is ~
0x0016dead-resources-pinnedunit is ~
0x0017auto-restart-queuedunit is ~
service_state_table start at 0x0020
0x0020tentativeunit is ~
0x0021pluggedunit is ~
service_state_table start at 0x0030
0x0030mountingunit is ~
0x0031mounting-doneunit is ~
0x0032mountedunit is ~
0x0033remountingunit is ~
0x0034unmountingunit is ~
0x0035remounting-sigtermunit is ~
0x0036remounting-sigkillunit is ~
0x0037unmounting-sigtermunit is ~
0x0038unmounting-sigkillunit is ~
service_state_table start at 0x0040
service_state_table start at 0x0050
0x0050abandonedunit is ~
service_state_table start at 0x0060
0x0060activeunit is ~
service_state_table start at 0x0070
0x0070start-chownunit is ~
0x0071start-postunit is ~
0x0072listeningunit is ~
0x0073stop-preunit is ~
0x0074stop-pre-sigtermunit is ~
0x0075stop-pre-sigkillunit is ~
0x0076final-sigkillunit is ~
service_state_table start at 0x0080
0x0080activatingunit is ~
0x0081activating-doneunit is ~
0x0082deactivatingunit is ~
0x0083deactivating-sigtermunit is ~
0x0084deactivating-sigkillunit is ~
service_state_table start at 0x0090
service_state_table start at 0x00a0
0x00a0elapsedunit is ~

Example Output

Output in non-detailed mode

systemd_units,host=host1.example.com,name=dbus.service,load=loaded,active=active,sub=running,user=telegraf load_code=0i,active_code=0i,sub_code=0i 1533730725000000000
systemd_units,host=host1.example.com,name=networking.service,load=loaded,active=failed,sub=failed,user=telegraf load_code=0i,active_code=3i,sub_code=12i 1533730725000000000
systemd_units,host=host1.example.com,name=ssh.service,load=loaded,active=active,sub=running,user=telegraf load_code=0i,active_code=0i,sub_code=0i 1533730725000000000

Output in detailed mode

systemd_units,active=active,host=host1.example.com,load=loaded,name=dbus.service,sub=running,preset=disabled,state=static,user=telegraf active_code=0i,load_code=0i,mem_avail=6470856704i,mem_current=2691072i,mem_peak=3895296i,pid=481i,restarts=0i,status_errno=0i,sub_code=0i,swap_current=794624i,swap_peak=884736i 1533730725000000000
systemd_units,active=inactive,host=host1.example.com,load=not-found,name=networking.service,sub=dead,user=telegraf active_code=2i,load_code=2i,pid=0i,restarts=0i,status_errno=0i,sub_code=1i 1533730725000000000
systemd_units,active=active,host=host1.example.com,load=loaded,name=pcscd.service,sub=running,preset=disabled,state=indirect,user=telegraf active_code=0i,load_code=0i,mem_avail=6370541568i,mem_current=512000i,mem_peak=4399104i,pid=1673i,restarts=0i,status_errno=0i,sub_code=0i,swap_current=3149824i,swap_peak=3149824i 1533730725000000000

# Structs

SystemdUnits is a telegraf plugin to gather systemd unit status.