Back to Ntopng

ntopng Lua API Reference (`interface.*` bindings)

doc/README.lua_interface_api.md

6.642.5 KB
Original Source

ntopng Lua API Reference (interface.* bindings)

This document describes all C→Lua bindings exposed as interface.* functions via src/LuaEngineInterface.cpp. It is intended both for human developers writing Lua scripts and as a machine-readable reference for AI-assisted code generation (e.g. Claude Code in this repository).


Table of Contents

  1. How interface.* works
  2. REST API development guide
  3. Interface Selection & Identity
  4. Interface Type & Capability Flags
  5. Interface Statistics
  6. Host Information
  7. Flow Information
  8. MAC Address Information
  9. nDPI Protocol & Category
  10. Alerts
  11. SNMP & Flow Devices
  12. Host Pools & Quotas
  13. Network / AS / VLAN / Country Statistics
  14. Service & Periodicity Maps
  15. ACL Management
  16. Network Discovery (mDNS / ARP / Ping)
  17. Live Capture & PCAP
  18. RRD Queue
  19. ClickHouse
  20. sFlow
  21. eBPF / Containers
  22. nEdge / L7 Shaping & Policy
  23. RADIUS Accounting (nEdge)
  24. Miscellaneous

1. How interface.* works

Selecting an interface first

All interface.* functions operate on the currently selected interface stored in the Lua VM state. You must call interface.select(ifid) before any other interface.* call — otherwise the VM uses a fallback interface (the first available).

lua
-- Always select an interface first
local ifid = _GET["ifid"] or interface.getFirstInterfaceId()
interface.select(tostring(ifid))

C→Lua registration

Every Lua function in _ntop_interface_reg[] (bottom of src/LuaEngineInterface.cpp) follows this pattern:

c
// 1. Implement a static C function
static int ntop_my_function(lua_State* vm) {
    NetworkInterface* ntop_interface = getCurrentInterface(vm);
    if (!ntop_interface) return (CONST_LUA_ERROR);

    ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING);
    const char* arg = lua_tostring(vm, 1);

    lua_pushstring(vm, result);
    return CONST_LUA_OK;  // or CONST_LUA_ERROR
}

// 2. Register it
{ "myFunction", ntop_my_function },   // called as interface.myFunction(...)

Standard boilerplate (REST endpoints using interface.*)

lua
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path

require "lua_utils"
local json       = require("dkjson")
local rest_utils = require("rest_utils")

-- Select interface
local ifid = _GET["ifid"] or interface.getFirstInterfaceId()
interface.select(tostring(ifid))

2. REST API development guide

File location

REST endpoints live at:

scripts/lua/rest/v2/<method>/<resource>/<action>.lua

Examples:

  • scripts/lua/rest/v2/get/interface/data.lua
  • scripts/lua/rest/v2/get/host/data.lua
  • scripts/lua/rest/v2/get/flow/active.lua

Minimal REST endpoint template

lua
-- scripts/lua/rest/v2/get/interface/my_endpoint.lua
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path

require "lua_utils"
local json       = require("dkjson")
local rest_utils = require("rest_utils")

-- Auth check
if not isAdministratorOrPrintErr() then
  rest_utils.answer(rest_utils.consts.err.not_granted)
  return
end

-- Param validation
local ifid = _GET["ifid"]
if not ifid then
  rest_utils.answer(rest_utils.consts.err.invalid_args)
  return
end

-- Select interface and fetch data
interface.select(tostring(ifid))
local stats = interface.getStats()

rest_utils.answer(rest_utils.consts.success.ok, stats)

rest_utils.consts error table (most common)

ConstantHTTP codeMeaning
success.ok200OK
err.not_granted401Not authorized
err.invalid_args400Bad/missing params
err.internal_error500C-level error
err.not_found404Resource not found
err.not_allowed405Method not allowed

Common REST patterns

Pattern 1 — Return interface stats

lua
interface.select(tostring(ifid))
local stats = interface.getStats()
rest_utils.answer(rest_utils.consts.success.ok, stats)

Pattern 2 — Return host info

lua
interface.select(tostring(ifid))
local host = _GET["host"]
local vlan  = _GET["vlan"] or 0
local info  = interface.getHostInfo(host, vlan)
if not info then
  rest_utils.answer(rest_utils.consts.err.not_found)
  return
end
rest_utils.answer(rest_utils.consts.success.ok, info)

Pattern 3 — Paginated flow listing

lua
interface.select(tostring(ifid))
local flows = interface.getFlowsInfo({
  currentPage  = tonumber(_GET["page"]) or 1,
  perPage      = tonumber(_GET["perPage"]) or 10,
  sortColumn   = _GET["sortColumn"] or "bytes",
  sortOrder    = _GET["sortOrder"] or "desc",
})
rest_utils.answer(rest_utils.consts.success.ok, flows)

