1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
--
-- (C) 2013-22 - 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
local snmp_utils = require "snmp_utils"
end
require "lua_utils"
local graph_utils = require "graph_utils"
local page_utils = require("page_utils")
local info = ntop.getInfo(false)
local vlan_id = _GET["vlan"]
local page = _GET["page"] -- only historical for now _GET["page"]
interface.select(ifname)
ifId = getInterfaceId(ifname)
sendHTTPContentTypeHeader('text/html')
page_utils.set_active_menu_entry(page_utils.menu_entries.vlans)
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\"><i class='fas fa-exclamation-triangle fa-lg fa-ntopng-warning'></i> " .. i18n("vlan_details.vlan_id_parameter_missing_or_invalid_message") .. "</div>")
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
return
end
if(not areVlanTimeseriesEnabled(ifId)) and (page ~= "config") then
print("<div class=\"alert alert alert-danger\"><i class='fas fa-exclamation-triangle fa-lg fa-ntopng-warning'></i> " .. i18n("vlan_details.no_available_stats_for_vlan_message",{vlan_id=vlan_id, product=info["product"]}).."</div>")
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
return
else
--[[
Create Menu Bar with buttons
--]]
local nav_url = ntop.getHttpPrefix().."/lua/vlan_details.lua?vlan="..vlan_id
local title = i18n("vlan")..": "..vlan_id..""
page_utils.print_navbar(title, nav_url,
{
{
active = page == "historical" or not page,
page_name = "historical",
label = "<i class='fas fa-lg fa-chart-area'></i>",
},
{
active = page == "alerts",
page_name = "alerts",
url = ntop.getHttpPrefix() .. "/lua/alert_stats.lua",
label = "<i class=\"fas fa-exclamation-triangle fa-lg\"></i>",
},
{
hidden = not network or not isAdministrator(),
active = page == "config",
page_name = "config",
label = "<i class=\"fas fa-cog fa-lg\"></i>",
},
}
)
--[[
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"],
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], vlan_url, selected_epoch, {
top_protocols = "top:vlan:ndpi",
timeseries = {
{schema="vlan:traffic", label=i18n("traffic")},
{schema="vlan:score", label=i18n("score"), split_directions = true},
},
})
elseif (page == "config") then
if(not isAdministrator()) then
return
end
print[[
<form id="vlan_config" class="form-inline" style="margin-bottom: 0px;" method="post">
<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print[["/>
<table class="table table-bordered table-striped">]]
if _SERVER["REQUEST_METHOD"] == "POST" then
setVlanAlias(tonumber(vlan_id), _POST["custom_name"])
custom_name = getVlanAlias(tonumber(vlan_id))
end
custom_name = getVlanAlias(vlan_id)
print [[<tr>
<th>]] print(i18n("vlan_details.vlan_alias")) print[[</th>
<td>
<input type="text" name="custom_name" class="form-control" placeholder="Custom Name" style="width: 280px;" value="]]print(custom_name)
print[["]]
print[[>
</td>
</tr>
]]
print[[
</table>
<button class="btn btn-primary" style="float:right; margin-right:1em; margin-left: auto" disabled="disabled" type="submit">]] print(i18n("save_settings")) print[[</button><br><br>
</form>
<script>
aysHandleForm("#vlan_config");
</script>
]]
print[[</table>]]
end
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|