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 | 含义 | 描述 |
|---|---|---|
| 0 | loaded | unit is ~ |
| 1 | stub | unit is ~ |
| 2 | not-found | unit is ~ |
| 3 | bad-setting | unit is ~ |
| 4 | error | unit is ~ |
| 5 | merged | unit is ~ |
| 6 | masked | unit is ~ |
Active
来自 unit_active_state_table 的枚举
| Value | 含义 | 描述 |
|---|---|---|
| 0 | active | unit is ~ |
| 1 | reloading | unit is ~ |
| 2 | inactive | unit is ~ |
| 3 | failed | unit is ~ |
| 4 | activating | unit is ~ |
| 5 | deactivating | unit is ~ |
Sub
子状态的枚举,请参阅各种 unittype_state_tables;重复项已被删除,表格已按十六进制对齐,为未来值留出一些空间。
| Value | 含义 | 描述 |
|---|---|---|
| service_state_table start at 0x0000 | ||
| 0x0000 | running | unit is ~ |
| 0x0001 | dead | unit is ~ |
| 0x0002 | start-pre | unit is ~ |
| 0x0003 | start | unit is ~ |
| 0x0004 | exited | unit is ~ |
| 0x0005 | reload | unit is ~ |
| 0x0006 | stop | unit is ~ |
| 0x0007 | stop-watchdog | unit is ~ |
| 0x0008 | stop-sigterm | unit is ~ |
| 0x0009 | stop-sigkill | unit is ~ |
| 0x000a | stop-post | unit is ~ |
| 0x000b | final-sigterm | unit is ~ |
| 0x000c | failed | unit is ~ |
| 0x000d | auto-restart | unit is ~ |
| 0x000e | condition | unit is ~ |
| 0x000f | cleaning | unit is ~ |
| service_state_table start at 0x0010 | ||
| 0x0010 | waiting | unit is ~ |
| 0x0011 | reload-signal | unit is ~ |
| 0x0012 | reload-notify | unit is ~ |
| 0x0013 | final-watchdog | unit is ~ |
| 0x0014 | dead-before-auto-restart | unit is ~ |
| 0x0015 | failed-before-auto-restart | unit is ~ |
| 0x0016 | dead-resources-pinned | unit is ~ |
| 0x0017 | auto-restart-queued | unit is ~ |
| service_state_table start at 0x0020 | ||
| 0x0020 | tentative | unit is ~ |
| 0x0021 | plugged | unit is ~ |
| service_state_table start at 0x0030 | ||
| 0x0030 | mounting | unit is ~ |
| 0x0031 | mounting-done | unit is ~ |
| 0x0032 | mounted | unit is ~ |
| 0x0033 | remounting | unit is ~ |
| 0x0034 | unmounting | unit is ~ |
| 0x0035 | remounting-sigterm | unit is ~ |
| 0x0036 | remounting-sigkill | unit is ~ |
| 0x0037 | unmounting-sigterm | unit is ~ |
| 0x0038 | unmounting-sigkill | unit is ~ |
| service_state_table start at 0x0040 | ||
| service_state_table start at 0x0050 | ||
| 0x0050 | abandoned | unit is ~ |
| service_state_table start at 0x0060 | ||
| 0x0060 | active | unit is ~ |
| service_state_table start at 0x0070 | ||
| 0x0070 | start-chown | unit is ~ |
| 0x0071 | start-post | unit is ~ |
| 0x0072 | listening | unit is ~ |
| 0x0073 | stop-pre | unit is ~ |
| 0x0074 | stop-pre-sigterm | unit is ~ |
| 0x0075 | stop-pre-sigkill | unit is ~ |
| 0x0076 | final-sigkill | unit is ~ |
| service_state_table start at 0x0080 | ||
| 0x0080 | activating | unit is ~ |
| 0x0081 | activating-done | unit is ~ |
| 0x0082 | deactivating | unit is ~ |
| 0x0083 | deactivating-sigterm | unit is ~ |
| 0x0084 | deactivating-sigkill | unit is ~ |
| service_state_table start at 0x0090 | ||
| service_state_table start at 0x00a0 | ||
| 0x00a0 | elapsed | unit 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此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。