--
-- (C) 2013-17 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "flow_utils"
sendHTTPHeader('text/html; charset=iso-8859-1')
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
interface.select(ifname)
ifstats = interface.getStats()
print('
'..ifstats.name..' Preferences
\n')
key = 'ntopng.prefs.'..ifname..'.name'
if(_POST["ifName"] ~= nil) then
custom_name = tostring(_POST["ifName"])
ntop.setCache(key, custom_name)
else
custom_name = ntop.getCache(key)
end
key = 'ntopng.prefs.'..ifname..'.speed'
ifstats.name = tostring(ifstats.name)
-- Ask Redis for actual speed
ifSpeed = ntop.getCache(key)
if((_POST["ifSpeed"] ~= nil) and (string.len(_POST["ifSpeed"]) > 0)) then
ifSpeed = _POST["ifSpeed"]
if(ifSpeed ~= nil) then
ifSpeed = tonumber(ifSpeed)
end
-- ifSpeed == nil assign the max value of speed
if(ifSpeed == nil) then
ifSpeed = ifstats.speed
end
-- set Redis cache for the speed to the associated interface
ntop.setCache(key, tostring(ifSpeed))
elseif _POST["ifSpeed"] ~= nil and _POST["ifSpeed"] == "" then
-- reset to the default detected value
ntop.setCache(key, tostring(ifstats.speed))
ifSpeed = ifstats.speed
else
if((ifSpeed ~= nil) and (string.len(ifSpeed) > 0)) then
ifSpeed = tonumber(ifSpeed)
else
-- ifSpeed == nil assign the max value of speed
ifSpeed = ifstats.speed
end
end
ifSpeed = math.floor(ifSpeed+0.5)
print [[
]]
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")