Pattern 4 — nDPI stats for an interface

lua
interface.select(tostring(ifid))
local ndpi = interface.getnDPIStats()
rest_utils.answer(rest_utils.consts.success.ok, ndpi)

3. Interface Selection & Identity

Lua callReturnsDescription
interface.getIfNames([exclude_viewed])tableReturns a table mapping interface IDs (as string keys) to interface names. Pass true to exclude viewed sub-interfaces.
interface.getFirstInterfaceId()integerReturns the numeric ID of the first available network interface. Useful as a default when no ifid is supplied.
interface.select(ifid)nilSelects the active interface for all subsequent interface.* calls in this Lua VM. ifid may be a number or string. Must be called before any other interface. function.*
interface.getId()integerReturns the numeric ID of the currently selected interface.
interface.getName()stringReturns the name (e.g. "eth0") of the currently selected interface.
interface.getMasterInterfaceId()integerReturns the numeric ID of the parent (master) interface when this is a sub-interface.
interface.isValidIfId(ifid)booleanReturns true if the given interface ID or name corresponds to an existing, enabled interface.
interface.getMaxIfSpeed([ifname_or_id])integerReturns the configured maximum speed in bps. Defaults to the current interface if no argument given.
interface.getEndpoint()stringReturns the capture endpoint/source string (e.g. "eth0", "tcp://127.0.0.1:1234").
interface.getIfMac()stringReturns the hardware MAC address of the currently selected interface.
interface.name2id(ifname)integerConverts an interface name string to its numeric ID.

4. Interface Type & Capability Flags

Lua callReturnsDescription
interface.isPacketInterface()booleantrue if this is a live packet-capture interface (not ZMQ/sFlow/eBPF).
interface.isDiscoverableInterface()booleantrue if network discovery is supported on this interface.
interface.isBridgeInterface()booleantrue if this interface is operating in nEdge bridge/inline mode.
interface.isPcapDumpInterface()booleantrue if this is a PCAP replay/dump interface.
interface.isDatabaseViewInterface()booleantrue if this is a ClickHouse/DB view interface.
interface.isZMQInterface()booleantrue if this interface receives flows via ZMQ (nProbe integration).
interface.isView()booleantrue if this is an aggregated view interface covering multiple sub-interfaces.
interface.isViewed()booleantrue if this interface is aggregated by a view interface.
interface.viewedBy()integerReturns the ID of the view interface that aggregates this interface, or nil.
interface.isLoopback()booleantrue if this is a loopback interface.
interface.isRunning()booleantrue if the interface capture thread is currently running.
interface.isIdle()booleantrue if the interface is idle (no recent traffic).
interface.setInterfaceIdleState(is_idle)nilSets the idle state of the interface (used by management scripts).
interface.isSubInterface()booleantrue if this is a disaggregated sub-interface.
interface.isSyslogInterface()booleantrue if this interface receives syslog events.
interface.hasVLANs()booleantrue if the interface has observed VLAN-tagged traffic.
interface.hasEBPF()booleantrue if the interface has received eBPF process-level events.
interface.hasExternalAlerts()booleantrue if the interface has received external (injected) alerts.

5. Interface Statistics

Lua callReturnsDescription
interface.getStats()tableReturns comprehensive real-time statistics for the interface (bytes, packets, flows, hosts, drops, throughput, etc.).
interface.getStatsUpdateFreq()integerReturns the statistics update frequency in seconds for this interface.
interface.getSecsToFirstData()integerReturns seconds elapsed since the interface first received traffic.
interface.updateDirectionStats()nilForces an update of per-direction (upload/download) statistics.
interface.updateTopSites()nilTriggers a refresh of the top-sites (popular domains) tracking.
interface.getThroughput()tableReturns current throughput in bps and pps in both directions ({"upload_bps":…, "download_bps":…, …}).
interface.getHashTablesStats()tableReturns size and usage statistics for the interface hash tables (hosts, flows, MACs, etc.).
interface.getPeriodicActivitiesStats()tableReturns timing and execution statistics for all periodic scripts on this interface.
interface.getQueuesStats()tableReturns enqueue/dequeue statistics for internal interface queues.
interface.setPeriodicActivityProgress(activity, progress_pct)nilUpdates the completion percentage for a running periodic script (used internally by periodic scripts).
interface.getActiveFlowsStats([params])tableReturns statistics on currently active flows grouped by various dimensions.
interface.getLiveASNStats(asn)tableReturns live (real-time) traffic statistics for a specific ASN.
interface.getAnomalies()tableReturns a table of currently active behavioral anomalies on this interface.
interface.getScore()tableReturns the current alert score breakdown for this interface.
interface.getProtocolFlowsStats()tableReturns per-L4-protocol flow and byte statistics.
interface.getVLANFlowsStats()tableReturns per-VLAN flow and byte statistics.
interface.resetCounters([only_drops])nilResets traffic counters for the interface. Pass true to reset only drop counters.
interface.resetBroadcastDomains()nilResets all learned broadcast domain state for the interface.
interface.incSyslogStats(stat_name, n)nilIncrements a named syslog processing statistics counter.

