mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Rework Preference Panes
This commit is contained in:
parent
7d82c7b897
commit
5d2f1f4c03
3 changed files with 555 additions and 260 deletions
|
|
@ -26,207 +26,415 @@ if(haveAdminPrivileges()) then
|
|||
|
||||
print [[
|
||||
<h2>Runtime Preferences</h2>
|
||||
<table class="table">
|
||||
]]
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Report Visualization</th></tr>')
|
||||
subpage_active = _GET["subpage_active"]
|
||||
|
||||
toggleTableButton("Throughput Unit",
|
||||
"Select the throughput unit to be displayed in traffic reports.",
|
||||
"Bytes", "bps", "primary","Packets", "pps", "primary","toggle_thpt_content", "ntopng.prefs.thpt_content")
|
||||
report_active = ""
|
||||
web_gui_active = ""
|
||||
traffic_active = ""
|
||||
top_talkers_active = ""
|
||||
mysql_active = ""
|
||||
nbox_active = ""
|
||||
alerts_active = ""
|
||||
user_auth_active = ""
|
||||
data_purge_active = ""
|
||||
stats_rrds_active = ""
|
||||
|
||||
if (subpage_active == nil or subpage_active == "") then
|
||||
subpage_active = "report"
|
||||
end
|
||||
|
||||
-- if autologout has not been explicitly disabled via command-line, then we allow
|
||||
-- changes at runtime
|
||||
if prefs.is_autologout_enabled == true then
|
||||
print('<tr><th colspan=2 class="info">Web User Interface</th></tr>')
|
||||
if (subpage_active == "report") then
|
||||
report_active = "active"
|
||||
end
|
||||
if (subpage_active == "web_gui") then
|
||||
web_gui_active = "active"
|
||||
end
|
||||
if (subpage_active == "traffic") then
|
||||
traffic_active = "active"
|
||||
end
|
||||
if (subpage_active == "top_talkers") then
|
||||
top_talkers_active = "active"
|
||||
end
|
||||
if (subpage_active == "mysql") then
|
||||
mysql_active = "active"
|
||||
end
|
||||
if (subpage_active == "nbox") then
|
||||
nbox_active = "active"
|
||||
end
|
||||
if (subpage_active == "alerts") then
|
||||
alerts_active = "active"
|
||||
end
|
||||
if (subpage_active == "user_auth") then
|
||||
user_auth_active = "active"
|
||||
end
|
||||
if (subpage_active == "data_purge") then
|
||||
data_purge_active = "active"
|
||||
end
|
||||
if (subpage_active == "stats_rrds") then
|
||||
stats_rrds_active = "active"
|
||||
end
|
||||
|
||||
toggleTableButton("Auto Logout",
|
||||
"Toggle the automatic logout of web interface users with expired sessions.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_autologout", "ntopng.prefs.is_autologon_enabled")
|
||||
end
|
||||
-- ================================================================================
|
||||
function printReportVisualization()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="report"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">Report Visualization</th></tr>')
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Traffic Metrics Storage (RRD)</th></tr>')
|
||||
toggleTableButtonPrefs("Throughput Unit",
|
||||
"Select the throughput unit to be displayed in traffic reports.",
|
||||
"Bytes", "bps", "primary","Packets", "pps", "primary","toggle_thpt_content", "ntopng.prefs.thpt_content", "bps")
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
toggleTableButton("RRDs For Local Hosts",
|
||||
"Toggle the creation of RRDs for local hosts. Turn it off to save storage space.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local", "ntopng.prefs.host_rrd_creation")
|
||||
-- ================================================================================
|
||||
function printWebGUI()
|
||||
if prefs.is_autologout_enabled == true then
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="web_gui"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">Web User Interface</th></tr>')
|
||||
|
||||
toggleTableButton("nDPI RRDs For Local Hosts and Networks",
|
||||
"Toggle the creation of nDPI RRDs for local hosts and defined networks. Enable their creation allows you "..
|
||||
"to keep application protocol statistics at the cost of using more disk space.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local_ndpi", "ntopng.prefs.host_ndpi_rrd_creation")
|
||||
toggleTableButtonPrefs("Auto Logout",
|
||||
"Toggle the automatic logout of web interface users with expired sessions.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_autologout", "ntopng.prefs.is_autologon_enabled", "1")
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
end
|
||||
|
||||
toggleTableButton("Category RRDs For Local Hosts and Networks",
|
||||
"Toggle the creation of Category RRDs for local hosts and defined networks. Enabling their creation allows you "..
|
||||
"to keep persistent traffic category statistics (e.g., social networks, news) at the cost of using more disk space.<br>"..
|
||||
"Creation is only possible if the ntopng instance has been launched with option -k flashstart:<user>:<password>.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local_categorization", "ntopng.prefs.host_categories_rrd_creation", not prefs.is_categorization_enabled)
|
||||
-- ================================================================================
|
||||
function printTraffic()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="traffic"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">Traffic Metrics Storage (RRD)</th></tr>')
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Top Talkers Storage</th></tr>')
|
||||
toggleTableButtonPrefs("RRDs For Local Hosts",
|
||||
"Toggle the creation of RRDs for local hosts. Turn it off to save storage space.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local", "ntopng.prefs.host_rrd_creation", "1")
|
||||
|
||||
minute_top_talkers_retention = ntop.getCache("ntopng.prefs.minute_top_talkers_retention")
|
||||
if((minute_top_talkers_retention == nil) or (minute_top_talkers_retention == "")) then minute_top_talkers_retention = "365" end
|
||||
prefsInputField("Data Retention", "Duration in days of minute top talkers data retention. Default: 365 days", "minute_top_talkers_retention", minute_top_talkers_retention)
|
||||
toggleTableButtonPrefs("nDPI RRDs For Local Hosts and Networks",
|
||||
"Toggle the creation of nDPI RRDs for local hosts and defined networks. Enable their creation allows you "..
|
||||
"to keep application protocol statistics at the cost of using more disk space.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local_ndpi", "ntopng.prefs.host_ndpi_rrd_creation", "0")
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">MySQL Database</th></tr>')
|
||||
toggleTableButtonPrefs("Category RRDs For Local Hosts and Networks",
|
||||
"Toggle the creation of Category RRDs for local hosts and defined networks. Enabling their creation allows you "..
|
||||
"to keep persistent traffic category statistics (e.g., social networks, news) at the cost of using more disk space.<br>"..
|
||||
"Creation is only possible if the ntopng instance has been launched with option -k flashstart:<user>:<password>.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_local_categorization", "ntopng.prefs.host_categories_rrd_creation", "0", not prefs.is_categorization_enabled)
|
||||
|
||||
mysql_retention = ntop.getCache("ntopng.prefs.mysql_retention")
|
||||
if((mysql_retention == nil) or (mysql_retention == "")) then mysql_retention = "30" end
|
||||
prefsInputField("Data Retention", "Duration in days of data retention in the MySQL database. Default: 30 days", "mysql_retention", mysql_retention)
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Alerts</th></tr>')
|
||||
-- ================================================================================
|
||||
function printTopTalkers()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="top_talkers"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">Top Talkers Storage</th></tr>')
|
||||
|
||||
toggleTableButton("Alerts On Syslog",
|
||||
"Enable alerts logging on system syslog.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_alert_syslog", "ntopng.prefs.alerts_syslog")
|
||||
--default value
|
||||
minute_top_talkers_retention = 365
|
||||
prefsInputFieldPrefs("Data Retention", "Duration in days of minute top talkers data retention. Default: 365 days", "ntopng.prefs.", "minute_top_talkers_retention", minute_top_talkers_retention)
|
||||
|
||||
if (ntop.isPro()) then
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Nagios Alerts</th></tr>')
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
toggleTableButton("Alerts To Nagios",
|
||||
"Enable sending ntopng alerts to Nagios NSCA (Nagios Service Check Acceptor).",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_alert_nagios", "ntopng.prefs.alerts_nagios")
|
||||
-- ================================================================================
|
||||
function printMysql()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="mysql"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">MySQL Database</th></tr>')
|
||||
|
||||
if ntop.getCache("ntopng.prefs.alerts_nagios") == "1" then
|
||||
prefsInputField("Nagios NSCA Host", "Address of the host where the Nagios NSCA daemon is running. Default: localhost.", "nagios_nsca_host", prefs.nagios_nsca_host)
|
||||
prefsInputField("Nagios NSCA Port", "Port where the Nagios daemon's NSCA is listening. Default: 5667.", "nagios_nsca_port", prefs.nagios_nsca_port)
|
||||
prefsInputField("Nagios send_nsca executable", "Absolute path to the Nagios NSCA send_nsca utility. Default: /usr/local/nagios/bin/send_nsca", "nagios_send_nsca_executable", prefs.nagios_send_nsca_executable)
|
||||
prefsInputField("Nagios send_nsca configuration", "Absolute path to the Nagios NSCA send_nsca utility configuration file. Default: /usr/local/nagios/etc/send_nsca.cfg", "nagios_send_nsca_config", prefs.nagios_send_nsca_conf)
|
||||
prefsInputField("Nagios host_name", "The host_name exactly as specified in Nagios host definition for the ntopng host. Default: ntopng-host", "nagios_host_name", prefs.nagios_host_name)
|
||||
prefsInputField("Nagios service_description", "The service description exactly as specified in Nagios passive service definition for the ntopng host. Default: NtopngAlert", "nagios_service_name", prefs.nagios_service_name)
|
||||
end
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">nBox Integration</th></tr>')
|
||||
mysql_retention = 30
|
||||
prefsInputFieldPrefs("Data Retention", "Duration in days of data retention in the MySQL database. Default: 30 days", "ntopng.prefs.", "mysql_retention", mysql_retention)
|
||||
|
||||
local nbox_integration = ntop.getCache("ntopng.prefs.nbox_integration")
|
||||
local nbox_user = ntop.getCache("ntopng.prefs.nbox_user")
|
||||
local nbox_password = ntop.getCache("ntopng.prefs.nbox_password")
|
||||
if((nbox_integration == nil) or (nbox_integration == "")) then ntop.setCache("ntopng.prefs.nbox_integration", "0") end
|
||||
if((nbox_user == nil) or (nbox_user == "")) then nbox_user = "nbox" end
|
||||
if((nbox_password == nil) or (nbox_password == "")) then nbox_password = "nbox" end
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
toggleTableButton("Enable nBox Support",
|
||||
"Enable sending ntopng requests (e.g., to download pcap files) to an nBox. Pcap requests are issued from the historical data browser when browsing 'Talkers' and 'Protocols'. Each request carry information on the search criteria generated by the user when drilling-down historical data. Requests are queued and pcaps become available for download from a dedicated 'Pcaps' tab once generated.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_nbox_integration", "ntopng.prefs.nbox_integration")
|
||||
if ntop.getCache("ntopng.prefs.nbox_integration") == "1" then
|
||||
prefsInputField("nBox User", "User that has privileges to access the nBox. Default: nbox", "nbox_user", nbox_user)
|
||||
prefsInputField("nBox Password", "Password associated to the nBox user. Default: nbox", "nbox_password", nbox_password, "password")
|
||||
end
|
||||
-- ================================================================================
|
||||
function printAlerts()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="alerts"/>\n')
|
||||
print('<table class="table">')
|
||||
print('<tr><th colspan=2 class="info">Alerts</th></tr>')
|
||||
|
||||
print('<tr><th colspan=2 class="info">User Authentication</th></tr>')
|
||||
toggleTableButtonPrefs("Alerts On Syslog",
|
||||
"Enable alerts logging on system syslog.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_alert_syslog", "ntopng.prefs.alerts_syslog", "1")
|
||||
|
||||
local js_body_funtion_script = "";
|
||||
if (ntop.isPro()) then
|
||||
print('<tr><th colspan=2 class="info">Nagios Alerts</th></tr>')
|
||||
|
||||
js_body_funtion_script = js_body_funtion_script.." if ((field.substring(0, 7) != \"ldap://\") && (field.substring(0, 8) != \"ldaps://\")) {\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." return \"Invalid Value: missing \\\"ldap://\\\" or \\\"ldaps://\\\" at beginning.\";"
|
||||
js_body_funtion_script = js_body_funtion_script.." }\n"
|
||||
local elementToSwitch = {"nagios_nsca_host","nagios_nsca_port","nagios_send_nsca_executable","nagios_send_nsca_config","nagios_host_name","nagios_service_name"}
|
||||
|
||||
js_body_funtion_script = js_body_funtion_script.." var new_field = field.replace(\'ldaps://\', \'\');\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." new_field = new_field.replace(\'ldap://\', \'\');\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." var res = new_field.split(\":\");\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." if(res.length != 2){\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." return \"Invalid Value: missing ldap server address or port number.\";\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." }\n"
|
||||
js_body_funtion_script = js_body_funtion_script.." return \"\";\n"
|
||||
toggleTableButtonPrefs("Alerts To Nagios",
|
||||
"Enable sending ntopng alerts to Nagios NSCA (Nagios Service Check Acceptor).",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_alert_nagios", "ntopng.prefs.alerts_nagios", "0", nil, elementToSwitch)
|
||||
|
||||
local labels = {"Local","LDAP","LDAP/Local"}
|
||||
local values = {"local","ldap","ldap_local"}
|
||||
local retVal = multipleTableButton("LDAP Authentication",
|
||||
"Local (Local only), LDAP (LDAP server only), LDAP/Local (Authenticate with LDAP server, if fails it uses local authentication).",
|
||||
labels, values, "local", "primary", "multiple_ldap_authentication", "ntopng.prefs.auth_type")
|
||||
if ((retVal == "ldap") or (retVal == "ldap_local")) then
|
||||
local ldap_server = ntop.getCache("ntopng.prefs.ldap.server")
|
||||
if((ldap_server == nil) or (ldap_server == "")) then
|
||||
ldap_server = "ldap://localhost:389"
|
||||
ntop.setCache("ntopng.prefs.ldap.server", ldap_server)
|
||||
end
|
||||
local labels_account = {"Posix","sAMAccount"}
|
||||
local values_account = {"posix","samaccount"}
|
||||
multipleTableButton("LDAP Accounts Type",
|
||||
"Choose your account type",
|
||||
labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type")
|
||||
prefsInputFieldWithParamCheck("LDAP Server Address", "IP address and port of LDAP server (e.g. ldaps://localhost:636). Default: \"ldap://localhost:389\".", "ntopng.prefs.ldap", "server", ldap_server, "text", js_body_funtion_script)
|
||||
local anonymous_bind = ntop.getCache("ntopng.prefs.ldap.anonymous_bind")
|
||||
if((anonymous_bind == nil) or (anonymous_bind == "")) then ntop.setCache("ntopng.prefs.ldap.anonymous_bind", "0") end
|
||||
toggleTableButton("LDAP Anonymous Binding",
|
||||
"Enable anonymous binding.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind")
|
||||
if ntop.getCache("ntopng.prefs.ldap.anonymous_bind") == "0" then
|
||||
local ldap_bind_dn = ntop.getCache("ntopng.prefs.ldap.bind_dn")
|
||||
if(ldap_bind_dn == nil) then ldap_bind_dn = "" end
|
||||
prefsInputFieldWithParamCheck("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", ldap_bind_dn, "text", nil)
|
||||
local ldap_bind_pwd = ntop.getCache("ntopng.prefs.ldap.bind_pwd")
|
||||
if(ldap_bind_pwd == nil) then ldap_bind_pwd = "" end
|
||||
prefsInputFieldWithParamCheck("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", ldap_bind_pwd, "password", nil)
|
||||
end
|
||||
local ldap_search_path = ntop.getCache("ntopng.prefs.ldap.search_path")
|
||||
if(ldap_search_path == nil) then ldap_search_path = "" end
|
||||
prefsInputFieldWithParamCheck("LDAP Search Path", "Root path used to search the users.", "ntopng.prefs.ldap", "search_path", ldap_search_path, "text", nil)
|
||||
local ldap_user_group = ntop.getCache("ntopng.prefs.ldap.user_group")
|
||||
if(ldap_user_group == nil) then ldap_user_group = "" end
|
||||
prefsInputFieldWithParamCheck("LDAP User Group", "Group name to which user has to belong in order to authenticate as unprivileged user.", "ntopng.prefs.ldap", "user_group", ldap_user_group, "text", nil)
|
||||
local ldap_admin_group = ntop.getCache("ntopng.prefs.ldap.admin_group")
|
||||
if(ldap_admin_group == nil) then ldap_admin_group = "" end
|
||||
prefsInputFieldWithParamCheck("LDAP Admin Group", "Group name to which user has to belong in order to authenticate as an administrator.", "ntopng.prefs.ldap", "admin_group", ldap_admin_group, "text", nil)
|
||||
if ntop.getCache("ntopng.prefs.alerts_nagios") == "1" then
|
||||
showElements = true
|
||||
else
|
||||
showElements = false
|
||||
end
|
||||
|
||||
prefsInputFieldPrefs("Nagios NSCA Host", "Address of the host where the Nagios NSCA daemon is running. Default: localhost.", "ntopng.prefs.", "nagios_nsca_host", prefs.nagios_nsca_host, nil, showElements)
|
||||
prefsInputFieldPrefs("Nagios NSCA Port", "Port where the Nagios daemon's NSCA is listening. Default: 5667.", "ntopng.prefs.", "nagios_nsca_port", prefs.nagios_nsca_port, nil, showElements)
|
||||
prefsInputFieldPrefs("Nagios send_nsca executable", "Absolute path to the Nagios NSCA send_nsca utility. Default: /usr/local/nagios/bin/send_nsca", "ntopng.prefs.", "nagios_send_nsca_executable", prefs.nagios_send_nsca_executable, nil, showElements)
|
||||
prefsInputFieldPrefs("Nagios send_nsca configuration", "Absolute path to the Nagios NSCA send_nsca utility configuration file. Default: /usr/local/nagios/etc/send_nsca.cfg", "ntopng.prefs.", "nagios_send_nsca_config", prefs.nagios_send_nsca_conf, nil, showElements)
|
||||
prefsInputFieldPrefs("Nagios host_name", "The host_name exactly as specified in Nagios host definition for the ntopng host. Default: ntopng-host", "ntopng.prefs.", "nagios_host_name", prefs.nagios_host_name, nil, showElements)
|
||||
prefsInputFieldPrefs("Nagios service_description", "The service description exactly as specified in Nagios passive service definition for the ntopng host. Default: NtopngAlert", "ntopng.prefs.", "nagios_service_name", prefs.nagios_service_name, nil, showElements)
|
||||
end
|
||||
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
-- TODO
|
||||
if(false) then
|
||||
if(ntop.isPro()) then
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Periodic Activities</th></tr>')
|
||||
local message = "Toggle generation of daily reports in PDF format."
|
||||
local disable = false
|
||||
if (not havePDFRenderer(getUsedPDFRenderer())) then
|
||||
disable = true
|
||||
message = message.." Install "..getUsedPDFRenderer().." to enable this."
|
||||
elseif (not ntop.isLoginDisabled()) then
|
||||
disable = true
|
||||
message = message..' Start ntopng with the "-l" option to enable this.'
|
||||
end
|
||||
toggleTableButton("Generate Reports Daily",
|
||||
message, "On", "1", "success", "Off", "0", "danger",
|
||||
"toggle_daily_reports", "ntopng.prefs.daily_reports", disable)
|
||||
end
|
||||
-- ================================================================================
|
||||
function printNbox()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="nbox"/>\n')
|
||||
print('<table class="table">')
|
||||
|
||||
print('<tr><th colspan=2 class="info">nBox Integration</th></tr>')
|
||||
|
||||
local elementToSwitch = {"nbox_user","nbox_password"}
|
||||
|
||||
toggleTableButtonPrefs("Enable nBox Support",
|
||||
"Enable sending ntopng requests (e.g., to download pcap files) to an nBox. Pcap requests are issued from the historical data browser when browsing 'Talkers' and 'Protocols'. Each request carry information on the search criteria generated by the user when drilling-down historical data. Requests are queued and pcaps become available for download from a dedicated 'Pcaps' tab once generated.",
|
||||
"On", "1", "success", "Off", "0", "danger", "toggle_nbox_integration", "ntopng.prefs.nbox_integration", "0", nil, elementToSwitch)
|
||||
|
||||
if ntop.getCache("ntopng.prefs.nbox_integration") == "1" then
|
||||
showElements = true
|
||||
else
|
||||
showElements = false
|
||||
end
|
||||
|
||||
prefsInputFieldPrefs("nBox User", "User that has privileges to access the nBox. Default: nbox", "ntopng.prefs.", "nbox_user", "nbox", nil, showElements)
|
||||
prefsInputFieldPrefs("nBox Password", "Password associated to the nBox user. Default: nbox", "ntopng.prefs.", "nbox_password", "nbox", "password", showElements)
|
||||
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Data Purge</th></tr>')
|
||||
prefsInputField("Local Host Idle Timeout", "Inactivity time after which a local host is considered idle (sec). Default: 300.", "local_host_max_idle", prefs.local_host_max_idle)
|
||||
prefsInputField("Remote Host Idle Timeout", "Inactivity time after which a remote host is considered idle (sec). Default: 60.", "non_local_host_max_idle", prefs.non_local_host_max_idle)
|
||||
prefsInputField("Flow Idle Timeout", "Inactivity time after which a flow is considered idle (sec). Default: 60.", "flow_max_idle", prefs.flow_max_idle)
|
||||
-- ================================================================================
|
||||
function printUserAuth()
|
||||
print('<form id="form_ldap">')
|
||||
print('<input type=hidden name="subpage_active" value="user_auth"/>\n')
|
||||
print('<table class="table">')
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">User Authentication</th></tr>')
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Network Interface Stats RRDs</th></tr>')
|
||||
prefsInputField("Days for raw stats", "Number of days for which raw stats are kept. Default: 1.", "intf_rrd_raw_days", prefs.intf_rrd_raw_days)
|
||||
prefsInputField("Days for 1 min resolution stats", "Number of days for which stats are kept in 1 min resolution. Default: 30.", "intf_rrd_1min_days", prefs.intf_rrd_1min_days)
|
||||
prefsInputField("Days for 1 hour resolution stats", "Number of days for which stats are kept in 1 hour resolution. Default: 100.", "intf_rrd_1h_days", prefs.intf_rrd_1h_days)
|
||||
prefsInputField("Days for 1 day resolution stats", "Number of days for which stats are kept in 1 day resolution. Default: 365.", "intf_rrd_1d_days", prefs.intf_rrd_1d_days)
|
||||
local labels = {"Local","LDAP","LDAP/Local"}
|
||||
local values = {"local","ldap","ldap_local"}
|
||||
local elementToSwitch = {"row_multiple_ldap_account_type", "row_toggle_ldap_anonymous_bind","server","bind_dn", "bind_pwd", "search_path", "user_group", "admin_group"}
|
||||
local showElementArray = {false, true, true}
|
||||
local javascriptAfterSwitch = "";
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." if ($(\"#id-toggle-multiple_ldap_authentication\").val() != \"local\" ) {\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." if ($(\"#toggle_ldap_anonymous_bind_input\").val() == \"0\") {\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"table-row\");\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"table-row\");\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." } else {\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"none\");\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"none\");\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." }\n"
|
||||
javascriptAfterSwitch = javascriptAfterSwitch.." }\n"
|
||||
local retVal = multipleTableButtonPrefs("LDAP Authentication",
|
||||
"Local (Local only), LDAP (LDAP server only), LDAP/Local (Authenticate with LDAP server, if fails it uses local authentication).",
|
||||
labels, values, "local", "primary", "multiple_ldap_authentication", "ntopng.prefs.auth_type", nil, elementToSwitch, showElementArray, javascriptAfterSwitch)
|
||||
|
||||
local showElements = true;
|
||||
if ntop.getCache("ntopng.prefs.auth_type") == "local" then
|
||||
showElements = false
|
||||
end
|
||||
|
||||
local labels_account = {"Posix","sAMAccount"}
|
||||
local values_account = {"posix","samaccount"}
|
||||
multipleTableButtonPrefs("LDAP Accounts Type",
|
||||
"Choose your account type",
|
||||
labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type", nil, nil, nil, nil, showElements)
|
||||
|
||||
prefsInputFieldPrefs("LDAP Server Address", "IP address and port of LDAP server (e.g. ldaps://localhost:636). Default: \"ldap://localhost:389\".", "ntopng.prefs.ldap", "server", "ldap://localhost:389", nil, showElements)
|
||||
|
||||
local elementToSwitchBind = {"bind_dn","bind_pwd"}
|
||||
toggleTableButtonPrefs("LDAP Anonymous Binding","Enable anonymous binding.","On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind", "0", nil, elementToSwitchBind, true, showElements)
|
||||
|
||||
local showEnabledAnonymousBind = false
|
||||
if ntop.getCache("ntopng.prefs.ldap.anonymous_bind") == "0" then
|
||||
showEnabledAnonymousBind = true
|
||||
end
|
||||
local showElementsBind = showElements
|
||||
if showElements == true then
|
||||
showElementsBind = showEnabledAnonymousBind
|
||||
end
|
||||
prefsInputFieldPrefs("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", "", nil, showElementsBind)
|
||||
prefsInputFieldPrefs("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", "", "password", showElementsBind)
|
||||
|
||||
prefsInputFieldPrefs("LDAP Search Path", "Root path used to search the users.", "ntopng.prefs.ldap", "search_path", "", "text", showElements)
|
||||
prefsInputFieldPrefs("LDAP User Group", "Group name to which user has to belong in order to authenticate as unprivileged user.", "ntopng.prefs.ldap", "user_group", "", "text", showElements)
|
||||
prefsInputFieldPrefs("LDAP Admin Group", "Group name to which user has to belong in order to authenticate as an administrator.", "ntopng.prefs.ldap", "admin_group", "", "text", showElements)
|
||||
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="button" onclick="save_button_ldap()" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form>
|
||||
<script>
|
||||
function save_button_ldap(){
|
||||
if ($("#id-toggle-multiple_ldap_authentication").val() != "local") {
|
||||
var field = $("#id_input_server").val();
|
||||
|
||||
if ((field.substring(0, 7) != "ldap://") && (field.substring(0, 8) != "ldaps://")) {
|
||||
alert("Invalid LDAP Server Address Value: missing \"ldap://\" or \"ldaps://\" at beginning.");
|
||||
return;
|
||||
}
|
||||
|
||||
var new_field = field.replace('ldaps://', '');
|
||||
new_field = new_field.replace('ldap://', '');
|
||||
var res = new_field.split(":");
|
||||
if(res.length != 2){
|
||||
alert("Invalid LDAP Server Address Value: missing ldap server address or port number.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$("#form_ldap").submit();
|
||||
}
|
||||
</script>
|
||||
]]
|
||||
end
|
||||
|
||||
-- ================================================================================
|
||||
function printDataPurge()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="data_purge"/>\n')
|
||||
print('<table class="table">')
|
||||
|
||||
print('<tr><th colspan=2 class="info">Data Purge</th></tr>')
|
||||
prefsInputFieldPrefs("Local Host Idle Timeout", "Inactivity time after which a local host is considered idle (sec). Default: 300.", "ntopng.prefs.","local_host_max_idle", prefs.local_host_max_idle)
|
||||
prefsInputFieldPrefs("Remote Host Idle Timeout", "Inactivity time after which a remote host is considered idle (sec). Default: 60.", "ntopng.prefs.", "non_local_host_max_idle", prefs.non_local_host_max_idle)
|
||||
prefsInputFieldPrefs("Flow Idle Timeout", "Inactivity time after which a flow is considered idle (sec). Default: 60.", "ntopng.prefs.", "flow_max_idle", prefs.flow_max_idle)
|
||||
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
-- ================================================================================
|
||||
function printStatsRrds()
|
||||
print('<form>')
|
||||
print('<input type=hidden name="subpage_active" value="stats_rrds"/>\n')
|
||||
print('<table class="table">')
|
||||
|
||||
print('<tr><th colspan=2 class="info">Network Interface Stats RRDs</th></tr>')
|
||||
prefsInputFieldPrefs("Days for raw stats", "Number of days for which raw stats are kept. Default: 1.", "ntopng.prefs.", "intf_rrd_raw_days", prefs.intf_rrd_raw_days)
|
||||
prefsInputFieldPrefs("Days for 1 min resolution stats", "Number of days for which stats are kept in 1 min resolution. Default: 30.", "ntopng.prefs.", "intf_rrd_1min_days", prefs.intf_rrd_1min_days)
|
||||
prefsInputFieldPrefs("Days for 1 hour resolution stats", "Number of days for which stats are kept in 1 hour resolution. Default: 100.", "ntopng.prefs.", "intf_rrd_1h_days", prefs.intf_rrd_1h_days)
|
||||
prefsInputFieldPrefs("Days for 1 day resolution stats", "Number of days for which stats are kept in 1 day resolution. Default: 365.", "ntopng.prefs.", "intf_rrd_1d_days", prefs.intf_rrd_1d_days)
|
||||
|
||||
print('<tr><th colspan=2 class="info">Protocol/Networks Stats RRDs</th></tr>')
|
||||
prefsInputFieldPrefs("Days for raw stats", "Number of days for which raw stats are kept. Default: 1.", "ntopng.prefs.", "other_rrd_raw_days", prefs.other_rrd_raw_days)
|
||||
--prefsInputFieldPrefs("Days for 1 min resolution stats", "Number of days for which stats are kept in 1 min resolution. Default: 30.", "ntopng.prefs.", "other_rrd_1min_days", prefs.other_rrd_1min_days)
|
||||
prefsInputFieldPrefs("Days for 1 hour resolution stats", "Number of days for which stats are kept in 1 hour resolution. Default: 100.", "ntopng.prefs.", "other_rrd_1h_days", prefs.other_rrd_1h_days)
|
||||
prefsInputFieldPrefs("Days for 1 day resolution stats", "Number of days for which stats are kept in 1 day resolution. Default: 365.", "ntopng.prefs.", "other_rrd_1d_days", prefs.other_rrd_1d_days)
|
||||
|
||||
print('<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px">Save</button></th></tr>')
|
||||
print('</table>')
|
||||
print [[<input id="csrf" name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print [[" />
|
||||
</form> ]]
|
||||
end
|
||||
|
||||
|
||||
print[[
|
||||
<table class="table">
|
||||
<col width="20%">
|
||||
<col width="80%">
|
||||
<tr><td style="padding-right: 20px;">
|
||||
<div class="list-group ">
|
||||
<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=report" class="list-group-item ]] print(report_active) print[["> Report Visualization</a>]]
|
||||
if prefs.is_autologout_enabled == true then
|
||||
print[[<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=web_gui" class="list-group-item ]] print(web_gui_active) print[[">Web User Interface</a>]]
|
||||
end
|
||||
print[[<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=traffic" class="list-group-item ]] print(traffic_active) print[[">Traffic Metrics Storage</a>
|
||||
<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=top_talkers" class="list-group-item ]] print(top_talkers_active) print[[">Top Talkers Storage</a>
|
||||
<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=mysql" class="list-group-item ]] print(mysql_active) print[[">MySQL Database</a>
|
||||
<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=alerts" class="list-group-item ]] print(alerts_active) print[[">Alerts</a> ]]
|
||||
if (ntop.isPro()) then
|
||||
print [[<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=nbox" class="list-group-item ]] print(nbox_active) print[[">nBox Integration</a> ]]
|
||||
print [[<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=user_auth" class="list-group-item ]] print(user_auth_active) print[[">User Authentication</a>]]
|
||||
end
|
||||
print [[<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=data_purge" class="list-group-item ]] print(data_purge_active) print[[">Data Purge</a>
|
||||
<a href="]] print(ntop.getHttpPrefix()) print[[/lua/admin/prefs.lua?subpage_active=stats_rrds" class="list-group-item ]] print(stats_rrds_active) print[[">Stats RRDs</a>
|
||||
</div>
|
||||
</td><td colspan=2 style="padding-left: 14px;border-left-style: groove; border-width:1px; border-color: #e0e0e0;">]]
|
||||
|
||||
if (subpage_active == "report") then
|
||||
printReportVisualization()
|
||||
end
|
||||
if (subpage_active == "web_gui") then
|
||||
printWebGUI()
|
||||
end
|
||||
if (subpage_active == "traffic") then
|
||||
printTraffic()
|
||||
end
|
||||
if (subpage_active == "top_talkers") then
|
||||
printTopTalkers()
|
||||
end
|
||||
if (subpage_active == "mysql") then
|
||||
printMysql()
|
||||
end
|
||||
if (subpage_active == "alerts") then
|
||||
printAlerts()
|
||||
end
|
||||
if (subpage_active == "nbox") then
|
||||
if (ntop.isPro()) then
|
||||
printNbox()
|
||||
end
|
||||
end
|
||||
if (subpage_active == "user_auth") then
|
||||
if (ntop.isPro()) then
|
||||
printUserAuth()
|
||||
end
|
||||
end
|
||||
if (subpage_active == "data_purge") then
|
||||
printDataPurge()
|
||||
end
|
||||
if (subpage_active == "stats_rrds") then
|
||||
printStatsRrds()
|
||||
end
|
||||
|
||||
print[[
|
||||
</td></tr>
|
||||
</table>
|
||||
]]
|
||||
|
||||
-- ================================================================================
|
||||
|
||||
-- ================================================================================
|
||||
print('<tr><th colspan=2 class="info">Protocol/Networks Stats RRDs</th></tr>')
|
||||
prefsInputField("Days for raw stats", "Number of days for which raw stats are kept. Default: 1.", "other_rrd_raw_days", prefs.other_rrd_raw_days)
|
||||
--prefsInputField("Days for 1 min resolution stats", "Number of days for which stats are kept in 1 min resolution. Default: 30.", "other_rrd_1min_days", prefs.other_rrd_1min_days)
|
||||
prefsInputField("Days for 1 hour resolution stats", "Number of days for which stats are kept in 1 hour resolution. Default: 100.", "other_rrd_1h_days", prefs.other_rrd_1h_days)
|
||||
prefsInputField("Days for 1 day resolution stats", "Number of days for which stats are kept in 1 day resolution. Default: 365.", "other_rrd_1d_days", prefs.other_rrd_1d_days)
|
||||
|
||||
-- ================================================================================
|
||||
|
||||
print [[
|
||||
</table>
|
||||
]]
|
||||
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue