diff --git a/libremap-agent/Makefile b/libremap-agent/Makefile index a2009be..aadf27b 100644 --- a/libremap-agent/Makefile +++ b/libremap-agent/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libremap-agent -PKG_RELEASE:=0.1.8 +PKG_RELEASE:=0.1.8.1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk @@ -75,6 +75,7 @@ $(eval $(call BuildPlugin,system,system,)) $(eval $(call BuildPlugin,wireless,wireless,)) $(eval $(call BuildPlugin,babel,babel,)) $(eval $(call BuildPlugin,bmx6,bmx6,)) +$(eval $(call BuildPlugin,qmp,qmp,)) define Package/libremap-agent SECTION:=utilities diff --git a/libremap-agent/files/etc/uci-defaults/80_libremap-agent b/libremap-agent/files/etc/uci-defaults/80_libremap-agent index 635a56c..21f0b40 100755 --- a/libremap-agent/files/etc/uci-defaults/80_libremap-agent +++ b/libremap-agent/files/etc/uci-defaults/80_libremap-agent @@ -71,6 +71,9 @@ config plugin 'babel' config plugin 'bmx6' option enabled '0' + +config plugin 'qmp' + option enabled '0' EOF } diff --git a/libremap-agent/luasrc/libremap/plugins/qmp.lua b/libremap-agent/luasrc/libremap/plugins/qmp.lua new file mode 100644 index 0000000..1910b98 --- /dev/null +++ b/libremap-agent/luasrc/libremap/plugins/qmp.lua @@ -0,0 +1,29 @@ +--[[ + +Copyright 2017 Roger Pueyo Centelles + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +local uci = (require 'uci').cursor() + +function insert(doc, options) + -- get values from qMp config + local community_name = tostring(uci:get('qmp', 'node', 'community_name')) + local mesh_name = tostring(uci:get('qmp', 'node', 'mesh_name')) + local device_id = tostring(uci:get('qmp', 'node', 'device_id')) + + -- store in doc + doc.community_name = community_name + doc.mesh_name = mesh_name + doc.device_id = device_id +end + +return { + insert = insert +} diff --git a/libremap-agent/luasrc/libremap/plugins/system.lua b/libremap-agent/luasrc/libremap/plugins/system.lua index 6539542..fce78d0 100644 --- a/libremap-agent/luasrc/libremap/plugins/system.lua +++ b/libremap-agent/luasrc/libremap/plugins/system.lua @@ -11,16 +11,19 @@ http://www.apache.org/licenses/LICENSE-2.0 ]]-- -sys = require 'luci.sys' +sys = require 'luci.sys' +util = require 'luci.util' return { insert = function(doc, options) - local name, model, memtotal = sys.sysinfo() - local system = { - name = name:match('[^\n]+'), - model = model:match('[^\n]+'), - memtotal = memtotal - } + local sysinfo = util.ubus("system", "info") or { } + local sysboard = util.ubus("system", "board") or { } + + local system = { } + system["name"] = sysinfo["hostname"] + system["model"] = sysboard["system"] + system["memtotal"] = sysinfo["memory"]["total"] + doc.attributes = doc.attributes or {} doc.attributes.system = system end