6
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
11
sendHTTPHeader('text/html')
13
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
16
if(page == nil) then page = "UserApps" end
17
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
19
user_key = _GET["user"]
20
host_key = _GET["host"]
21
application = _GET["application"]
23
if(user_key == nil) then
24
print("<div class=\"alert alert-danger\"><img src=/img/warning.png> Missing user name</div>")
26
if(host_key ~= nil) then
27
name = ntop.getResolvedAddress(host_key)
33
<nav class="navbar navbar-default" role="navigation">
34
<div class="navbar-collapse collapse">
35
<ul class="nav navbar-nav">
36
<li><a href="#"><i class="fa fa-user fa-lg"></i> ]] print(user_key) if(host_key ~= nil) then print(' - <i class="fa fa-building fa-lg"></i> '..name) end print [[ </a></li>
40
if(page == "UserApps") then active=' class="active"' else active = "" end
41
print('<li'..active..'><a href="?user='.. user_key) if(host_key ~= nil) then print("&host="..host_key) end print('&page=UserApps">Applications</a></li>\n')
43
if(page == "UserProtocols") then active=' class="active"' else active = "" end
44
print('<li'..active..'><a href="?user='.. user_key) if(host_key ~= nil) then print("&host="..host_key) end print('&page=UserProtocols">Protocols</a></li>\n')
46
if(page == "Flows") then active=' class="active"' else active = "" end
47
print('<li'..active..'><a href="?user='.. user_key) if(host_key ~= nil) then print("&host="..host_key) end print('&page=Flows">Flow</a></li>\n')
50
print('</ul>\n\t</div>\n\t\t</nav>\n')
53
if(page == "UserApps") then
55
<table class="table table-bordered table-striped">
56
<tr><th class="text-center">
57
<h4>Top Applications</h4>
58
<td><div class="pie-chart" id="topApps"></div></td>
65
<script type='text/javascript'>
66
window.onload=function() {
67
var refresh = 3000 /* ms */;
68
do_pie("#topApps", '/lua/user_stats.lua', { user: "]] print(user_key) print [[", mode: "apps" ]]
69
if (host_key ~= nil) then print(", host: \""..host_key.."\"") end
76
elseif(page == "UserProtocols") then
81
<div class="tabbable tabs-left">
83
<ul class="nav nav-tabs">
84
<li class="active"><a href="#l7" data-toggle="tab">L7 Protocols</a></li>
85
<li><a href="#l4" data-toggle="tab">L4 Protocols</a></li>
89
<div class="tab-content">
91
<div class="tab-pane active" id="l7">
92
<table class="table table-bordered table-striped">
94
<th class="text-center">Top L7 Protocols</th>
95
<td><div class="pie-chart" id="topL7"></div></td>
101
<div class="tab-pane" id="l4">
102
<table class="table table-bordered table-striped">
104
<th class="text-center">Top L4 Protocols</th>
105
<td><div class="pie-chart" id="topL4"></div></td>
108
</div> <!-- Tab l4-->
110
</div> <!-- End Tab content-->
111
</div> <!-- End Left Tab -->
117
<script type='text/javascript'>
118
window.onload=function() {
119
var refresh = 3000 /* ms */;
120
do_pie("#topL7", '/lua/user_stats.lua', { user: "]] print(user_key) print [[", mode: "l7" ]]
121
if (host_key ~= nil) then print(", host: \""..host_key.."\"") end
124
do_pie("#topL4", '/lua/user_stats.lua', { user: "]] print(user_key) print [[", mode: "l4" ]]
125
if (host_key ~= nil) then print(", host: \""..host_key.."\"") end
132
elseif(page == "Flows") then
134
stats = interface.getNdpiStats()
138
<div id="table-hosts"></div>
140
$("#table-hosts").datatable({
141
url: "/lua/get_flows_data.lua]]
142
if(application ~= nil) then
143
print("?application="..application)
144
num_param = num_param + 1
147
if(user_key ~= nil) then
148
if (num_param > 0) then
153
print("user="..user_key)
154
num_param = num_param + 1
157
if(host_key ~= nil) then
158
if (num_param > 0) then
163
print("host="..host_key)
164
num_param = num_param + 1
168
showPagination: true,
169
buttons: [ '<div class="btn-group"><button class="btn btn-link dropdown-toggle" data-toggle="dropdown">Applications<span class="caret"></span></button> <ul class="dropdown-menu" id="flow_dropdown">]]
171
print('<li><a href="/lua/get_user_info.lua?user='.. user_key) if(host_key ~= nil) then print("&host="..host_key) end print('&page=Flows">All Proto</a></li>')
172
for key, value in pairsByKeys(stats["ndpi"], asc) do
174
if(key == application) then
175
class_active = ' class="active"'
177
print('<li '..class_active..'><a href="/lua/get_user_info.lua?user='.. user_key) if(host_key ~= nil) then print("&host="..host_key) end print('&page=Flows&application=' .. key..'">'..key..'</a></li>')
181
print("</ul> </div>' ],\n")
184
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/sflows_stats_top.inc")
186
prefs = ntop.getPrefs()
188
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/sflows_stats_bottom.inc")
201
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")