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