6. Host Information

Host counts

Lua callReturnsDescription
interface.getNumHosts()integerTotal count of active hosts (local + remote).
interface.getNumLocalHosts()integerCount of currently active local hosts.
interface.getNumLocalRxOnlyHosts()integerCount of local hosts seen only in the receive direction.
interface.getNumFlows()integerTotal count of active flows on this interface.

Host listing

Lua callReturnsDescription
interface.getHostsInfo([params])tableReturns information for all hosts (local + remote) on the interface. params table supports: currentPage, perPage, sortColumn, sortOrder, host, vlan, country, os, asn, vlan_id, pool, network, filter.
interface.getLocalHostsInfo([params])tableReturns information for local hosts only. Same params as getHostsInfo.
interface.getLocalHostsInfoNoTX([params])tableReturns local hosts that have received but not sent any traffic.
interface.getLocalHostsInfoNoTXTCP([params])tableReturns local hosts that have not sent any TCP traffic.
interface.getRemoteHostsInfo([params])tableReturns information for remote (non-local) hosts only.
interface.getRemoteHostsInfoNoTX([params])tableReturns remote hosts that have received but not sent any traffic.
interface.getRemoteHostsInfoNoTXTCP([params])tableReturns remote hosts that have not sent any TCP traffic.
interface.getRxOnlyHostsList()tableReturns hosts that have only been seen in the receive direction.
interface.getBroadcastDomainHostsInfo([params])tableReturns hosts that are part of broadcast domains on this interface.
interface.getBroadcastMulticastHostsInfo([params])tableReturns broadcast/multicast group hosts on this interface.
interface.getPublicHostsInfo([params])tableReturns hosts with public (routable) IP addresses.
interface.getInterfaceHosts([include_details])tableReturns all active hosts as a flat array.
interface.getBatchedHostsInfo(cursor, count)tableReturns a paginated batch of host records for all hosts.
interface.getBatchedLocalHostsInfo(cursor, count)tableReturns a paginated batch of local host records.
interface.getBatchedRemoteHostsInfo(cursor, count)tableReturns a paginated batch of remote host records.
interface.getBatchedLocalHostsTs(cursor, count)tableReturns a paginated batch of local host time-series data.

Single-host queries

Lua callReturnsDescription
interface.isHostActive(host[,vlan])booleanReturns true if the specified host is currently active.
interface.getHostInfo(host[,vlan])tableReturns comprehensive information for a specific host (bytes, packets, flows, nDPI breakdown, alerts, score, etc.).
interface.getHostMinInfo(host[,vlan])tableReturns minimal host info (bytes, packets, score) for lightweight polling.
interface.getHostCountry(host[,vlan])stringReturns the 2-letter ISO country code for a host's IP via GeoIP.
interface.findHost(host[,vlan])tableFinds a host by IP or name and returns its info, or nil if not active.
interface.findHostByMac(mac)tableFinds a host by its MAC address and returns its info.
interface.getHostAttributes(host, vlan)tableReturns classification attributes for a host (device type, OS, category).
interface.getHostsByPort(port, proto)tableReturns hosts using the specified server port and transport protocol.
interface.getHostsByService(service_name)tableReturns hosts using a specific application service.
interface.getHostsPorts(params)tableReturns a list of server ports used by hosts on this interface.
interface.getnDPIHostStats(host, vlan)tableReturns per-protocol nDPI traffic statistics for a specific host.
interface.getAddressInfo(ip_or_name)tableReturns comprehensive address information (DNS, geolocation, ASN) for an IP or hostname.

Host modification

Lua callReturnsDescription
interface.setHostOperatingSystem(host, vlan, os_id)nilOverrides the detected operating system for a host.
interface.setHostResolvedName(host, vlan, name)nilSets the resolved DNS name for a host.
interface.resetHostStats(host, vlan)nilResets all traffic statistics for a specific host.
interface.resetHostTopSites(host, vlan)nilResets the top-sites statistics for a specific host.
interface.deleteHostData(host, vlan)nilPermanently deletes all stored data for a specific host.
interface.updateHostTrafficPolicy(host, vlan)nilForces a traffic policy refresh for a specific host.
interface.reloadHostPrefs(host[,vlan])nilReloads per-host preference overrides from Redis for a specific host.
interface.dropHostTraffic(host, vlan)nilMarks all traffic for a host for dropping (nEdge inline mode).
interface.addDataToLocalHostAssets(ip, data_table)nilAdds asset attributes to a local host's discovery record.
interface.removeDataFromLocalHostAssets(ip)nilRemoves a local host's asset discovery record.
interface.addMacsIpAddresses()nilForces re-association of MAC addresses with their known IP addresses.

