I've been beating my head on this one for a while now and can't seem to figure out the right incantations of rewrite_index and oid_rewrite_* to make this work.
What I'm trying to accomplish is to get the bgp remote ASN that's stored in .1.3.6.1.2.1.15.3.1.9 as an input field in an SNMP data query and have it associated with an interface ifIndex. The problem is that this OID is indexed using the bgp neighbor address. The neighbor address is available as a value at .1.3.6.1.2.1.15.3.1.7 and the local address (which is on the interface I want to ultimately use) is available .1.3.6.1.2.1.15.3.1.5 indexed by the neighbor address.
I've tried using the information in the arp table at .1.3.6.1.2.1.4.22.1.1 to get the neighbor address associated with the ifIndex, but because every address (local and remote) appear in the arp table with the ifIndex, this only works when the neighbor address appears second in the arp table.
Does anyone have any clues on how I can accomplish this?
trying to associate bgp neighbor with interface
Moderators: Developers, Moderators
Re: trying to associate bgp neighbor with interface
so this gets part of the job done:
But the problem is that walking .1.3.6.1.2.1.4.22.1.1 gives multiple values for each interface. The index is 'ifIndex.IPaddress' for every IP address that is in the arp table on that interface (usually only 2, local and remote since these are routers with point-to-point interfaces). The value for walking this OID is the ifIndex. So the result is only the last entry is kept in the table indexed as ifIndex. Unfortunately, I can't depend on the address I need being the last one in the list for each interface.
So I'm looking for a way to find the ifIndex of the values associated with each bgp neighbor listed at OID .1.3.6.1.2.1.15.3.1.7 (or the index, it's the same thing in this case), and index them by interface ifIndex.
This is a new installation of cacti version 1.2.16 if that makes any difference. I need this field so I can automate adding graphs. I'm open to other ways of getting this information associated with interfaces, even an external inventory would work.
Code: Select all
<ifnei>
<name>neighbor</name>
<method>walk</method>
<source>OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.4.22.1.1</oid>
</ifnei>
<ifbgpnei>
<name>bgp neighbor</name>
<method>get</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.15.3.1.9</oid>
<rewrite_index>|query_ifnei|</rewrite_index>
</ifbgpnei>
So I'm looking for a way to find the ifIndex of the values associated with each bgp neighbor listed at OID .1.3.6.1.2.1.15.3.1.7 (or the index, it's the same thing in this case), and index them by interface ifIndex.
This is a new installation of cacti version 1.2.16 if that makes any difference. I need this field so I can automate adding graphs. I'm open to other ways of getting this information associated with interfaces, even an external inventory would work.
Re: trying to associate bgp neighbor with interface
So far, nothing I've tried has worked out to get the bgp neighbor IP aligned with the interface ifIndex.
It's pretty clear that I have no idea how to use oid_rewrite_pattern and oid_rewrite_replacement.
I'm starting to think the only way to get this done is with a custom data query script. But I'm a little worried about going that path for all of my SNMP data collections since my goal is to be polling a lot of large routers and that scale could be a concern on the scripted side vs using a spine collector.
I'm hoping someone has an idea for how to combine this bgp neighbor information as an input field with SNMP collected interface stats so I can automate managing graphs based on this criteria.
It's pretty clear that I have no idea how to use oid_rewrite_pattern and oid_rewrite_replacement.
I'm starting to think the only way to get this done is with a custom data query script. But I'm a little worried about going that path for all of my SNMP data collections since my goal is to be polling a lot of large routers and that scale could be a concern on the scripted side vs using a spine collector.
I'm hoping someone has an idea for how to combine this bgp neighbor information as an input field with SNMP collected interface stats so I can automate managing graphs based on this criteria.
Re: trying to associate bgp neighbor with interface
It's been interesting having this conversation with myself
But I'm hoping these updates will either give someone an idea that I haven't thought of or may help someone else in the future...
I've been able to do some manual manipulations to get what I want.
I've added this field to the interfaces.xml:
and created a new data query with the following xml:
Then I can manually manipulate the database as follows (formatted to be more readable):
This does have the limitation of only one BGP remote ASN per interface ifIndex, but meets my needs for the point-to-point links I manage (this won't work if you peer at an IX for example, or loopback peering, or in other cases where you have multiple bgp neighbor ASNs per interface).
What I'm hoping for now is to be able to automate that bit of SQL to execute after both of the data queries complete getting data from the device and before the automation for graph creation is triggered when hosts get re-indexed. I've looked a bit at the hook registration for plugin development, but it's not yet clear to me which is the right hook to use for this.
But I'm hoping these updates will either give someone an idea that I haven't thought of or may help someone else in the future...
I've been able to do some manual manipulations to get what I want.
I've added this field to the interfaces.xml:
Code: Select all
<ifbgpas>
<name>bgp neighbor</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.15.3.1.9</oid>
</ifbgpas>
Code: Select all
<bgp>
<name>Get SNMP BGP</name>
<description>Queries a host for a list of monitorable BGP</description>
<oid_index>.1.3.6.1.2.1.15.3.1.5</oid_index>
<oid_index_parse>OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$</oid_index_parse>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>
<fields>
<ifbgpnei>
<name>Index</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.15.3.1.5</oid>
</ifbgpnei>
<ifbgpas>
<name>bgp neighbor</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.15.3.1.9</oid>
</ifbgpas>
</fields>
</bgp>
Code: Select all
delete from host_snmp_cache where field_name="ifbgpas" and snmp_query_id=1;
insert into host_snmp_cache
select IP.host_id, IP.snmp_query_id, bgp.field_name, bgp.field_value, IP.snmp_index, bgp.oid, bgp.present, bgp.last_updated
from host_snmp_cache as bgp
join host_snmp_cache as nei using (host_id)
join host_snmp_cache as IP using (host_id)
where bgp.field_name="ifbgpas"
and nei.field_name="ifbgpnei"
and IP.field_name="ifIP"
and nei.field_value=IP.field_value
and bgp.snmp_index=nei.snmp_index
group by snmp_index;
What I'm hoping for now is to be able to automate that bit of SQL to execute after both of the data queries complete getting data from the device and before the automation for graph creation is triggered when hosts get re-indexed. I've looked a bit at the hook registration for plugin development, but it's not yet clear to me which is the right hook to use for this.
Who is online
Users browsing this forum: No registered users and 4 guests