文档文档

Systemd-Units 输入插件

此插件使用 systemd 的 DBus 接口收集 Linux 上 systemd-units 的状态。

此插件需要 systemd v230+!

引入于: Telegraf v1.13.0 标签: system 操作系统支持: linux

全局配置选项

插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md

配置

# 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 (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"

此插件支持两种操作模式

非详细模式

这是默认模式,仅收集单元的状态数据,不包含单元的进一步详细信息。

详细模式

可以通过将配置选项 details 设置为 true 来启用此模式。在此模式下,插件会收集非详细模式的所有信息,并提供额外的单元信息,如内存使用情况、重启计数、PID 等。请参阅指标部分。

Load

来自 unit_load_state_table 的枚举

Value含义描述
0loadedunit is ~
1stubunit is ~
2not-foundunit is ~
3bad-settingunit is ~
4errorunit is ~
5mergedunit is ~
6maskedunit is ~

Active

来自 unit_active_state_table 的枚举

Value含义描述
0activeunit is ~
1reloadingunit is ~
2inactiveunit is ~
3failedunit is ~
4activatingunit is ~
5deactivatingunit is ~

Sub

子状态的枚举,请参阅各种 unittype_state_tables;重复项已被删除,表格已按十六进制对齐,为未来值留出一些空间。

Value含义描述
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 ~

示例输出

非详细模式下的输出

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

详细模式下的输出

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

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2