You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过Salt的service.show指定要显示的服务属性?

能否用Salt的service.show仅显示指定服务属性?

不能直接通过salt <host> service.show <service>实现仅显示指定属性的功能。

Salt的service.show模块默认会返回目标服务的全部可用属性,没有提供类似systemctl show -p的参数来筛选特定字段。

替代方案

目前可行的方式是通过cmd.run直接调用原生的systemctl show命令来实现需求,具体命令如下:

salt <host> cmd.run "systemctl show -pId,ActiveState,ActiveEnterTimestamp <service>"

如果希望得到结构化的输出(比如JSON格式),可以给systemctl show添加--json参数优化结果:

salt <host> cmd.run "systemctl show -pId,ActiveState,ActiveEnterTimestamp --json <service>"

内容的提问来源于stack exchange,提问作者John Ross

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 05:24:49