The use of openwrt ubus in luci

Ubus provides a general framework for inter-process communication in the development of openwrt platform, which makes the realization of inter-process communication very simple.
At the same time, ubus is also an important component of Luci, providing information communication between the web interface and the system.
Applicable version openwrt v19.07.4

  • Commands supported by ubus
root@Eric:/# ubus
Usage: ubus [<options>] <command> [arguments...]
Options:
 -s <socket>:           Set the unix domain socket to connect to
 -t <timeout>:          Set the timeout (in seconds) for a command to complete
 -S:                    Use simplified output (for scripts)
 -v:                    More verbose output
 -m <type>:             (for monitor): include a specific message type
                        (can be used more than once)
 -M <r|t>               (for monitor): only capture received or transmitted traffic

Commands:
 - list [<path>]                        List objects
 - call <path> <method> [<message>]     Call an object method
 - listen [<path>...]                   Listen for events
 - send <type> [<message>]              Send an event
 - wait_for <object> [<object>...]      Wait for multiple objects to appear on ubus
 - monitor                              Monitor ubus traffic

  • For example: get system information from feeds/xluci2/luci2-base/htdocs/luci2/system.js
getSystemInfo: L.rpc.declare({
    
    
		object: 'system',
		method: 'info',
		expect: {
    
     '': {
    
     } }
	}),

Essentially calling ubus call system info

root@Eric:/# ubus call system info
{
    
    
        "localtime": 1599411007,
        "uptime": 1838,
        "load": [
                24736,
                15552,
                12384
        ],
        "memory": {
    
    
                "total": 60755968,
                "free": 33140736,
                "shared": 143360,
                "buffered": 2838528,
                "available": 26689536,
                "cached": 7913472
        },
        "swap": {
    
    
                "total": 0,
                "free": 0
        }
}

Knowing the above relationship, you can debug the luci interface~~~


Guess you like

Origin blog.csdn.net/pyt1234567890/article/details/109546684