Ubus » Historial » Versió 5
Roger Pueyo Centelles, 30-05-2014 20:23
1 | 1 | Roger Pueyo Centelles | h1. Ubus |
---|---|---|---|
2 | |||
3 | The [[NCd|Network Characterization daemon]] (NCd) uses "ubus":http://wiki.openwrt.org/doc/techref/ubus (the "OpenWrt":http://www.openwrt.org micro bus architecture) to communicate with the [[NCui|Network Characterization user interface]] and with other daemons and applications. This page documents the ubus namespace of the NC, with the available procedures and several examples. |
||
4 | |||
5 | h2. NCd ubus namespace and procedures summary |
||
6 | |||
7 | 4 | Roger Pueyo Centelles | h3. Local node information |
8 | 1 | Roger Pueyo Centelles | |
9 | 4 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
10 | 1 | Roger Pueyo Centelles | |\4=. | |
11 | 4 | Roger Pueyo Centelles | |ncd | [[Ubus#ncd-id|id]] | { } | Get the unique id of the local node. | |
12 | |ncd | [[Ubus#ncd-board|board]] | { } | Get the system information of the local node (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹| |
||
13 | |ncd | [[Ubus#ncd-info|info]] | { } | Get the system status of the local node (uptime, load, memory, etc.) ²| |
||
14 | |||
15 | 1 | Roger Pueyo Centelles | |ncd.node | [[Ubus#ncdnodeneighbours|neighbours]] | { "node" : "id" } | List all the neighbours of a specified node using its unique id. | |
16 | 4 | Roger Pueyo Centelles | |
17 | 1 | Roger Pueyo Centelles | |ncd.node.position | [[Ubus|get]] | { "nodes" : [ "id_1", "id_2", "id_3" ] } | Get the position (latitude and longitude) of the nodes. | |
18 | |ncd.node.position | [[Ubus|set]] | { "position" : [ "lat", "lon" ] } | Set the position (latitude and longitude) of the node. | |
||
19 | |ncd.node | [[Ubus|info]] | { "node" : "id" } | Get all the device-specific details of a node (hardware, software, interfaces, etc.) | |
||
20 | 4 | Roger Pueyo Centelles | |
21 | ¹ It is the same information provided by OpenWrt's _system board_ Ubus call |
||
22 | ¹ It is the same information provided by OpenWrt's _system info_ Ubus call |
||
23 | 1 | Roger Pueyo Centelles | |
24 | h3. Link-related information |
||
25 | |||
26 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
27 | |\4=. | |
||
28 | |ncd.link | link | { "nodes": [ "id_1", "id_2" ] } | Get the details of the link(s) between nodes id_1 and id_2. | |
||
29 | | | | | | |
||
30 | |||
31 | h2. Usage examples |
||
32 | |||
33 | 5 | Roger Pueyo Centelles | h3. ncd id |
34 | 1 | Roger Pueyo Centelles | |
35 | Request: |
||
36 | 3 | Roger Pueyo Centelles | |
37 | 5 | Roger Pueyo Centelles | @ubus call ncd id { }@ |
38 | 1 | Roger Pueyo Centelles | |
39 | Response: |
||
40 | 3 | Roger Pueyo Centelles | |
41 | 1 | Roger Pueyo Centelles | @{ "id" : "node_id" }@ |
42 | |||
43 | |
||
44 | |||
45 | |||
46 | 5 | Roger Pueyo Centelles | |
47 | |||
48 | h3. ncd board |
||
49 | |||
50 | 1 | Roger Pueyo Centelles | Request: |
51 | |||
52 | 5 | Roger Pueyo Centelles | @ubus call ncd board { }@ |
53 | 1 | Roger Pueyo Centelles | |
54 | Response: |
||
55 | |||
56 | 5 | Roger Pueyo Centelles | <pre> |
57 | { |
||
58 | "kernel": "3.10.36", |
||
59 | "hostname": "qMp-6a32", |
||
60 | "system": "Qualcomm Atheros QCA9533 rev 1", |
||
61 | "model": "TP-Link TL-WR841N\/ND v9", |
||
62 | "release": { |
||
63 | "distribution": "OpenWrt", |
||
64 | "version": "Bleeding Edge", |
||
65 | "revision": "r40831", |
||
66 | "codename": "barrier_breaker", |
||
67 | "target": "ar71xx\/generic", |
||
68 | "description": "OpenWrt Barrier Breaker r40831" |
||
69 | } |
||
70 | } |
||
71 | </pre> |
||
72 | 1 | Roger Pueyo Centelles | |
73 | |
||
74 | |||
75 | |||
76 | |||
77 | |||
78 | 5 | Roger Pueyo Centelles | h3. ncd info |
79 | |||
80 | 1 | Roger Pueyo Centelles | Request: |
81 | |||
82 | 5 | Roger Pueyo Centelles | @ubus call ncd info { }@ |
83 | 1 | Roger Pueyo Centelles | |
84 | Response: |
||
85 | |||
86 | 5 | Roger Pueyo Centelles | <pre> |
87 | { |
||
88 | "uptime": 9425, |
||
89 | "localtime": 1401464813, |
||
90 | "load": [ |
||
91 | 3264, |
||
92 | 10592, |
||
93 | 7648 |
||
94 | ], |
||
95 | "memory": { |
||
96 | "total": 29741056, |
||
97 | "free": 5259264, |
||
98 | "shared": 0, |
||
99 | "buffered": 2297856 |
||
100 | }, |
||
101 | "swap": { |
||
102 | "total": 0, |
||
103 | "free": 0 |
||
104 | } |
||
105 | } |
||
106 | </pre> |
||
107 | 1 | Roger Pueyo Centelles | |
108 | |
||
109 | |||
110 | 5 | Roger Pueyo Centelles | h3. ncd.node.neighbours |
111 | 1 | Roger Pueyo Centelles | |
112 | 5 | Roger Pueyo Centelles | Request: |
113 | |||
114 | @ncd.node.neighbours { "node" : "id" }@ |
||
115 | 1 | Roger Pueyo Centelles | |
116 | 5 | Roger Pueyo Centelles | Response: |
117 | |||
118 | @{ "nodes" : [ "id_1", "id_2", "id_3" ] }@ |
||
119 | |||
120 | |
||
121 | |||
122 | |||
123 | |||
124 | |||
125 | |||
126 | |||
127 | |||
128 | 1 | Roger Pueyo Centelles | h3. ncd.node.info |
129 | |||
130 | Request: |
||
131 | |||
132 | @ncd.node.info { "node" : "id" }@ |
||
133 | |||
134 | Response: |
||
135 | |||
136 | <pre> |
||
137 | { |
||
138 | "nodeinfo": { |
||
139 | "id": "node016", |
||
140 | "name": "FT-NarrowStreet1616-NSLM5", |
||
141 | "hardware": { |
||
142 | "model": "Ubiquiti Nanostation M", |
||
143 | "type": "Atheros AR7241 rev 1", |
||
144 | "cpu": "MIPS 24Kc V7.4", |
||
145 | "ram": "29312" |
||
146 | }, |
||
147 | "software": { |
||
148 | "os": { |
||
149 | "name": "OpenWrt", |
||
150 | "version": 12.09, |
||
151 | "codename": "Attitude Adjustment", |
||
152 | "date": "2013-09-06", |
||
153 | "revision": "r38347" |
||
154 | }, |
||
155 | "qMp": { |
||
156 | "version": "3.0-rc3", |
||
157 | "codename": "Clearance", |
||
158 | "date": 20140227, |
||
159 | "revision": "d94713e", |
||
160 | "branch": "master" |
||
161 | }, |
||
162 | "bmx6": { |
||
163 | "revision": "bae36ab0", |
||
164 | "version": 12, |
||
165 | "branch": "master" |
||
166 | }, |
||
167 | "ncd": { |
||
168 | "revision": "36aaed94", |
||
169 | "version": 0.2, |
||
170 | "branch": "dev" |
||
171 | } |
||
172 | }, |
||
173 | "interfaces": { |
||
174 | "physical": { |
||
175 | "wired": { |
||
176 | "eth0": { |
||
177 | "mac": "DC:9F:DB:4F:A1:F6", |
||
178 | "encap": "Ethernet", |
||
179 | "mode": "100baseTX", |
||
180 | "mtu": 1500 |
||
181 | }, |
||
182 | "eth1": { |
||
183 | "mac": "DE:9F:DB:4F:A1:F6", |
||
184 | "encap": "Ethernet", |
||
185 | "mode": "down", |
||
186 | "mtu": 1500 |
||
187 | } |
||
188 | }, |
||
189 | "wireless": { |
||
190 | "radio0": { |
||
191 | "type": "mac80211", |
||
192 | "mac": "DC:9F:DB:4E:A1:F6", |
||
193 | "hwmode": "auto", |
||
194 | "channel": 124, |
||
195 | "country": "SP", |
||
196 | "txpower": 17, |
||
197 | "distance": 5000, |
||
198 | "ht": [ |
||
199 | "SHORT-GI-40", |
||
200 | "RX-STBC1", |
||
201 | "DSSS_CCK-40" |
||
202 | ], |
||
203 | "interfaces": { |
||
204 | "wlan0": { |
||
205 | "device": "radio0", |
||
206 | "mode": "adhoc", |
||
207 | "bssid": "02:CA:FF:EE:BA:BE", |
||
208 | "ssid": "qMp-HWErmitaBellvitge16", |
||
209 | "encryption": "open", |
||
210 | "network": "lan", |
||
211 | "ifname": "wlan0", |
||
212 | "stations": { |
||
213 | "dc:9f:db:34:17:b6": { |
||
214 | "signal": [ |
||
215 | -70, |
||
216 | -74, |
||
217 | -73 |
||
218 | ], |
||
219 | "avgsignal": [ |
||
220 | -70, |
||
221 | -74, |
||
222 | -73 |
||
223 | ], |
||
224 | "txbitrate": "60.0 MBit/s MCS 9 40Mhz short GI", |
||
225 | "rxbitrate": "81.0 MBit/s MCS 4 40Mhz" |
||
226 | } |
||
227 | } |
||
228 | } |
||
229 | } |
||
230 | } |
||
231 | } |
||
232 | }, |
||
233 | "virtual": { |
||
234 | "lo": { |
||
235 | "type": "loopback", |
||
236 | "addressing": { |
||
237 | "ipv4": [ |
||
238 | { |
||
239 | "ipaddr": "127.0.0.1", |
||
240 | "netmask": "255.0.0.0" |
||
241 | } |
||
242 | ], |
||
243 | "ipv6": [ |
||
244 | { |
||
245 | "ipaddr6": "::1/128", |
||
246 | "scope": "host" |
||
247 | } |
||
248 | ] |
||
249 | } |
||
250 | }, |
||
251 | "br-lan": { |
||
252 | "type": "bridge", |
||
253 | "ifname": [ |
||
254 | "eth0" |
||
255 | ], |
||
256 | "addressing": { |
||
257 | "ipv4": [ |
||
258 | { |
||
259 | "ipaddr": "10.1.32.33", |
||
260 | "netmask": "255.255.255.224" |
||
261 | }, |
||
262 | { |
||
263 | "ipaddr": "169.254.246.1", |
||
264 | "netmask": "255.255.255.248" |
||
265 | } |
||
266 | ], |
||
267 | "ipv6": [ |
||
268 | { |
||
269 | "scope": "global", |
||
270 | "ipaddr6": "fd00:1714:1714:a1f6::1/64" |
||
271 | }, |
||
272 | { |
||
273 | "scope": "link", |
||
274 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
275 | } |
||
276 | ] |
||
277 | } |
||
278 | }, |
||
279 | "br-lan.12": { |
||
280 | "type": "vlan", |
||
281 | "ifname": [ |
||
282 | "eth0" |
||
283 | ], |
||
284 | "addressing": { |
||
285 | "ipv6": [ |
||
286 | { |
||
287 | "scope": "global", |
||
288 | "ipaddr6": "fd66:66:66:8:de9f:dbff:fe4f:a1f6/64" |
||
289 | }, |
||
290 | { |
||
291 | "scope": "global", |
||
292 | "ipaddr6": "fd02::dc9f:db4f:a1f6:0:112/128" |
||
293 | }, |
||
294 | { |
||
295 | "scope": "link", |
||
296 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
297 | } |
||
298 | ] |
||
299 | } |
||
300 | }, |
||
301 | "wlan0": { |
||
302 | "type": "wireless", |
||
303 | "ifname": "radio0", |
||
304 | "addressing": { |
||
305 | "ipv4": [ |
||
306 | { |
||
307 | "ipaddr": "169.254.246.1", |
||
308 | "netmask": "255.255.255.248" |
||
309 | }, |
||
310 | { |
||
311 | "ipaddr": "10.1.32.33", |
||
312 | "netmask": "255.255.255.224" |
||
313 | } |
||
314 | ], |
||
315 | "ipv6": [ |
||
316 | { |
||
317 | "scope": "link", |
||
318 | "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" |
||
319 | }, |
||
320 | { |
||
321 | "scope": "global", |
||
322 | "ipaddr6": "fd00:1714:1714:a1f6::1/64" |
||
323 | }, |
||
324 | { |
||
325 | "scope": "link", |
||
326 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
327 | } |
||
328 | ] |
||
329 | } |
||
330 | }, |
||
331 | "wlan0.12": { |
||
332 | "type": "vlan", |
||
333 | "ifname": "radio0", |
||
334 | "addressing": { |
||
335 | "ipv6": [ |
||
336 | { |
||
337 | "scope": "link", |
||
338 | "ipaddr6": "fd66:66:66:a:de9f:dbff:fe4e:a1f6/64" |
||
339 | }, |
||
340 | { |
||
341 | "scope": "global", |
||
342 | "ipaddr6": "fd02::dc9f:db4f:a1f6:0:212/128" |
||
343 | }, |
||
344 | { |
||
345 | "scope": "link", |
||
346 | "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" |
||
347 | } |
||
348 | ] |
||
349 | } |
||
350 | }, |
||
351 | "bmxtmain": { |
||
352 | "type": "tunnel6", |
||
353 | "addressing": { |
||
354 | "ipv4": [ |
||
355 | { |
||
356 | "ipaddr": "10.1.32.33", |
||
357 | "netmask": "255.255.255.224" |
||
358 | } |
||
359 | ], |
||
360 | "ipv6": [ |
||
361 | { |
||
362 | "scope": "global", |
||
363 | "ipaddr6": "2012:0:0:a1f6::1/128" |
||
364 | }, |
||
365 | { |
||
366 | "scope": "link", |
||
367 | "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" |
||
368 | } |
||
369 | ] |
||
370 | } |
||
371 | } |
||
372 | } |
||
373 | } |
||
374 | } |
||
375 | } |
||
376 | </pre> |
||
377 | |||
378 | |
||
379 | |||
380 | h2. More examples |
||
381 | |||
382 | There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]]. |