El uso de openwrt ubus en luci

Ubus proporciona un marco general para la comunicación entre procesos en el desarrollo de la plataforma openwrt, lo que simplifica la realización de la comunicación entre procesos.
Al mismo tiempo, ubus también es un componente importante de Luci, ya que proporciona comunicación de información entre la interfaz web y el sistema.
Versión aplicable openwrt v19.07.4

  • Comandos admitidos por 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

  • Por ejemplo: obtenga información del sistema de feeds / xluci2 / luci2-base / htdocs / luci2 / system.js
getSystemInfo: L.rpc.declare({
    
    
		object: 'system',
		method: 'info',
		expect: {
    
     '': {
    
     } }
	}),

Básicamente, llamar a la información del sistema de llamadas de ubus

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
        }
}

Conociendo la relación anterior, puede depurar la interfaz luci ~~~


Supongo que te gusta

Origin blog.csdn.net/pyt1234567890/article/details/109546684
Recomendado
Clasificación