mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Enhanced the host Lua API for host checks
This commit is contained in:
parent
cb4a100b3b
commit
4212c6225d
8 changed files with 232 additions and 15 deletions
|
|
@ -10,6 +10,30 @@
|
|||
-- that ntopng has in memory
|
||||
--
|
||||
|
||||
-- the function below is for *DEBUG ONLY* purposes to test the implementation
|
||||
function dump_host()
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require "lua_utils"
|
||||
|
||||
local rsp = {}
|
||||
|
||||
rsp.ip = host.ip()
|
||||
rsp.mac = host.mac()
|
||||
rsp.name = host.name()
|
||||
rsp.vlan_id = host.vlan_id()
|
||||
rsp.is_unicast = host.is_unicast()
|
||||
rsp.is_multicast = host.is_multicast()
|
||||
rsp.is_broadcast = host.is_broadcast()
|
||||
rsp.is_blacklisted = host.is_blacklisted()
|
||||
rsp.bytes_sent = host.bytes_sent()
|
||||
rsp.bytes_rcvd = host.bytes_rcvd()
|
||||
rsp.bytes = host.bytes()
|
||||
rsp.l7 = host.l7()
|
||||
|
||||
io.write("----------------------------\n")
|
||||
tprint(rsp)
|
||||
end
|
||||
|
||||
|
||||
-- the function below shows an example of how a host alert is triggered
|
||||
|
|
@ -21,5 +45,12 @@ function trigger_dummy_alert()
|
|||
host.triggerAlert(score, message)
|
||||
end
|
||||
|
||||
-- dump_host()
|
||||
|
||||
-- Set this host as already visited in case we want to visit it once
|
||||
-- With this call, a host is visited only once. Do not call the method below
|
||||
-- if you want to visit the host periodically
|
||||
host.skipVisitedHost()
|
||||
|
||||
-- IMPORTANT: do not forget this return at the end of the script
|
||||
return(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue