-- -- (C) 2013 - ntop.org -- -- debug lua example -- Set package.path information to be able to require lua module dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" -- Here you can choose the type of your HTTP message {'text/html','application/json',...}. There are two main function that you can use: -- function sendHTTPHeaderIfName(mime, ifname, maxage) -- function sendHTTPHeader(mime) -- For more information please read the scripts/lua/modules/lua_utils.lua file. sendHTTPHeader('text/html; charset=iso-8859-1') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print('
There are five type of event:
') print('Use the following function to modify the current trace level.
') print('setTraceLevel(p_trace_level)resetTraceLevel()')
print('There are two type of trace:
') print('Default: Only the TRACE_ERROR is printed.
') print('Code:
') print('
traceError(TRACE_DEBUG,TRACE_CONSOLE, "Trace: ".._GET["trace"])')
end
if(_GET["trace"] == "web") then
print('Code:
') print('
traceError(TRACE_DEBUG,TRACE_WEB, "Trace: ".._GET["trace"])')
end
if(_GET["trace"] == "console") then
print('Output:
') print('
Output:
') print('
#date #time [#calling_function] [#filename:#currentline] #trace_level: #message')
print('NB: #calling_function will be show only if it is different from #filename:#currentline
')
print('
Any lua scripts can be executed by passing one or more parameters. The simple way to get an input variable is "variable_name = _GET["variable_name"]".
Try with this: /lua/examples/debug.lua?host=192.168.1.10&myparam=myparam&var=123456
')
for key, value in pairs(_GET) do
print(key.."="..value.."
")
end
-- printGETParameters(_GET)
print('