【sdbusplus系列】busctl的使用

前言

本文章介绍busctl命令的使用。

busctl命令

busctl -h

~# busctl -h
busctl [OPTIONS...] COMMAND ...

Introspect the D-Bus IPC bus.

Commands:
  list                     List bus names
  status [SERVICE]         Show bus service, process or bus owner credentials
  monitor [SERVICE...]     Show bus traffic
  capture [SERVICE...]     Capture bus traffic as pcap
  tree [SERVICE...]        Show object tree of service
  introspect SERVICE OBJECT [INTERFACE]
  call SERVICE OBJECT INTERFACE METHOD [SIGNATURE [ARGUMENT...]]
                           Call a method
  emit OBJECT INTERFACE SIGNAL [SIGNATURE [ARGUMENT...]]
                           Emit a signal
  get-property SERVICE OBJECT INTERFACE PROPERTY...
                           Get property value
  set-property SERVICE OBJECT INTERFACE PROPERTY SIGNATURE ARGUMENT...
                           Set property value
  help                     Show this help

Options:
  -h --help                Show this help
     --version             Show package version
     --no-pager            Do not pipe output into a pager
     --no-legend           Do not show the headers and footers
  -l --full                Do not ellipsize output
     --system              Connect to system bus
     --user                Connect to user bus
  -H --host=[USER@]HOST    Operate on remote host
  -M --machine=CONTAINER   Operate on local container
     --address=ADDRESS     Connect to bus specified by address
     --show-machine        Show machine ID column in list
     --unique              Only show unique names
     --acquired            Only show acquired names
     --activatable         Only show activatable names
     --match=MATCH         Only show matching messages
     --size=SIZE           Maximum length of captured packet
     --list                Don't show tree, but simple object path list
  -q --quiet               Don't show method call reply
     --verbose             Show result values in long format
     --json=MODE           Output as JSON
  -j                       Same as --json=pretty on tty, --json=short otherwise
     --expect-reply=BOOL   Expect a method call reply
     --auto-start=BOOL     Auto-start destination service
     --allow-interactive-authorization=BOOL
                           Allow interactive authorization for operation
     --timeout=SECS        Maximum time to wait for method call completion
     --augment-creds=BOOL  Extend credential data with data read from /proc/$PID
     --watch-bind=BOOL     Wait for bus AF_UNIX socket to be bound in the file
                           system
     --destination=SERVICE Destination service of a signal

See the busctl(1) man page for details.

busctl list

命令格式:busctl list

~# busctl list
NAME                                              PID PROCESS         USER             CONNECTION    UNIT                                                                SESSION DESCRIPTION
:1.0                                              220 systemd-resolve systemd-resolve  :1.0          systemd-resolved.service                                            -       -
:1.1                                              222 systemd-timesyn systemd-timesync :1.1          systemd-timesyncd.service                                           -       -
:1.10                                             242 snoopd          root             :1.10         lpcsnoop.service                                                    -       -
:1.103                                            807 phosphor-log-ma root             :1.103        xyz.openbmc_project.Logging.service                                 -       -
:1.104                                            805 phosphor-fru-fa root             :1.104        obmc-fru-fault-monitor.service                                      -       -
:1.106                                            828 sel-logger      root             :1.106        xyz.openbmc_project.Logging.IPMI.service                            -       -
:1.113                                            888 phosphor-image- root             :1.113        xyz.openbmc_project.Software.BMC.Updater.service                    -       -
...

busctl tree

命令格式:busctl tree [SERVICE]

