21 个版本
新 0.9.1 | 2024 年 8 月 19 日 |
---|---|
0.9.0 | 2024 年 7 月 23 日 |
0.8.4 | 2024 年 6 月 5 日 |
0.8.2 | 2023 年 12 月 14 日 |
0.3.0 | 2022 年 11 月 11 日 |
#264 in Unix API
556 每月下载量
用于 monitord-exporter
1.5MB
8K SLoC
包含 (WOFF 字体, 400KB) NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2, (WOFF 字体, 135KB) FiraSans-Medium-8f9a781e4970d388.woff2, (WOFF 字体, 130KB) FiraSans-Regular-018c141bf0843ffd.woff2, (WOFF 字体, 82KB) SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2, (WOFF 字体, 77KB) SourceSerif4-Regular-46f98efaafac5295.ttf.woff2, (WOFF 字体, 45KB) SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2 和更多.
monitord
monitord ... 了解你的 systemd 多么快乐!😊
我们提供以下运行模式
- systemd-timer (传统的 cron 也会工作)
- 参考 monitord.timer 和 monitord.service 单元文件
- 确保在
monitord.conf
中未设置任何daemon:
模式选项
- 守护进程模式
- 在配置文件中启用守护进程模式
- 每
daemon_stats_refresh_secs
将将统计信息写入 stdout
开放更多格式/运行方法 ... 提交一个问题以进行讨论。基本上取决于依赖项。
monitord
是一个由配置驱动的二进制文件。我们计划将 CLI 参数保持到最小。
INFO 级别日志默认启用到 stderr。使用 -l LEVEL
增加或减少日志记录。
安装
通过 cargo 安装或将其用作 Cargo.toml
中的依赖项。
cargo安装 monitord
- 创建(从仓库复制)一个
monitord.conf
- 默认在 /etc/monitord.conf 中查找它
monitord--帮助
crl-linux:monitord cooper$ monitord --help
monitord 0.8.4
Cooper Ry Lees <[email protected]>
monitord: Know how happy your systemd is! 😊
Usage: monitord [OPTIONS]
Options:
-c, --config <CONFIG>
Location of your monitord config
[default: /etc/monitord.conf]
-l, --log-level <LOG_LEVEL>
Adjust the console log-level
[default: Info]
[possible values: error, warn, info, debug, trace]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
配置
monitord 可以监控不同的组件。要启用/禁用,请在我们的 monitord.conf 中设置以下内容。此文件是 ini 格式,以匹配 systemd 单元文件。
# Pure ini - no yes/no for bools
[monitord]
# Set a custom dbus address to connect to
# OPTIONAL: If not set, we default to the Unix socket below
dbus_address = unix:path=/run/dbus/system_bus_socket
# Run as a daemon or 1 time
daemon = false
# Time to refresh systemd stats in seconds
# Daemon mode only
daemon_stats_refresh_secs = 60
# Prefix flat-json key with this value
# The value automatically gets a '.' appended (so don't put here)
key_prefix = monitord
# cron/systemd timer output format
# Supported: json, json-flat, json-pretty
output_format = json
# Grab networkd stats from files + networkctl
[networkd]
enabled = true
link_state_dir = /run/systemd/netif/links
# Enable grabbing PID 1 stats via procfs
[pid1]
enabled = true
# Services to grab extra stats for
# .service is important as that's what DBus returns from `list_units`
[services]
foo.service
# Grab unit status counts via dbus
[units]
enabled = true
state_stats = true
# Filter what services you want collect state stats for
# If both lists are configured blocklist is preferred
# If neither exist all units state will generate counters
[units.state_stats.allowlist]
foo.service
[units.state_stats.blocklist]
bar.service
输出格式
json
普通 serde_json
不美观的 JSON。所有内容在一行。最紧凑的格式。
json-flat
将所有键值对移动到顶层,并且使用.表示组件+子值。也是半美观的+自定义。所有未测试...
{
"networkd.eno4.address_state": 3,
"networkd.eno4.admin_state": 4,
"networkd.eno4.carrier_state": 5,
"networkd.eno4.ipv4_address_state": 3,
"networkd.eno4.ipv6_address_state": 2,
"networkd.eno4.oper_state": 9,
"networkd.eno4.required_for_online": 1,
"networkd.ens2f0.address_state": 1,
"networkd.ens2f0.admin_state": 3,
"networkd.ens2f0.carrier_state": 1,
"networkd.ens2f0.ipv4_address_state": 1,
"networkd.ens2f0.ipv6_address_state": 1,
"networkd.ens2f0.oper_state": 2,
"networkd.ens2f0.required_for_online": 0,
"networkd.managed_interfaces": 6,
"networkd.spectrum.address_state": 3,
"networkd.spectrum.admin_state": 4,
"networkd.spectrum.carrier_state": 5,
"networkd.spectrum.ipv4_address_state": 3,
"networkd.spectrum.ipv6_address_state": 3,
"networkd.spectrum.oper_state": 9,
"networkd.spectrum.required_for_online": 1,
"networkd.vlan69.address_state": 3,
"networkd.vlan69.admin_state": 4,
"networkd.vlan69.carrier_state": 5,
"networkd.vlan69.ipv4_address_state": 3,
"networkd.vlan69.ipv6_address_state": 3,
"networkd.vlan69.oper_state": 9,
"networkd.vlan69.required_for_online": 1,
"networkd.vlan70.address_state": 3,
"networkd.vlan70.admin_state": 4,
"networkd.vlan70.carrier_state": 5,
"networkd.vlan70.ipv4_address_state": 1,
"networkd.vlan70.ipv6_address_state": 3,
"networkd.vlan70.oper_state": 9,
"networkd.vlan70.required_for_online": 1,
"networkd.wg0.address_state": 3,
"networkd.wg0.admin_state": 4,
"networkd.wg0.carrier_state": 5,
"networkd.wg0.ipv4_address_state": 3,
"networkd.wg0.ipv6_address_state": 3,
"networkd.wg0.oper_state": 9,
"networkd.wg0.required_for_online": 1,
"pid1.cpu_time_kernel": 48,
"pid1.cpu_user_kernel": 41,
"pid1.fd_count": 245,
"pid1.memory_usage_bytes": 19165184,
"pid1.tasks": 1,
"services.chronyd.service.active_enter_timestamp": 1683556542382710,
"services.chronyd.service.active_exit_timestamp": 0,
"services.chronyd.service.cpuusage_nsec": 328951000,
"services.chronyd.service.inactive_exit_timestamp": 1683556541360626,
"services.chronyd.service.ioread_bytes": 18446744073709551615,
"services.chronyd.service.ioread_operations": 18446744073709551615,
"services.chronyd.service.memory_available": 18446744073709551615,
"services.chronyd.service.memory_current": 5214208,
"services.chronyd.service.nrestarts": 0,
"services.chronyd.service.restart_usec": 100000,
"services.chronyd.service.state_change_timestamp": 1683556542382710,
"services.chronyd.service.status_errno": 0,
"services.chronyd.service.tasks_current": 1,
"services.chronyd.service.timeout_clean_usec": 18446744073709551615,
"services.chronyd.service.watchdog_usec": 0,
"system-state": 3,
"unit_states.chronyd.service.active_state": 1,
"unit_states.chronyd.service.loaded_state": 1,
"unit_states.chronyd.service.unhealthy": 0,
"units.active_units": 403,
"units.automount_units": 1,
"units.device_units": 150,
"units.failed_units": 0,
"units.inactive_units": 159,
"units.jobs_queued": 0,
"units.loaded_units": 497,
"units.masked_units": 25,
"units.mount_units": 52,
"units.not_found_units": 38,
"units.path_units": 4,
"units.scope_units": 17,
"units.service_units": 199,
"units.slice_units": 7,
"units.socket_units": 28,
"units.target_units": 54,
"units.timer_units": 20,
"units.total_units": 562,
"version": "255.7-1.fc40"
}
json-pretty
普通 serde_json
各个组件结构的美丽表示。
开发
进行测试运行(需要安装systemd
和systemd-networkd
已安装)
-
等待你在配置中启用的内容...
-
cargo运行 ---c monitord.conf -l debug
在提交PR(CI检查)之前确保以下通过
cargo测试
cargoclippy
cargofmt
生成代码生成API
cargo安装dbus-codegen
dbus-代码生成-rust-s-g-mNone -d org.freedesktop.systemd1-p/org/freedesktop/systemd1/unit/chronyd_2eservice>unit_dbus.rs
然后添加以下宏来告诉clippy离开
#![allow(warnings)]
#![allow(clippy)]
#![allow(unknown_lints)]
依赖项
~15–29MB
~412K SLoC