[ixpmanager] Discrepancies between sflow hosts

Barry O'Donovan barry.odonovan at inex.ie
Tue Feb 23 09:29:38 GMT 2021


Hi Ian,

the tl;dr on this is that it appears you are mixing up discovered MAC 
addresses and configured MAC addresses.

Please see here: https://docs.ixpmanager.org/features/layer2-addresses/

This is important in the script here which determines the API endpoint:

https://github.com/inex/IXP-Manager/blob/master/tools/runtime/sflow/sflow-to-rrd-handler#L82

and the config element (macdbtype) is discussed here:

https://docs.ixpmanager.org/features/sflow-p2p/#ixpmanagerconf

I'll just comment inline below to show where this crops up:

Ian Chilton wrote on 22/02/2021 13:10:
> So, we make a call to: 
> https://ixpmanager.example.com/v4/sflow-db-mapper/learned-macs with a 
> valid API key.
> 
> Sure enough, that mac is not in the returned list!

NB: you're querying discovered / learned MAC addresses here - database 
table 'macaddress'.

> mysql> select * from l2address where mac='001f9ed20000';
> +----+-------------------+--------------+---------------------+----------+---------------------+
> | id | vlan_interface_id | mac | firstseen | lastseen | created |
> +----+-------------------+--------------+---------------------+----------+---------------------+
> | 62 | 62 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL | 2018-06-20 
> 15:47:14 |
> | 63 | 243 | 001f9ed20000 | 2018-06-20 15:44:14 | NULL | 2018-06-20 
> 15:47:14 |
> +----+-------------------+--------------+---------------------+----------+---------------------+
> 2 rows in set (0.00 sec)

NB: database table 'l2address' is for configured MAC addresses.

> So then we end up at sflowLearnedMacs():

Key here is 'learned' in the function name.

> Which uses this query:
> 
> |return $this->getEntityManager()->createQuery( "SELECT DISTINCT vli.id 
> AS vliid, ma.mac AS mac, vl.number as tag, i.id as infrastructure FROM 
> Entities\VirtualInterface vi LEFT JOIN vi.VlanInterfaces vli JOIN 
> vi.MACAddresses ma LEFT JOIN vli.Vlan vl LEFT JOIN vl.Infrastructure i 
> WHERE ma.mac IS NOT NULL AND vli.id IS NOT NULL ORDER BY vliid" 
> )->getArrayResult(); |
> 
> How can one print out the SQL that generates as a string??

Let's not go down that road, Yann is busy removing all Doctrine from IXP 
Manager right now.

But note the above query uses 'MACAddresses' which is the php / Dcotrine 
repository for the 'macaddress' table (discovered/learned addresses).

> Unable to work out how to get the exact query, I poked around the 
> database and came up with something similar…
> 
> mysql> SELECT l2.*, vli.id AS vli_id, vl.id AS vlan_id, vl.name AS vlan, 
> vl.number AS vlan_num FROM l2address l2 LEFT JOIN vlaninterface vli on 
> l2.vlan_interface_id = vli.id LEFT JOIN vlan vl ON vli.vlanid = vl.id 
> LEFT JOIN infrastructure i ON vl.infrastructureid = i.id WHERE 
> l2.mac='001f9ed20000';

Good effort but you've swapped macaddress for l2address so you're 
querying the configured rather than the discovered addresses.

> So it seems as if the /v4/sflow-db-mapper/learned-macs call might not be 
> returning all the macs it should, but I can’t quite pinpoint why….

Well it is, just not the ones I think you want 😉

> Any ideas?

Sounds like you need:

    macdbtype = configured

in the config file per:

https://docs.ixpmanager.org/features/sflow-p2p/#ixpmanagerconf


  - Barry






More information about the ixpmanager mailing list