7. Flow Information

Lua callReturnsDescription
interface.getFlowsInfo([params_table])tableReturns detailed information for all active flows. params_table supports currentPage, perPage, sortColumn, sortOrder, host, vlan, application, category, l4proto, status, alert_type, traffic_type.
interface.getBatchedFlowsInfo(cursor, count[,filter])tableReturns a paginated batch of active flow records.
interface.getGroupedFlows(params_table)tableReturns flows aggregated (grouped) by a specified key field.
interface.getFlowsStats()tableReturns aggregate flow statistics counts for the interface.
interface.getFlowsStatus()tableReturns flow status distribution (normal, warning, alert) for this interface.
interface.getLocalServerPorts(proto)tableReturns server ports observed on local hosts for a given L4 protocol.
interface.listHTTPhosts([filter])tableReturns a list of hosts with active HTTP/HTTPS flows.
interface.findFlowByKeyAndHashId(key, hash_id)tableFinds and returns an active flow by its hash key and bucket ID.
interface.findFlowByTuple(src_ip, src_port, dst_ip, dst_port, proto[,vlan])tableFinds and returns an active flow by its 5-tuple.
interface.getFlowKey(src_ip, src_port, dst_ip, dst_port, proto[,vlan])integerComputes the hash key for a flow 5-tuple.
interface.findPidFlows(pid)tableReturns active flows associated with a specific process ID (eBPF).
interface.findNameFlows(proc_name)tableReturns active flows associated with a process name (eBPF).

Flow manipulation

Lua callReturnsDescription
interface.dropFlowTraffic(key, hash_id)nilMarks a specific flow for traffic dropping (nEdge inline mode).
interface.dropMultipleFlowsTraffic(flows_table)nilDrops traffic for multiple flows at once (nEdge inline mode).
interface.processFlow(flow_table)nilInjects a flow record from ZMQ/sFlow into the interface for processing (non-nEdge).

ZMQ flow fields

Lua callReturnsDescription
interface.getAllZMQFlowFieldDescr()tableReturns descriptions of all ZMQ flow template fields (non-nEdge).
interface.getZMQFlowFieldDescr(field_id)tableReturns description of a specific ZMQ flow field (non-nEdge).

8. MAC Address Information

Lua callReturnsDescription
interface.getActiveMacs([vlan_id])tableReturns currently active MAC addresses on the interface.
interface.getMacsInfo([params])tableReturns detailed information for MAC addresses on the interface.
interface.getBatchedMacsInfo(cursor, count)tableReturns a paginated batch of MAC address records.
interface.isMacActive(mac)booleanReturns true if the given MAC address is currently active.
interface.getMacInfo(mac)tableReturns detailed information for a specific MAC address.
interface.getMacHosts(mac)tableReturns all hosts associated with a given MAC address.
interface.getMacManufacturers([params])tableReturns a grouped count of MAC addresses by their OUI manufacturer.
interface.getMacDeviceTypes()tableReturns a mapping of MAC device type IDs to their names and counts.
interface.isMulticastMac(mac)booleanReturns true if the given MAC address is a multicast/broadcast address.
interface.appendMacEvent(mac, event_type)nilAppends a captive-portal event (login/logout) for a MAC address (nEdge).
interface.findMacPool(mac)integerReturns the host pool ID that a MAC address belongs to.
interface.findMemberPool(host[,vlan])integerReturns the host pool ID that a host belongs to.
interface.resetMacStats(mac)nilResets all traffic statistics for a specific MAC address.
interface.deleteMacData(mac)nilPermanently deletes all stored data for a specific MAC address.

9. nDPI Protocol & Category

Protocol/category lookup

Lua callReturnsDescription
interface.getnDPIProtocols([category_id])tableReturns all nDPI protocol IDs and names, optionally filtered by category.
interface.getnDPICategories()tableReturns all nDPI category IDs and their names.
interface.getnDPIProtoName(proto_id)stringReturns the human-readable name for an nDPI protocol ID.
interface.getnDPIFullProtoName(proto_id)stringReturns the full hierarchical name (e.g. 'HTTP.Facebook') for an nDPI protocol.
interface.getnDPIProtoId(proto_name)integerReturns the nDPI protocol ID for a given protocol name string.
interface.getnDPICategoryId(category_name)integerReturns the nDPI category ID for a given category name string.
interface.getnDPICategoryName(category_id)stringReturns the human-readable name for an nDPI category ID.
interface.getnDPIProtoBreed(proto_id)stringReturns the nDPI breed (e.g. 'Safe', 'Unsafe') for a protocol.

