mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Reworked host traffic page adding vue
This commit is contained in:
parent
7e3562f1c4
commit
7692a0aa3d
10 changed files with 399 additions and 115 deletions
54
scripts/lua/rest/v2/get/host/l4/traffic_data.lua
Normal file
54
scripts/lua/rest/v2/get/host/l4/traffic_data.lua
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
--
|
||||
-- (C) 2013-22 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
-- Imports
|
||||
require "lua_utils"
|
||||
local graph_utils = require "graph_utils"
|
||||
local rest_utils = require "rest_utils"
|
||||
|
||||
-- Local variables
|
||||
|
||||
local ifid = _GET["ifid"] or interface.getId()
|
||||
local host_ip = _GET["host"]
|
||||
local host_vlan = _GET["vlan"] or 0
|
||||
interface.select(tostring(ifid))
|
||||
|
||||
local host = interface.getHostInfo(host_ip, host_vlan)
|
||||
local total_bytes_rcvd = 0
|
||||
local total_bytes_sent = 0
|
||||
local colors = {}
|
||||
|
||||
if host then
|
||||
for id, _ in ipairs(l4_keys) do
|
||||
local key = l4_keys[id][2]
|
||||
local traffic = 0
|
||||
|
||||
if(host[key..".bytes.sent"] ~= nil) then
|
||||
traffic = traffic + host[key..".bytes.sent"]
|
||||
total_bytes_sent = total_bytes_sent + host[key..".bytes.sent"]
|
||||
end
|
||||
|
||||
if(host[key..".bytes.rcvd"] ~= nil) then
|
||||
traffic = traffic + host[key..".bytes.rcvd"]
|
||||
total_bytes_rcvd = total_bytes_rcvd + host[key..".bytes.rcvd"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)
|
||||
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)
|
||||
|
||||
-- Bytes sent vs Bytes rcvd
|
||||
local rsp = {
|
||||
["series"] = { total_bytes_sent, total_bytes_rcvd },
|
||||
["labels"] = { i18n("traffic_page.bytes_sent"), i18n("traffic_page.bytes_rcvd") },
|
||||
["colors"] = colors -- Still two colors like the second serie, reuse it
|
||||
}
|
||||
|
||||
-- ##################################
|
||||
|
||||
rest_utils.answer(rest_utils.consts.success.ok, rsp)
|
||||
Loading…
Add table
Add a link
Reference in a new issue