File: vlan_details.lua

package info (click to toggle)
ntopng 2.4%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,888 kB
  • ctags: 8,091
  • sloc: cpp: 21,442; ansic: 10,999; sh: 1,627; makefile: 423; pascal: 312; ruby: 34; exp: 4
file content (78 lines) | stat: -rw-r--r-- 2,484 bytes parent folder | download
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
--
-- (C) 2013-16 - 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 vlan_id        = _GET["vlan_id"]
local page           = "historical" -- only historical for now _GET["page"]
local rrdfile        = "bytes.rrd"
if(_GET["rrd_file"] ~= nil) then
   rrdfile=_GET["rrd_file"]
end

interface.select(ifname)
ifId = getInterfaceId(ifname)

sendHTTPHeader('text/html; charset=iso-8859-1')
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> Vlan_Id parameter is missing or is not valid</div>")
    return
end

local rrdname = getRRDName(ifId, "vlan:"..vlan_id, rrdfile)

if(not ntop.exists(rrdname) and rrdfile ~= "all") then
    print("<div class=\"alert alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png> No available stats for VLAN  "..vlan_id..". Please wait a few minutes to allow ntopng to harvest new statistics.</div>")
    return
end

--[[
Create Menu Bar with buttons
--]]
local nav_url = ntop.getHttpPrefix().."/lua/vlan_details.lua?vlan_id="..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=\"#\">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
    vlan_url = ntop.getHttpPrefix()..'/lua/vlan_details.lua?ifname='..ifId..'&vlan_id='..vlan_id..'&page=historical'
    drawRRD(ifId, 'vlan:'..vlan_id, rrdfile, _GET["graph_zoom"], vlan_url, 1, _GET["epoch"], nil, makeTopStatsScriptsArray())
end

dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")