Protocol traffic statistics

Lua callReturnsDescription
interface.getnDPIFlowsCount()tableReturns per-protocol flow count statistics for this interface.
interface.getnDPIStats([host,vlan])tableReturns per-protocol byte/flow statistics, optionally filtered to a specific host.
interface.getnDPIHostStats(host, vlan)tableReturns per-protocol nDPI traffic statistics for a specific host.

nDPI data recording

Lua callReturnsDescription
interface.dumpnDPIProtocolId(host, vlan, proto_id)nilRecords a protocol observation for a host to the nDPI dump table.
interface.dumpnDPICategoryId(host, vlan, cat_id)nilRecords a category observation for a host to the nDPI dump table.

10. Alerts

Alert store queries

Lua callReturnsDescription
interface.getAlerts(params_table)tableReturns alerts matching the given filter criteria. params_table supports status ("engaged", "past"), alert_type, alert_severity, entity, entity_val, page, perPage, order_by.
interface.getEngagedAlerts([params_table])tableReturns all currently engaged (active/unresolved) alerts for this interface.
interface.alert_store_query(query[,limit_rows])nilExecutes a raw SQL query on the interface alert database and streams JSON to the HTTP response.

Alert lifecycle

Lua callReturnsDescription
interface.storeTriggeredAlert(alert_table)nilStores a triggered alert record in the interface alert database.
interface.releaseTriggeredAlert(alert_id)nilMarks a triggered alert as resolved/released.
interface.triggerExternalAlert(alert_table)nilStores an externally generated alert into the interface alert store.
interface.releaseExternalAlert(alert_id)nilMarks an external alert as resolved/released.
interface.releaseEngagedAlerts(script_key, subtype, alert_type)nilBulk-releases engaged alerts matching a script key and type.
interface.triggerTrafficAlert(params_table)nilTriggers a traffic-threshold alert with configurable severity and details.

Alert context (script helpers)

Lua callReturnsDescription
interface.getCachedAlertValue(key)stringRetrieves a cached alert context value by key for this interface.
interface.setCachedAlertValue(key, value[, expiry])nilStores a cached alert context value for this interface.
interface.checkContext(context_key)nilValidates and initializes alert context for a script execution.

11. SNMP & Flow Devices

Lua callReturnsDescription
interface.getSNMPStats()tableReturns SNMP-polled statistics for the current interface (Pro only).
interface.getFlowDevices()tableReturns flow exporters (NetFlow/IPFIX probes) seen on this interface (Pro).
interface.getFlowDeviceInfo(device_ip)tableReturns detailed information for a specific flow-exporting device (Pro).
interface.getFlowDeviceInfoByIP(ip)tableReturns flow device information looked up by IP address (Pro).
interface.refreshFlowDeviceSiteId(device_ip)nilRefreshes the site-ID mapping for a flow-exporting device (Pro).

12. Host Pools & Quotas

Lua callReturnsDescription
interface.getHostPoolsInfo()tableReturns configuration and member counts for all host pools on this interface.
interface.getHostPoolsStats()tableReturns traffic statistics for all host pools on this interface.
interface.getHostPoolStats(pool_id)tableReturns traffic statistics for a specific host pool.
interface.getHostUsedQuotasStats(host, vlan)tableReturns quota usage statistics for a specific host (nEdge Pro).
interface.resetPoolsQuotas([pool_id])nilResets traffic quota counters for all or a specific host pool (nEdge Pro).
interface.flushPoolDynamicBlacklist(pool_id)nilClears the dynamic blacklist for a host pool (nEdge Pro).
interface.getPoolDynamicBlacklistStats(pool_id)tableReturns blacklist statistics for a host pool (nEdge Pro).
interface.getPoolDynamicBlacklistMembers(pool_id)tableReturns the current dynamic blacklist members for a pool (nEdge Pro).

13. Network / AS / VLAN / Country Statistics

Networks

Lua callReturnsDescription
interface.getNetworksStats()tableReturns per-local-network traffic statistics.
interface.getNetworkStats(network_id)tableReturns traffic statistics for a specific local network by ID.

Autonomous Systems

Lua callReturnsDescription
interface.getASesInfo([params])tableReturns statistics for all Autonomous Systems observed on this interface.
interface.getASInfo(asn)tableReturns traffic statistics for a specific Autonomous System number.
interface.aggregateASNFlows()nilTriggers aggregation of flows by Autonomous System Number.
interface.aggregateSiteFlows()nilTriggers aggregation of flows by site/organization (Pro).

VLANs

Lua callReturnsDescription
interface.getVLANsList()tableReturns a list of VLAN IDs seen on this interface.
interface.getVLANsInfo([params])tableReturns per-VLAN traffic statistics for this interface.
interface.getVLANInfo(vlan_id)tableReturns traffic statistics for a specific VLAN.

