ntopng/scripts/lua/vlan_details.lua
Emanuele Faranda 4cbe45a948
New pro charts features and timeseries api (#1865)
* Integrate modified nvd3 library with zoom and multicharts working support

* Fix count in RRD driver

* Initial chart ajax migration

* Update nvd3 with zoom stack support

* Fix RRD listSeries with directories

* Work in progress graphs

* Compatibility fix

* Initial support for schema based api

* Add missing script

* Fix listSeries for existance check

* Implement topk timseries api

* Implement topk queries and fix labels and formats

* Migrate interface top sender and receivers

* Migrate charts to new API

* Move timeseries list for menu inside respective scripts

* Add support for extended labels

* Fix missing fields while chaning graph resolution

Also Rename drawRRD in drawGraphs

* Fix historical tabs

* Add missing time fence in influx topk

* Add graphs support for custom statistics visualization

* Initial support for graphs statistics footer

* Implement statistics in single graphs for RRD driver

* Move sampling function into the driver and fix graph statistics

* Fix max/min value offset

* Implement influxdb sampling use built-in FILL

* Implement stats and total serie in influxdb driver

* Update nvd3 with multiChart fixes

* Update nvd3 with new multiChart fixes

* RRD driver fixes

* Move metrics type from single metric to schema

* Handle ajax errors and empty data in charts

* Fix flow device interfaces graphs

* Use timeserie label as timeseries dropdown text

* Implement topk aggregation into one data serie

* ts_utils module now provides all the schemas

* Migrate ntop.exist(rrd) to ts_utils.exist

* Fix timeseries dropdown label

* L4 protos fixes for charts

* Migrate getProtoVolume to new API

* Integrate nvd3 fix for tooltip position

* Initial community graphs migration to timseries API

* Fix community timeseries dropdown and historical tabs

* Hide total serie by default

* Remove l4 protos from topk charts
2018-07-18 15:09:19 +02:00

91 lines
2.8 KiB
Lua

--
-- (C) 2013-18 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
if(ntop.isPro()) then
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
require "snmp_utils"
end
require "lua_utils"
require "graph_utils"
local ts_utils = require"ts_utils"
local info = ntop.getInfo(false)
local vlan_id = _GET["vlan"]
local page = "historical" -- only historical for now _GET["page"]
interface.select(ifname)
ifId = getInterfaceId(ifname)
sendHTTPContentTypeHeader('text/html')
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
if vlan_id == nil or tonumber(vlan_id) == nil or tonumber(vlan_id) == 0 then
print("<div class=\"alert alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png> " .. i18n("vlan_details.vlan_id_parameter_missing_or_invalid_message") .. "</div>")
return
end
if(not ts_utils.exists("vlan:traffic", {ifid=ifId, vlan=vlan_id})) then
print("<div class=\"alert alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png> " .. i18n("vlan_details.no_available_stats_for_vlan_message",{vlan_id=vlan_id, product=info["product"]}).."</div>")
else
--[[
Create Menu Bar with buttons
--]]
local nav_url = ntop.getHttpPrefix().."/lua/vlan_details.lua?vlan"..vlan_id
print [[
<div class="bs-docs-example">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
]]
print("<li><a href=\"#\">"..i18n("vlan")..": "..vlan_id.."</A> </li>")
if(page == "historical") then
print("\n<li class=\"active\"><a href=\"#\"><i class='fa fa-area-chart fa-lg'></i></a></li>\n")
else
print("\n<li><a href=\""..nav_url.."&page=historical\"><i class='fa fa-area-chart fa-lg'></i></a></li>")
end
print [[
<li><a href="javascript:history.go(-1)"><i class='fa fa-reply'></i></a></li>
</ul>
</div>
</nav>
</div>
]]
--[[
Selectively render information pages
--]]
if page == "historical" then
local schema = _GET["ts_schema"] or "vlan:traffic"
local selected_epoch = _GET["epoch"] or ""
local vlan_url = ntop.getHttpPrefix()..'/lua/vlan_details.lua?ifid='..ifId..'&vlan='..vlan_id..'&page=historical'
local tags = {
ifid = ifId,
vlan = vlan_id,
protocol = _GET["protocol"],
}
drawGraphs(ifId, schema, tags, _GET["zoom"], vlan_url, selected_epoch, {
top_protocols = "top:vlan:ndpi",
timeseries = {
{schema="vlan:traffic", label=i18n("traffic")},
},
})
end
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")