mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Implements Autonomous Systems hash table
This commit is contained in:
parent
fa8b3f7f37
commit
5014669d12
22 changed files with 768 additions and 61 deletions
82
scripts/lua/get_ases_data.lua
Normal file
82
scripts/lua/get_ases_data.lua
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
--
|
||||
-- (C) 2013-17 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require "lua_utils"
|
||||
require "as_utils"
|
||||
|
||||
local json = require("dkjson")
|
||||
sendHTTPHeader('text/html; charset=iso-8859-1')
|
||||
|
||||
-- Table parameters
|
||||
local currentPage = _GET["currentPage"]
|
||||
local perPage = _GET["perPage"]
|
||||
local sortColumn = _GET["sortColumn"]
|
||||
local sortOrder = _GET["sortOrder"]
|
||||
|
||||
local sortPrefs = "asn"
|
||||
|
||||
if((sortColumn == nil) or (sortColumn == "column_"))then
|
||||
sortColumn = getDefaultTableSort(sortPrefs)
|
||||
else
|
||||
if((sortColumn ~= "column_")
|
||||
and (sortColumn ~= "")) then
|
||||
tablePreferences("sort_"..sortPrefs,sortColumn)
|
||||
end
|
||||
end
|
||||
|
||||
if(sortOrder == nil) then
|
||||
sortOrder = getDefaultTableSortOrder(sortPrefs)
|
||||
else
|
||||
if((sortColumn ~= "column_")
|
||||
and (sortColumn ~= "")) then
|
||||
tablePreferences("sort_order_"..sortPrefs,sortOrder)
|
||||
end
|
||||
end
|
||||
|
||||
if(currentPage == nil) then
|
||||
currentPage = 1
|
||||
else
|
||||
currentPage = tonumber(currentPage)
|
||||
end
|
||||
|
||||
if(perPage == nil) then
|
||||
perPage = getDefaultTableSize()
|
||||
else
|
||||
perPage = tonumber(perPage)
|
||||
tablePreferences("rows_number", perPage)
|
||||
end
|
||||
|
||||
interface.select(ifname)
|
||||
|
||||
to_skip = (currentPage-1) * perPage
|
||||
|
||||
if(sortOrder == "desc") then sOrder = false else sOrder = true end
|
||||
|
||||
local ases_stats = interface.getASesInfo(sortColumn, perPage, to_skip, sOrder,
|
||||
false --[[high, but not higher details as there's no need for nDPI here --]])
|
||||
|
||||
local total_rows = 0
|
||||
|
||||
if(ases_stats ~= nil) then
|
||||
total_rows = ases_stats["numASes"]
|
||||
end
|
||||
ases_stats = ases_stats["ASes"]
|
||||
|
||||
local res_formatted = {}
|
||||
|
||||
for _, as in ipairs(ases_stats) do
|
||||
local record = as2record(as)
|
||||
res_formatted[#res_formatted + 1] = record
|
||||
end
|
||||
|
||||
local result = {}
|
||||
result["perPage"] = perPage
|
||||
result["currentPage"] = currentPage
|
||||
result["totalRows"] = total_rows
|
||||
result["data"] = res_formatted
|
||||
result["sort"] = {{sortColumn, sortOrder}}
|
||||
|
||||
print(json.encode(result, nil))
|
||||
Loading…
Add table
Add a link
Reference in a new issue