Countries

Lua callReturnsDescription
interface.getCountriesInfo([params])tableReturns per-country traffic statistics observed on this interface.
interface.getCountryInfo(country_code)tableReturns traffic statistics for a specific country on this interface.
interface.convertCountryCode2U16(code)integerConverts a 2-letter ISO country code string to a 16-bit integer.
interface.convertCountryU162Code(n)stringConverts a 16-bit country integer back to its ISO country code string.

Observation Points

Lua callReturnsDescription
interface.getObsPointsInfo([params])tableReturns statistics for all observation points seen on this interface.
interface.getObsPointInfo(obs_point_id)tableReturns statistics for a specific observation point.
interface.prepareDeleteObsPoint(obs_point_id)nilMarks an observation point for deletion (first step of two-step delete).
interface.deleteObsPoint(obs_point_id)nilCompletes deletion of a previously prepared observation point.

14. Service & Periodicity Maps

These functions are available in Pro/Enterprise editions with behavioral analysis enabled.

Lua callReturnsDescription
interface.isBehaviourAnalysisAvailable()booleanReturns true if behavioral analysis (periodicity/service maps) is available.
interface.periodicityMap([params])tableReturns the periodicity map data for hosts and protocols on this interface.
interface.flushPeriodicityMap()nilClears all learned periodicity map data for this interface.
interface.periodicityMapFilterList()tableReturns available filter options for the periodicity map view.
interface.serviceMap([params])tableReturns the service map data (host-to-service relationships) for this interface.
interface.flushServiceMap()nilClears all learned service map data for this interface.
interface.serviceMapFilterList()tableReturns available filter options for the service map view.
interface.serviceMapLearningStatus()tableReturns whether the service map is in learning or enforcement mode.
interface.serviceMapSetStatus(key, status)nilSets the learning/active status for a single service map entry.
interface.serviceMapSetMultipleStatus(entries_table)nilSets status for multiple service map entries in a single call.

15. ACL Management

Lua callReturnsDescription
interface.insertIPACL(cidr, is_allow)nilInserts an IP CIDR rule into the interface ACL. Pass true for allow, false for block.
interface.removeIPACL(cidr)nilRemoves an IP CIDR rule from the interface ACL.
interface.insertMacACL(mac, is_allow)nilInserts a MAC address rule into the interface ACL.
interface.removeMacACL(mac)nilRemoves a MAC address rule from the interface ACL.
interface.getACLInfo()tableReturns the current IP and MAC ACL rules for this interface.

16. Network Discovery (mDNS / ARP / Ping)

Lua callReturnsDescription
interface.discoverHosts(timeout_ms)tableTriggers active host discovery (ping sweep) on the interface.
interface.arpScanHosts()tableTriggers ARP scan discovery of hosts on the interface.
interface.mdnsQueueAnyQuery(service_type)nilQueues an mDNS ANY query for a service type for background resolution.
interface.mdnsQueueNameToResolve(name)nilQueues an mDNS/Bonjour name resolution request.
interface.mdnsReadQueuedResponses()tableReads and returns pending mDNS resolution results.

17. Live Capture & PCAP

Lua callReturnsDescription
interface.liveCapture(params_table)tableStarts a live packet capture session on the interface; returns session info.
interface.stopLiveCapture(capture_id)nilStops a running live capture session by its ID.
interface.dumpLiveCaptures()tableReturns a table listing active live-capture sessions on this interface.
interface.captureToPcap(params_table)nilStarts a PCAP file capture session with BPF filter and duration.
interface.isCaptureRunning()booleanReturns true if a PCAP file capture session is currently active.
interface.stopRunningCapture()nilStops the currently running PCAP file capture session.

18. RRD Queue

The RRD queue is used by periodic scripts to asynchronously persist time-series data.

Lua callReturnsDescription
interface.rrd_enqueue(rrd_path, value, step)nilEnqueues an RRD update for background writing.
interface.rrd_dequeue()tableDequeues a pending RRD update task.
interface.rrd_queue_length()integerReturns the number of pending items in the RRD update queue.
interface.appendInfluxDB(json_points)nilAppends time-series data points to the InfluxDB write queue.

19. ClickHouse

Available in Enterprise/Pro editions with ClickHouse integration enabled.

Lua callReturnsDescription
interface.clickhouseExecCSVQuery(sql)nilExecutes a ClickHouse SQL query and streams CSV results to the HTTP response.
interface.clickhouseArchiveData()nilTriggers archival of old interface data to ClickHouse storage.
interface.execSQLWrite(sql)nilExecutes a SQL write statement on the ClickHouse interface database.
interface.chTsEnqueue(json_data)nilEnqueues a ClickHouse time-series data batch for async insertion.
interface.chTsDequeue()stringDequeues a pending ClickHouse time-series data batch.
interface.chTsQueueLen()integerReturns the number of pending ClickHouse time-series batches in the queue.
interface.execInMemoryQuery(sql)tableExecutes a SQL query against the in-memory flow/host tables.
interface.execSQLQuery(sql)tableExecutes a SQL query against the interface's local SQLite database.

