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.
- Return
- a table (numMacs, nextSlot, macs) on success, nil otherwise.
- 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”.
-
function
getMacInfo
(string mac)¶ Retrieve information about a specific L2 device.
- Return
- device information on success, nil otherwise.
- Parameters
mac
: the mac to query information for.
-
function
getMacHosts
(string mac)¶ Get the L2 hosts which have the specified MAC address.
- Return
- a table containing the matching hosts.
- Parameters
mac
: the mac.
-
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.
- Return
- table (manufacturer -> num_active_devices) on success, nil otherwise.
- 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”.
-
function
setMacOperatingSystem
(string mac, int os_id)¶ Set L2 device operating system.
- Parameters
mac
: device MAC addressos_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.
- Return
- table (device_type -> num_active_devices) on success, nil otherwise.
- Parameters
maxHits
: maximum number of returned items.sourceMacsOnly
: if true, only sender devices will be returnmanufacturer
: filter by device manufacturer.ed.location_filter
: filter by device location, “lan” or “wan”.
-
function
findMacPool
(string mac)¶ Get the pool of the specified L2 device. This also works for inactive devices. @oaram mac L2 device MAC address.
- Return
- the device pool id on success, nil otherwise.
- Note
- nil is also returned for devices which do not belong to any pool.
-
function
resetMacStats
(string mac)¶ Reset the stats (e.g. traffic and application data) for the given device. @oaram mac L2 device MAC address.
- Return
- true if the reset request was successful, false otherwise.
- Note
- The device must be active in order to reset it. See also interface.resetStats
-
function
deleteMacData
(string mac)¶ Delete all the data stored for the given host. @oaram mac L2 device MAC address.
- Return
- true if the delete request was successful, false otherwise.