Fixed traffic stats chart in flows

This commit is contained in:
Luca Deri 2021-04-01 13:49:46 +02:00
parent 7a5869f729
commit fe74fb4f14
4 changed files with 37 additions and 36 deletions

View file

@ -17,7 +17,7 @@ local rest_utils = require("rest_utils")
--
local flows_filter = getFlowsFilter()
local rc = rest_utils.consts.success.ok
local res = {}
local res
local ifid = _GET["ifid"]
@ -30,18 +30,6 @@ end
interface.select(ifid)
-- This is used to get the current bytes rcvd and sent by these specific filters
filtered_traffic_stats = interface.getFlowsTrafficStats(flows_filter["hostFilter"], flows_filter, true)
res["throughput_bps_sent"] = (filtered_traffic_stats["flows"]["totNewBytesSent"] - filtered_traffic_stats["flows"]["totOldBytesSent"]) / 5
res["throughput_bps_rcvd"] = (filtered_traffic_stats["flows"]["totNewBytesRcvd"] - filtered_traffic_stats["flows"]["totOldBytesRcvd"]) / 5
if res["throughput_bps_sent"] < 0 then
res["throughput_bps_sent"] = 0
end
if res["throughput_bps_rcvd"] < 0 then
res["throughput_bps_rcvd"] = 0
end
res = interface.getFlowsTrafficStats(flows_filter["hostFilter"], flows_filter, true)
rest_utils.answer(rc, res)