20. sFlow

Lua callReturnsDescription
interface.getSFlowDevices()tableReturns sFlow agent devices seen on this interface.
interface.getSFlowDeviceInfo(agent_ip)tableReturns per-port statistics for a specific sFlow agent.

21. eBPF / Containers

Lua callReturnsDescription
interface.getPodsStats()tableReturns statistics for Kubernetes pods observed on this interface (eBPF).
interface.getContainersStats()tableReturns statistics for containers observed on this interface (eBPF).
interface.reloadCompanions()nilReloads companion interface assignments from Redis configuration.

22. nEdge / L7 Shaping & Policy

These functions are available only in nEdge (inline/bridge) deployments.

Lua callReturnsDescription
interface.reloadL7Rules(pool_id)nilReloads L7 (nDPI-based) shaping rules for a host pool.
interface.reloadShapers()nilReloads traffic shaper configurations from Redis.
interface.updateFlowsShapers()nilTriggers an update of traffic shaper state for all active flows.
interface.getPolicyChangeMarker()integerReturns a monotonic counter incremented on each policy change.
interface.getl7PolicyInfo(pool_id)tableReturns the L7 policy rules for a host pool.
interface.addLanIPAddress(ip_cidr)nilAdds an IP/CIDR to the LAN address list for nEdge routing decisions.
interface.updateTrafficMirrored(enabled)nilUpdates the traffic-mirrored flag for the interface.
interface.updateSmartRecording(enabled)nilUpdates the smart-recording setting for the interface.
interface.updateDynIfaceTrafficPolicy(policy)nilUpdates the dynamic traffic policy for this interface.
interface.updatePushFiltersSettings(params)nilUpdates push-filter settings (e.g. BPF rules) for the interface.
interface.updateLbdIdentifier(use_mac)nilUpdates the local broadcast domain host identifier (IP vs MAC).
interface.updateFlowsOnlyInterface(enabled)nilSets the flows-only flag (no host tracking) on the interface.
interface.loadScalingFactorPrefs()nilReloads interface throughput scaling factor preferences from Redis.
interface.reloadGwMacs()nilReloads the list of known gateway MAC addresses from Redis.
interface.reloadDhcpRanges()nilReloads DHCP address ranges from Redis configuration.

23. RADIUS Accounting (nEdge)

Used by captive portal integrations to send RADIUS accounting packets.

Lua callReturnsDescription
interface.radiusAccountingStart(params)nilSends a RADIUS Accounting-Start packet for a captive-portal session.
interface.radiusAccountingStop(params)nilSends a RADIUS Accounting-Stop packet for a captive-portal session.
interface.radiusAccountingUpdate(params)nilSends a RADIUS Accounting-Update (Interim-Update) for an active session.

24. Miscellaneous

Lua callReturnsDescription
interface.updateSyslogProducers()nilReloads syslog producer configuration for this interface (non-nEdge).
interface.updateIPReassignment(params_table)nilHandles an IP address reassignment event (DHCP lease change).
interface.updateRanking(ranking_table)nilUpdates the site/host ranking data for this interface (Pro).
interface.swapHostnameIPCache()nilSwaps the hostname-to-IP cache with a newly built version.
interface.incSyslogStats(stat_name, n)nilIncrements a named syslog processing statistics counter.

Appendix: Complete Function Index

All 245 interface.* functions in alphabetical order:

