Ubus » Historial » Revisió 5
Revisió 4 (Roger Pueyo Centelles, 30-05-2014 20:06) → Revisió 5/31 (Roger Pueyo Centelles, 30-05-2014 20:23)
h1. Ubus 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. h2. NCd ubus namespace and procedures summary h3. Local node information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd | [[Ubus#ncd-id|id]] | { } | Get the unique id of the local node. | |ncd | [[Ubus#ncd-board|board]] | { } | Get the system information of the local node (model, CPU, OpenWrt version, hostname, kernel version, etc.) ¹| |ncd | [[Ubus#ncd-info|info]] | { } | Get the system status of the local node (uptime, load, memory, etc.) ²| |ncd.node | [[Ubus#ncdnodeneighbours|neighbours]] | { "node" : "id" } | List all the neighbours of a specified node using its unique id. | |ncd.node.position | [[Ubus|get]] | { "nodes" : [ "id_1", "id_2", "id_3" ] } | Get the position (latitude and longitude) of the nodes. | |ncd.node.position | [[Ubus|set]] | { "position" : [ "lat", "lon" ] } | Set the position (latitude and longitude) of the node. | |ncd.node | [[Ubus|info]] | { "node" : "id" } | Get all the device-specific details of a node (hardware, software, interfaces, etc.) | ¹ It is the same information provided by OpenWrt's _system board_ Ubus call ¹ It is the same information provided by OpenWrt's _system info_ Ubus call h3. Link-related information |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.link | link | { "nodes": [ "id_1", "id_2" ] } | Get the details of the link(s) between nodes id_1 and id_2. | | | | | | h2. Usage examples h3. ncd id ncd.node.id Request: @ubus call ncd id @ncd.id { }@ Response: @{ "id" : "node_id" }@ h3. ncd board ncd.node.neighbours Request: @ubus call ncd board @ncd.node.neighbours { "node" : "id" }@ Response: <pre> { "kernel": "3.10.36", "hostname": "qMp-6a32", "system": "Qualcomm Atheros QCA9533 rev 1", "model": "TP-Link TL-WR841N\/ND v9", "release": { "distribution": "OpenWrt", "version": "Bleeding Edge", "revision": "r40831", "codename": "barrier_breaker", "target": "ar71xx\/generic", "description": "OpenWrt Barrier Breaker r40831" } } </pre> h3. ncd info Request: @ubus call ncd info { @{ "nodes" : [ "id_1", "id_2", "id_3" ] }@ Response: <pre> { "uptime": 9425, "localtime": 1401464813, "load": [ 3264, 10592, 7648 ], "memory": { "total": 29741056, "free": 5259264, "shared": 0, "buffered": 2297856 }, "swap": { "total": 0, "free": 0 } } </pre> h3. ncd.node.neighbours ncd.node.name Request: @ncd.node.neighbours @ncd.node.name { "node" "nodes" : "id" [ "id_1", "id_2", "id_3" ] }@ Response: @{ "nodes" "name" : [ "id_1", "id_2", "id_3" "Name001", "Name002", "Name003" ] }@ h3. ncd.node.info Request: @ncd.node.info { "node" : "id" }@ Response: <pre> { "nodeinfo": { "id": "node016", "name": "FT-NarrowStreet1616-NSLM5", "hardware": { "model": "Ubiquiti Nanostation M", "type": "Atheros AR7241 rev 1", "cpu": "MIPS 24Kc V7.4", "ram": "29312" }, "software": { "os": { "name": "OpenWrt", "version": 12.09, "codename": "Attitude Adjustment", "date": "2013-09-06", "revision": "r38347" }, "qMp": { "version": "3.0-rc3", "codename": "Clearance", "date": 20140227, "revision": "d94713e", "branch": "master" }, "bmx6": { "revision": "bae36ab0", "version": 12, "branch": "master" }, "ncd": { "revision": "36aaed94", "version": 0.2, "branch": "dev" } }, "interfaces": { "physical": { "wired": { "eth0": { "mac": "DC:9F:DB:4F:A1:F6", "encap": "Ethernet", "mode": "100baseTX", "mtu": 1500 }, "eth1": { "mac": "DE:9F:DB:4F:A1:F6", "encap": "Ethernet", "mode": "down", "mtu": 1500 } }, "wireless": { "radio0": { "type": "mac80211", "mac": "DC:9F:DB:4E:A1:F6", "hwmode": "auto", "channel": 124, "country": "SP", "txpower": 17, "distance": 5000, "ht": [ "SHORT-GI-40", "RX-STBC1", "DSSS_CCK-40" ], "interfaces": { "wlan0": { "device": "radio0", "mode": "adhoc", "bssid": "02:CA:FF:EE:BA:BE", "ssid": "qMp-HWErmitaBellvitge16", "encryption": "open", "network": "lan", "ifname": "wlan0", "stations": { "dc:9f:db:34:17:b6": { "signal": [ -70, -74, -73 ], "avgsignal": [ -70, -74, -73 ], "txbitrate": "60.0 MBit/s MCS 9 40Mhz short GI", "rxbitrate": "81.0 MBit/s MCS 4 40Mhz" } } } } } } }, "virtual": { "lo": { "type": "loopback", "addressing": { "ipv4": [ { "ipaddr": "127.0.0.1", "netmask": "255.0.0.0" } ], "ipv6": [ { "ipaddr6": "::1/128", "scope": "host" } ] } }, "br-lan": { "type": "bridge", "ifname": [ "eth0" ], "addressing": { "ipv4": [ { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" }, { "ipaddr": "169.254.246.1", "netmask": "255.255.255.248" } ], "ipv6": [ { "scope": "global", "ipaddr6": "fd00:1714:1714:a1f6::1/64" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "br-lan.12": { "type": "vlan", "ifname": [ "eth0" ], "addressing": { "ipv6": [ { "scope": "global", "ipaddr6": "fd66:66:66:8:de9f:dbff:fe4f:a1f6/64" }, { "scope": "global", "ipaddr6": "fd02::dc9f:db4f:a1f6:0:112/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "wlan0": { "type": "wireless", "ifname": "radio0", "addressing": { "ipv4": [ { "ipaddr": "169.254.246.1", "netmask": "255.255.255.248" }, { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" } ], "ipv6": [ { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" }, { "scope": "global", "ipaddr6": "fd00:1714:1714:a1f6::1/64" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } }, "wlan0.12": { "type": "vlan", "ifname": "radio0", "addressing": { "ipv6": [ { "scope": "link", "ipaddr6": "fd66:66:66:a:de9f:dbff:fe4e:a1f6/64" }, { "scope": "global", "ipaddr6": "fd02::dc9f:db4f:a1f6:0:212/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4e:a1f6/64" } ] } }, "bmxtmain": { "type": "tunnel6", "addressing": { "ipv4": [ { "ipaddr": "10.1.32.33", "netmask": "255.255.255.224" } ], "ipv6": [ { "scope": "global", "ipaddr6": "2012:0:0:a1f6::1/128" }, { "scope": "link", "ipaddr6": "fe80::de9f:dbff:fe4f:a1f6/64" } ] } } } } } } </pre> h2. More examples There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].