2.4. MACs API
The MACs API exposes functions to query and manage ntopng L2 devices.
Functions
-
function getMacsInfo(string sortColumn = "column_mac", int maxHits = 32768, int toSkip = 0, bool a2zSortOrder = true, bool sourceMacsOnly = false, string manufacturer = nil, int pool_filter = nil, int devtype_filter = nil, string location_filter = nil)
Retrieve active L2 devices information.
Note
it’s better to use the more efficient helper
callback_utils.getDevicesIterator
for generic devices iteration.- Parameters:
sortColumn – column to use for sorting.
maxHits – maximum number of returned items.
toSkip – number of initial items to skip after sorting.
a2zSortOrder – if true, enable ascending sort order, otherwise order is descending.
sourceMacsOnly – if true, only sender devices will be returned.
manufacturer – filter by device manufacturer.
pool_filter – filter by host pool ID.
devtype_filter – filter by device type.
location_filter – filter by device location, “lan” or “wan”.
- Returns:
a table (numMacs, nextSlot, macs) on success, nil otherwise.
-
function getMacInfo(string mac)
Retrieve information about a specific L2 device.
- Parameters:
mac – the mac to query information for.
- Returns:
device information on success, nil otherwise.
-
function getMacHosts(string mac)
Get the L2 hosts which have the specified MAC address.
- Parameters:
mac – the mac.
- Returns:
a table containing the matching hosts.
-
function getMacManufacturers(int maxHits = 32768, bool sourceMacsOnly = false, int devtype_filter = nil, string location_filter = nil)
Get a list of MAC manufacturers from active devices.
- Parameters:
maxHits – maximum number of returned items.
sourceMacsOnly – if true, only sender devices will be returned.
devtype_filter – filter by device type.
location_filter – filter by device location, “lan” or “wan”.
- Returns:
table (manufacturer -> num_active_devices) on success, nil otherwise.
-
function setMacOperatingSystem(string mac, int os_id)
Set L2 device operating system.
- Parameters:
mac – device MAC address
os_id – the operating system id to set.
-
function getMacDeviceTypes(int maxHits = 32768, bool sourceMacsOnly = false, string manufacturer = nil, string location_filter = nil)
Get a list of device types from active devices.
- Parameters:
maxHits – maximum number of returned items.
sourceMacsOnly – if true, only sender devices will be return
manufacturer – filter by device manufacturer.ed.
location_filter – filter by device location, “lan” or “wan”.
- Returns:
table (device_type -> num_active_devices) on success, nil otherwise.
-
function findMacPool(string mac)
Get the pool of the specified L2 device. This also works for inactive devices. @oaram mac L2 device MAC address.
Note
nil is also returned for devices which do not belong to any pool.
- Returns:
the device pool id on success, nil otherwise.
-
function resetMacStats(string mac)
Reset the stats (e.g. traffic and application data) for the given device. @oaram mac L2 device MAC address.
Note
The device must be active in order to reset it. See also interface.resetStats
- Returns:
true if the reset request was successful, false otherwise.
-
function deleteMacData(string mac)
Delete all the data stored for the given host. @oaram mac L2 device MAC address.
- Returns:
true if the delete request was successful, false otherwise.