addDataToLocalHostAssets · addLanIPAddress · addMacsIpAddresses · aggregateASNFlows · aggregateSiteFlows · alert_store_query · appendInfluxDB · appendMacEvent · arpScanHosts · captureToPcap · checkContext · chTsDequeue · chTsEnqueue · chTsQueueLen · clickhouseArchiveData · clickhouseExecCSVQuery · convertCountryCode2U16 · convertCountryU162Code · deleteHostData · deleteMacData · deleteObsPoint · discoverHosts · dropFlowTraffic · dropHostTraffic · dropMultipleFlowsTraffic · dumpLiveCaptures · dumpnDPICategoryId · dumpnDPIProtocolId · execInMemoryQuery · execSQLQuery · execSQLWrite · findFlowByKeyAndHashId · findFlowByTuple · findHost · findHostByMac · findMacPool · findMemberPool · findNameFlows · findPidFlows · flushPeriodicityMap · flushPoolDynamicBlacklist · flushServiceMap · getACLInfo · getASesInfo · getASInfo · getActiveMacs · getActiveFlowsStats · getAddressInfo · getAnomalies · getAlerts · getAllZMQFlowFieldDescr · getBatchedFlowsInfo · getBatchedHostsInfo · getBatchedLocalHostsInfo · getBatchedLocalHostsTs · getBatchedMacsInfo · getBatchedRemoteHostsInfo · getBroadcastDomainHostsInfo · getBroadcastMulticastHostsInfo · getContainersStats · getCountriesInfo · getCountryInfo · getEndpoint · getEngagedAlerts · getFirstInterfaceId · getFlowDeviceInfo · getFlowDeviceInfoByIP · getFlowDevices · getFlowKey · getFlowsInfo · getFlowsStats · getFlowsStatus · getGroupedFlows · getHashTablesStats · getHostAttributes · getHostCountry · getHostInfo · getHostMinInfo · getHostPoolStats · getHostPoolsInfo · getHostPoolsStats · getHostUsedQuotasStats · getHostsByPort · getHostsByService · getHostsPorts · getHostsInfo · getId · getIfMac · getIfNames · getInterfaceHosts · getLocalHostsInfo · getLocalHostsInfoNoTX · getLocalHostsInfoNoTXTCP · getLocalServerPorts · getLiveASNStats · getMacDeviceTypes · getMacHosts · getMacInfo · getMacManufacturers · getMacsInfo · getMasterInterfaceId · getMaxIfSpeed · getName · getNetworkStats · getNetworksStats · getNumFlows · getNumHosts · getNumLocalHosts · getNumLocalRxOnlyHosts · getObsPointInfo · getObsPointsInfo · getPeriodicActivitiesStats · getPolicyChangeMarker · getPoolDynamicBlacklistMembers · getPoolDynamicBlacklistStats · getPodsStats · getProtocolFlowsStats · getPublicHostsInfo · getQueuesStats · getRemoteHostsInfo · getRemoteHostsInfoNoTX · getRemoteHostsInfoNoTXTCP · getRxOnlyHostsList · getSFlowDeviceInfo · getSFlowDevices · getSNMPStats · getScore · getSecsToFirstData · getStats · getStatsUpdateFreq · getThroughput · getVLANFlowsStats · getVLANInfo · getVLANsList · getVLANsInfo · getZMQFlowFieldDescr · getl7PolicyInfo · getnDPICategories · getnDPICategoryId · getnDPICategoryName · getnDPIFlowsCount · getnDPIFullProtoName · getnDPIHostStats · getnDPIProtoBreed · getnDPIProtoId · getnDPIProtoName · getnDPIProtocols · getnDPIStats · hasEBPF · hasExternalAlerts · hasVLANs · insertIPACL · insertMacACL · isBehaviourAnalysisAvailable · isBridgeInterface · isCaptureRunning · isDatabaseViewInterface · isDiscoverableInterface · isHostActive · isIdle · isLoopback · isMacActive · isMulticastMac · isPacketInterface · isPcapDumpInterface · isRunning · isSubInterface · isSyslogInterface · isValidIfId · isView · isViewed · isZMQInterface · liveCapture · listHTTPhosts · loadScalingFactorPrefs · mdnsQueueAnyQuery · mdnsQueueNameToResolve · mdnsReadQueuedResponses · name2id · periodicityMap · periodicityMapFilterList · prepareDeleteObsPoint · processFlow · radiusAccountingStart · radiusAccountingStop · radiusAccountingUpdate · refreshFlowDeviceSiteId · releaseEngagedAlerts · releaseExternalAlert · releaseTriggeredAlert · reloadCompanions · reloadDhcpRanges · reloadGwMacs · reloadHostPrefs · reloadL7Rules · reloadShapers · removeDataFromLocalHostAssets · removeIPACL · removeMacACL · resetBroadcastDomains · resetCounters · resetHostStats · resetHostTopSites · resetMacStats · resetPoolsQuotas · rrd_dequeue · rrd_enqueue · rrd_queue_length · select · serviceMap · serviceMapFilterList · serviceMapLearningStatus · serviceMapSetMultipleStatus · serviceMapSetStatus · setCachedAlertValue · setHostOperatingSystem · setHostResolvedName · setInterfaceIdleState · setPeriodicActivityProgress · stopLiveCapture · stopRunningCapture · storeTriggeredAlert · swapHostnameIPCache · triggerExternalAlert · triggerTrafficAlert · updateDirectionStats · updateDynIfaceTrafficPolicy · updateFlowsOnlyInterface · updateFlowsShapers · updateHostTrafficPolicy · updateIPReassignment · updateLbdIdentifier · updatePushFiltersSettings · updateRanking · updateSmartRecording · updateSyslogProducers · updateTopSites · updateTrafficMirrored · viewedBy