noc.bi.models.mac

Module Contents

class noc.bi.models.mac.MAC

Bases: noc.core.clickhouse.model.Model

MAC address table snapshot

Common queries:

Last seen MAC location:

SELECT timestamp, object, interface FROM mac WHERE

date >= ? AND mac = ?

AND uni = 1

ORDER BY timestamp DESC LIMIT 1;

All MAC locations for date interval:

SELECT timestamp, object, interface FROM mac WHERE

date >= ? AND mac = ? AND uni = 1;
class Meta

Bases: object

db_table = mac
engine
date
ts
managed_object
mac
interface
interface_profile
segment
vlan
is_uni
mac_filter(self, query, offset=0, limit=400, convert_mac=False)

Filter interface to MACDB :param query: Query to MACDB :param query: dict :param offset: Offset output data :type offset: int :param limit: Offset output data :type limit: limit data count :param convert_mac: Conver MAC from int to str represent :return: list query result from MACDB select max(ts), managed_object, interface, vlan from mac where like(MACNumToString(mac), ‘A0:AB:1B%’) group by managed_object, interface, vlan;

get_neighbors_by_mac(self, macs, mos=None)

Return list BI ID MO by interfaces. Filter mo by macs :param macs: list(int) :param mos: list(int) :return: Dict {mo_a: {iface1: [mo1, mo2], iface2: [mo3, mo4], …}, mo_b: …}

get_mac_history(self, mac)