~# busctl tree com.intel.crashdump
`-/com
  `-/com/intel
    `-/com/intel/crashdump

busctl tree后面不加service时,将返回所有service对象的信息。

busctl introspect

命令格式:busctl introspect SERVICE OBJECT [INTERFACE]

~# busctl introspect com.intel.crashdump /com/intel/crashdump
NAME                                     TYPE      SIGNATURE  RESULT/VALUE  FLAGS
com.intel.crashdump.OnDemand             interface -          -             -
.GenerateOnDemandLog                     method    -          s             -
com.intel.crashdump.SendRawPeci          interface -          -             -
.SendRawPeci                             method    aay        aay           -
com.intel.crashdump.Stored               interface -          -             -
.GenerateStoredLog                       method    s          s             -
com.intel.crashdump.Telemetry            interface -          -             -
.GenerateTelemetryLog                    method    -          s             -
org.freedesktop.DBus.Introspectable      interface -          -             -
.Introspect                              method    -          s             -
org.freedesktop.DBus.ObjectManager       interface -          -             -
.GetManagedObjects                       method    -          a{oa{sa{sv}}} -
.InterfacesAdded                         signal    oa{sa{sv}} -             -
.InterfacesRemoved                       signal    oas        -             -
org.freedesktop.DBus.Peer                interface -          -             -
.GetMachineId                            method    -          s             -
.Ping                                    method    -          -             -
org.freedesktop.DBus.Properties          interface -          -             -
.Get                                     method    ss         v             -
.GetAll                                  method    s          a{sv}         -
.Set                                     method    ssv        -             -
.PropertiesChanged                       signal    sa{sv}as   -             -
xyz.openbmc_project.Collection.DeleteAll interface -          -             -
.DeleteAll                               method    -          s             -

也可以指定interface查看信息

~# busctl introspect com.intel.crashdump /com/intel/crashdump xyz.openbmc_project.Collection.DeleteAll
NAME                                     TYPE      SIGNATURE RESULT/VALUE FLAGS
.DeleteAll                               method    -         s            -

busctl call

命令格式:busctl call SERVICE OBJECT INTERFACE METHOD [SIGNATURE [ARGUMENT…]]

~# busctl introspect com.intel.crashdump /com/intel/crashdump xyz.openbmc_project.Collection.DeleteAll
NAME                                     TYPE      SIGNATURE RESULT/VALUE FLAGS
.DeleteAll                               method    -         s            -
~# busctl call  com.intel.crashdump /com/intel/crashdump xyz.openbmc_project.Collection.DeleteAll DeleteAll
s "Logs Cleared"
~# 
~# busctl introspect com.intel.crashdump /com/intel/crashdump com.intel.crashdump.Stored
NAME                       TYPE      SIGNATURE RESULT/VALUE FLAGS
.GenerateStoredLog         method    s         s            -
busctl call com.intel.crashdump /com/intel/crashdump com.intel.crashdump.Stored GenerateStoredLog s "cpuError"
s "Log Started"
~# busctl call xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper GetSubTree sias "/xyz/openbmc_project/inventory/system/diskbackplane" 0 1 "xyz.openbmc_peoject.Configuration.INSPUR_HSBP_CPLD"
a{sa{sas}} 0

busctl get-property

命令格式:busctl get-property SERVICE OBJECT INTERFACE PROPERTY

~# busctl get-property xyz.openbmc_project.Network /xyz/openbmc_project/network/bond1 xyz.openbmc_project.Network.EthernetInterface StaticNTPServers
as 2 "1.1.1.1" "1.1.1.2"

busctl set-property

命令格式:busctl set-property SERVICE OBJECT INTERFACE PROPERTY SIGNATURE ARGUMENT

~# busctl set-property xyz.openbmc_project.Network /xyz/openbmc_project/network/bond1 xyz.openbmc_project.Network.EthernetInterface StaticNTPServers as 2 "1.1.1.1" "1.1.1.2"
~# 

busctl monitor

命令格式:busctl monitor [SERVICE…]

~# busctl monitor --match=sender='com.intel.crashdump'
> Type=method_call  Endian=l  Flags=0  Version=1 Cookie=15  Timestamp="Wed 2023-10-25 11:46:02.185711 UTC"
  Sender=:1.11  Destination=org.freedesktop.DBus  Path=/org/freedesktop/DBus  Interface=org.freedesktop.DBus  Member=GetConnectionUnixUser
  UniqueName=:1.11
  MESSAGE "s" {
          STRING ":1.297";
  };
> Type=method_return  Endian=l  Flags=1  Version=1 Cookie=16  ReplyCookie=2  Timestamp="Wed 2023-10-25 11:46:02.225580 UTC"
  Sender=:1.11  Destination=:1.297
  UniqueName=:1.11
  MESSAGE "s" {
          STRING "Log Started";
  };
s "Log Started"
...

sbus-send命令

详细可参考官方文档:https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md

~# dbus-send --system --print-reply --dest=xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper.GetSubTreePaths string:"/" int32:0 array:string:"xyz.openbmc_project.Logging.Entry"
method return time=1700189958.723444 sender=:1.24 -> destination=:1.46011 serial=871984 reply_serial=2
   array [
      string "/xyz/openbmc_project/logging/entry/1"
      string "/xyz/openbmc_project/logging/entry/10"
      string "/xyz/openbmc_project/logging/entry/11"
      string "/xyz/openbmc_project/logging/entry/2"
      string "/xyz/openbmc_project/logging/entry/3"
      string "/xyz/openbmc_project/logging/entry/4"
      string "/xyz/openbmc_project/logging/entry/5"
      string "/xyz/openbmc_project/logging/entry/6"
      string "/xyz/openbmc_project/logging/entry/7"
      string "/xyz/openbmc_project/logging/entry/8"
      string "/xyz/openbmc_project/logging/entry/9"
   ]

可参考:https://blog.csdn.net/yeiris/article/details/124356843?ops_request_misc=&request_id=&biz_id=102&utm_term=dbus%20mapper&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-1-124356843.142v91insertT0,239v12control2&spm=1018.2226.3001.4187

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值