Add yaml front matter to all asciidoc files
[web.git] / docs / ubus.txt
1 ---
2 ---
3 uBus IPC/RPC System
4 ===================
5
6 include::menu.inc[]
7
8 == uBus - IPC/RPC
9
10 uBus is the interconnect system used by most services running on a _LEDE_ setup.
11 Services can connect to the bus and provide methods that can be called by other services or clients.
12
13 There is a CLI that can be used to communicate with services on the bus.
14
15 ----
16 root@lede:/# ubus
17 Usage: ubus [<options>] <command> [arguments...]
18 Options:
19 -s <socket>: Set the unix domain socket to connect to
20 -t <timeout>: Set the timeout (in seconds) for a command to complete
21 -S: Use simplified output (for scripts)
22 -v: More verbose output
23
24 Commands:
25 - list [<path>] List objects
26 - call <path> <method> [<message>] Call an object method
27 - listen [<path>...] Listen for events
28 - send <type> [<message>] Send an event
29 - wait_for <object> [<object>...] Wait for multiple objects to appear on ubus
30 ----
31
32 To find out which services are currently running on the bus simply use the list command. This will show a complete list.
33
34 ----
35 root@lede:/# ubus list
36 dhcp
37 log
38 network
39 network.device
40 network.interface
41 network.interface.loopback
42 network.interface.wan
43 network.interface.wan6
44 network.wireless
45 service
46 system
47 ----
48
49 To find out which methods a specific service provides also use the list command but add a few more parameters to see a complete list
50
51 ----
52 root@OpenWrt:/# ubus -v list system
53 'system' @6b093875
54 "board":{}
55 "info":{}
56 "upgrade":{}
57 "watchdog":{"frequency":"Integer","timeout":"Integer","stop":"Boolean"}
58 "signal":{"pid":"Integer","signum":"Integer"}
59 ----
60
61 You can now call a remote method and receive a reply. A reply may be a simple integer return code or a more complete reply. Internally the bus uses a blob format, the CLI conveniently converts this to JSON.
62
63 ----
64 root@lede:/# ubus call system board
65 {
66 "kernel": "4.4.6",
67 "hostname": "lede",
68 "system": "MIPS Malta",
69 "release": {
70 "distribution": "LEDE",
71 "version": "HEAD",
72 "revision": "3",
73 "codename": "designated_driver",
74 "target": "malta\/le",
75 "description": "LEDE Designated Driver 3"
76 }
77 }
78 ----
79
80 You can call a method and pass it some parameters by simply appending a JSON structure to the CLI command.
81 ----
82 root@lede:/# ubus call system signal '{ "pid": 123, "signum": 9 }'
83 root@lede:/# echo $?
84 0
85 ----
86
87