Cleanup old fontawesome 4 and bootstrap 3

This commit is contained in:
Simone Mainardi 2019-12-09 15:35:39 +01:00
parent 7402bbdd14
commit b5ba28d8d1
55 changed files with 0 additions and 14 deletions

View file

@ -0,0 +1,23 @@
--
-- (C) 2013-18 - ntop.org
--
-- This page is requested by grafana Simple JSON plugin when testing the datasource
-- datasource test involes a request to / that is mapped by ntopng to index.lua
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "grafana_utils"
local json = require("dkjson")
if isCORSpreflight() then
processCORSpreflight()
else
local corsr = {}
corsr["Access-Control-Allow-Origin"] = _SERVER["Origin"]
sendHTTPHeader('application/json', nil, corsr)
print(json.encode({status="OK"}, nil))
end

View file

@ -0,0 +1,121 @@
--
-- (C) 2013-18 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "graph_utils"
require "grafana_utils"
local ts_utils = require("ts_utils")
interface.select(ifname)
local ifnames = interface.getIfNames()
if isCORSpreflight() then
processCORSpreflight()
else
local corsr = {}
corsr["Access-Control-Allow-Origin"] = _SERVER["Origin"]
sendHTTPHeader('application/json', nil, corsr)
local epoch_begin = toEpoch(_POST["payload"]["range"]["from"])
local epoch_end = toEpoch(_POST["payload"]["range"]["to"])
-- override max_num_points in singlerrd2json
global_max_num_points = _POST["payload"]["maxDataPoints"]
if global_max_num_points > 600 then
global_max_num_points = 600
end
local res = {}
for _, t in pairs(_POST["payload"]["targets"]) do
if t["target"] == nil then t["target"] = "" end
local is_host = string.starts(t["target"] or '', "host_")
local addr
if is_host then
addr = string.match(t["target"], "_(.-)_") -- host address is between the first two underscores
t["target"] = string.gsub(t["target"], "host_(.-)_", "")
end
local is_traffic = string.ends(t["target"], "_traffic_bps") or string.ends(t["target"], "_traffic_total_bytes")
local is_packets = string.ends(t["target"], "_traffic_pps") or string.ends(t["target"], "_traffic_total_packets")
local is_allprotos = string.ends(t["target"], "_allprotocols_bps")
local is_allcategories = string.ends(t["target"], "_allcategories_bps")
local ifname = string.gsub(t["target"], "^(.-)_", "") -- lazy match to remove up to the first underscore
ifname = string.gsub(ifname, "_(.-)$", "") -- lazy match to remove up to the last underscore
local schema = nil
local is_topk = false
if is_traffic then
if is_host then schema = "host:traffic" else schema = "iface:traffic" end
elseif is_packets then schema = "iface:packets"
elseif is_allprotos then
if is_host then schema = "host:ndpi" else schema = "iface:ndpi" end
is_topk = true
elseif is_allcategories then
if is_host then schema = "host:ndpi_categories" else schema = "iface:ndpi_categories" end
is_topk = true
else goto continue end
local datapoints = {}
local options = {
max_num_points = global_max_num_points,
-- always request full series
-- as, by default, queryTopk only returns
-- cumulated total values while grafana needs full timeseries
with_series = true,
}
local rr
local tags = {ifid=getInterfaceId(ifname), host=addr}
if is_topk then
rr = ts_utils.queryTopk(schema, tags, epoch_begin, epoch_end, options)
else
rr = ts_utils.query(schema, tags, epoch_begin, epoch_end, options)
end
if not rr then
goto continue
end
local totalval = nil
if rr.statistics then
totalval = rr.statistics.total
end
local label = ifname
if is_host then label = addr..", "..label end
label = "["..label.."]"
if is_allprotos then
toSeries(rr, res, label)
elseif string.ends(t["target"], "traffic_total_bytes") or string.ends(t["target"], "traffic_total_packets") then
if totalval then
res[#res + 1] = {target="Total", datapoints={{totalval, 0 --[[ it's an integral, an instant is not meaningful here --]]}}}
end
else
toSeries(rr, res, label)
end
-- tprint({target=target, is_traffic=is_traffic, is_packets=is_packets, entity_name=entity_name})
::continue::
end
--tprint(_POST["payload"])
-- tprint("QUERY")
-- tprint(_POST)
print(json.encode(res, nil))
end

View file

@ -0,0 +1,108 @@
--
-- (C) 2013-18 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "grafana_utils"
if isCORSpreflight() then
processCORSpreflight()
else
interface.select(ifname)
local corsr = {}
corsr["Access-Control-Allow-Origin"] = _SERVER["Origin"]
sendHTTPHeader('application/json', nil, corsr)
-- tprint("SEARCH")
-- tprint(_POST)
local target = _POST["payload"]["target"]
--[[
example targets:
interface_eth0
host_192.168.2.0
host_192.168.2.0_interface_eth0
--]]
if target == nil then
target = ""
end
local host_info
local target_interfaces = {}
-- PARSE the host part of the target
-- the host part is preceeded by prefix host_
if isEmptyString(target) or string.starts("host_", target) or string.starts(target, "host_") then
local addr = string.match(target or '', "_(.-)_") -- assumes address is between the first two underscores
if isEmptyString(addr) then
addr = string.match(target or '', "_(.-)$") -- assumes address is between the first underscore and the end of string
end
host_info = hostkey2hostinfo(addr or '')
-- tprint(host_info)
local a, b = string.find(target, addr or '')
target = string.sub(target, b + 2 --[[ +2 removes the optional uderscore preceding interface_ --]])
-- tprint({target=target})
end
-- PARSE the interface part of the target
-- the interface part is preceeded by prefix interface_
if isEmptyString(target) or string.starts("interface_", target) or string.starts(target, "interface_") then
local ifnames = interface.getIfNames()
for _, n in pairs(ifnames) do
local t = "interface_"..n
if isEmptyString(target) or string.starts(t, target) or string.starts(target, t) then
target_interfaces[n] = 1
end
end
end
local matches = {}
for n,_ in pairs(target_interfaces) do
interface.select(n)
matches[n] = {}
if host_info ~= nil then
local matching_hosts = interface.findHost(hostinfo2hostkey(host_info))
for addr, label in pairs(matching_hosts) do
matches[n][addr] = label
end
end
end
local rsp_targets = {}
local metrics = {"traffic_bps", "traffic_total_bytes", "allprotocols_bps", "allcategories_bps"}
if host_info == nil then -- packets only for interfaces
metrics[#metrics + 1] = "traffic_pps"
metrics[#metrics + 1] = "traffic_total_packets"
end
for _, metric in pairs(metrics) do
for n, hosts in pairs(matches) do
local interface_series = "interface_"..n.."_"..metric
for addr, label in pairs(hosts) do
local host_series = "host_"..addr
rsp_targets[#rsp_targets + 1] = host_series.."_"..interface_series
end
if host_info == nil then
rsp_targets[#rsp_targets + 1] = interface_series
end
end
end
-- tprint({matches=matches, rsp_targets=rsp_targets})
print(json.encode(rsp_targets, nil))
end