Add v1/get/system/stats v1/get/host/mud REST API

This commit is contained in:
Alfredo Cardigliano 2020-05-18 17:46:50 +02:00
parent 5ebd5ad5c1
commit b266ab9335
8 changed files with 99 additions and 16 deletions

View file

@ -31,6 +31,17 @@ local host_stats_flows_num = _GET["limit"]
local host_info = url2hostinfo(_GET)
local ifid = _GET["ifid"]
-- parse interface names and possibly fall back to the selected interface:
-- priority goes to the interface id
if not isEmptyString(ifid) then
if_name = getInterfaceName(ifid)
-- finally, we fall back to the default selected interface name
else
print(rest_utils.rc(rest_utils.consts_invalid_interface))
return
end
local function flows2protocolthpt(flows)
local protocol_thpt = {}
for _, flow in pairs(flows) do
@ -58,17 +69,6 @@ local function flows2protocolthpt(flows)
return protocol_thpt
end
local ifid = _GET["ifid"]
-- parse interface names and possibly fall back to the selected interface:
-- priority goes to the interface id
if not isEmptyString(ifid) then
if_name = getInterfaceName(ifid)
-- finally, we fall back to the default selected interface name
else
print(rest_utils.rc(rest_utils.consts_invalid_interface))
return
end
if host_info["host"] then
interface.select(if_name)
local host = interface.getHostInfo(host_info["host"], host_info["vlan"])