don't understand the data query 'interface.xml'

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
User avatar
belianisto
Posts: 20
Joined: Tue Feb 15, 2011 12:53 pm

don't understand the data query 'interface.xml'

Post by belianisto »

Hello everybody,
I've been reading the documentation and I still don't understand the Cacti common data query 'interface.xml', just the final part:

Code: Select all

<oid_index>.1.3.6.1.2.1.2.2.1.1</oid_index>
[...]
  <ifIndex>
    <name>Index</name>
    <method>walk</method>
    <source>value</source>
    <direction>input</direction>
    <oid>.1.3.6.1.2.1.2.2.1.1</oid>
  </ifIndex>
[...]
  <ifIP>
    <name>IP Address</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.20.1.2</oid>
  </ifIP>
The index for this data query is "ifIndex" from the table "ifTable". In the case of "<ifIndex>" is easy to understand. For example:
ifIndex.1=1
ifIndex.2=2

but is the case of "<ifIP>" that I don't understand, because the instantiation cannot be like in the previous case; this following is not correct:
ipAdEntIfIndex.1=1
ipAdEntIfIndex.2=2

because "ifIndex" is not the index for "ipTable" but "ipAdEntAddr". i.e. (this is correct)
ipAdEntIfIndex.192.168.0.56=1
ipAdEntIfIndex.192.168.0.34=2

I know the secret is in "OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$". The regular expression means "any number of characters followed of an IP and then EOF". But I don't understand step by step how it works.

?? Is it supposed that:
1-It walks ".1.3.6.1.2.1.4.20.1.2 (ipAdEntIfIndex)" so it gets for example:
ipAdEntIfIndex.192.168.0.56=1
ipAdEntIfIndex.192.168.0.34=2

2-Then, in the case of ifIndex=1 it looks for the interface 1,
ipAdEntIfIndex.192.168.0.56=1

3-The regular expression gets 192.168.0.56 ??

4-And then we see 192.168.0.56 for the interface 1 when clicking "Create graphs for this host" in Cacti ??
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: don't understand the data query 'interface.xml'

Post by gandalf »

belianisto wrote:1-It walks ".1.3.6.1.2.1.4.20.1.2 (ipAdEntIfIndex)" so it gets for example:
ipAdEntIfIndex.192.168.0.56=1
ipAdEntIfIndex.192.168.0.34=2

2-Then, in the case of ifIndex=1 it looks for the interface 1,
ipAdEntIfIndex.192.168.0.56=1

3-The regular expression gets 192.168.0.56 ??

4-And then we see 192.168.0.56 for the interface 1 when clicking "Create graphs for this host" in Cacti ??
This is quite correct
R.
User avatar
belianisto
Posts: 20
Joined: Tue Feb 15, 2011 12:53 pm

Re: don't understand the data query 'interface.xml'

Post by belianisto »

Hello,
Thank you for your reply, Gandalf. But if the regular expression means "any number of characters followed of an IP and then EOF", why do we finally have only the IP? What does it happen with the previous characters?

Have a nice day
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: don't understand the data query 'interface.xml'

Post by gandalf »

They are dropped. Like in may regexp's, () denotes that the data is preserved for subsequent use (e.g. as $1 pseudo-variable)
R.
User avatar
belianisto
Posts: 20
Joined: Tue Feb 15, 2011 12:53 pm

Re: don't understand the data query 'interface.xml'

Post by belianisto »

Thanks, I think other people may be wondering themselves the same. Parentheses serve not only to group sequences of characters, but also capturing subpatterns that may be returned to the script (backreferences)

Spanish: Los paréntesis sirven no solamente para agrupar secuencias de caracteres, sino también para capturar subpatrones que luego pueden ser devueltos al script (retroreferencias)
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests