openwrt ubus在luci中的使用

ubus为openwrt平台开发中的进程间通信提供了一个通用的框架,它让进程间通信的实现变得非常简单。
同时ubus也作为Luci重要的组件,提供web界面和系统之间的信息沟通。
适用版本openwrt v19.07.4

  • 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

  • 例如:feeds/xluci2/luci2-base/htdocs/luci2/system.js中获取系统信息
getSystemInfo: L.rpc.declare({
		object: 'system',
		method: 'info',
		expect: { '': { } }
	}),

本质上是调用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
        }
}

知道以上关系,就可以进行luci界面调试了~~~


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值