be more flexable with oid/regex output in XML files

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

be more flexable with oid/regex output in XML files

Post by sodium »

I have seen several MIB's where an index is used to point to other locations in the mib with a little extension (of 2 numbers)

example: (juniper mib)

.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.<index>.<peer_index_#>

and now you have to use <index> on the info you want but now with an addition of 2 numbers

like:

.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.<peer_index_#>.1.1
.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.<peer_index_#>.1.1
.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.<peer_index_#>.1.1
.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.<peer_index_#>.1.1

if we could use back references from regex in XML like this:

<interface>
<name>Juniper - BGP Peer Prefix Stats</name>
<oid_index>.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14</oid_index>
<oid_index_parse>OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\.1\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\.([0-9]{1,2})$</oid_index_parse>
<index_order>Index</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>

<fields>
<Index>
<name>Index</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2636.5.1.1.2.6.2.1</oid>
</Index>

<jnxBgpM2PrefixInPrefixes>
<name>Prefixes In</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.$3.1.1</oid>
</jnxBgpM2PrefixInPrefixes>
<jnxBgpM2PrefixInPrefixesAccepted>
<name>Accepted Prefixes</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.$3.1.1</oid>
</jnxBgpM2PrefixInPrefixesAccepted>
<jnxBgpM2PrefixOutPrefixes>
<name>Outbound Prefixes</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.$3.1.1</oid>
</jnxBgpM2PrefixOutPrefixes>
</fields>
</interface>

I do not have to do this in a seperate perl script...

and the Centillion MIB has the same problem -- so I think it's more common....
User avatar
twelzy
Cacti User
Posts: 83
Joined: Wed Mar 30, 2005 6:48 pm
Location: BRAZIL/Brasilia

Post by twelzy »

Hi sodium!

That's one of the features that I requested in 'Improve the "power" of REGEXPs in Data Queries' (http://forums.cacti.net/viewtopic.php?t=13949)!
(No answer until now...)

Still waiting...

(And sorry for my poor English...)
Thanks in advance!
(And sorry for my poor English...)
_______________________________________
twelzy (Enio Sanches)
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

I don't know how we can make it "better", as we are using the regex functions that PHP provides.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Post by sodium »

rony wrote:I don't know how we can make it "better", as we are using the regex functions that PHP provides.
to implement this:

<oid>.1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.$regs[3].1.1</oid>

it's simple regex 'back reference' stuff (it's available in PHP see http://nl2.php.net/manual/en/ref.regex.php )
danbeck
Posts: 30
Joined: Tue Jun 20, 2006 12:08 pm
Location: Huntsville, Alabama
Contact:

Post by danbeck »

rony wrote:I don't know how we can make it "better", as we are using the regex functions that PHP provides.
How about using the preg functions instead of POSIX only?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

danbeck wrote:
rony wrote:I don't know how we can make it "better", as we are using the regex functions that PHP provides.
How about using the preg functions instead of POSIX only?
Without looking at the source code, I don't recall what it uses.. :)
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
twelzy
Cacti User
Posts: 83
Joined: Wed Mar 30, 2005 6:48 pm
Location: BRAZIL/Brasilia

Post by twelzy »

Hi sodium, rony and danbeck,

The actual regexp functions used in <CACTI_PATH>/lib/data_query.php file are POSIX Regular Expressions.

I think that both POSIX Regular Expressions functions and PCRE (Perl-Compatible Regular Expression) functions could resolve this issue.

The problem here is that with the actual <CACTI_PATH>/lib/data_query.php file we can't do:
  • - "VALUE/REGEXP" in the <oid_index_parse> field, with the possibility to match more than one value and use these values in the <source> field;
    - "VALUE/REGEXP" in the <source> field, with the possibility to match and use these values;
    - "VALUE/REGEXP_REPLACE" in the <source> field, with the possibility to match and replace more than one value.
In a previous post of mine (http://forums.cacti.net/viewtopic.php?t=13949) I give this example:
Example: Internet Links in our Border Routers

We have 2 kinds of agreements in our Internet Links: transit and peering links.
And we classify these links in 2 categories: national and international links.
These classifications are shortened in the ifAlias as following:

(TRANS|PEER)_(NAC|INTL)_.*

We have here 2 input fields: AGGREMENT and NATIONALITY.
So we need to match and replace:

TRANS by Transit, in the AGGREMENT input field;
PEER by Peering, in the AGGREMENT input field;
NAC by National, in the NATIONALITY input field;
INTL by International, in the NATIONALITY input field,

respectively!
In this case, we need a "VALUE/REGEXP_REPLACE" in the <source> field, with the possibility to match and replace more than one value!

And if we want to make a Data/Graph template that will list only these Internet links of our Border Routers, we need a "VALUE/REGEXP" in the <oid_index_parse> field, that matches only the ifAlias that begin with (TRANS|PEER)!
I'm not a PHP expert. I have 6 years of experience in shell scripting. Now I'm studing PHP to convert my shell scripts to PHP scripts.
rony, if you need some help to write/test the code I can dedicate some of my time to this task.

Thanks in advance!
(And sorry for my poor English...)
Thanks in advance!
(And sorry for my poor English...)
_______________________________________
twelzy (Enio Sanches)
User avatar
twelzy
Cacti User
Posts: 83
Joined: Wed Mar 30, 2005 6:48 pm
Location: BRAZIL/Brasilia

Post by twelzy »

Any feedback...?!

Thanks in advance!
(And sorry for my poor English...)
Thanks in advance!
(And sorry for my poor English...)
_______________________________________
twelzy (Enio Sanches)
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Post by sodium »

The silence is deafining... :-)
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

It's just that the developers are indisposed at the moment. I can't seem to get any time for Cacti lately. I hope that changes soon....

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
sebastianw
Posts: 5
Joined: Tue Jul 31, 2007 4:24 am

Post by sebastianw »

Hi! I also asked for a feature like that in

http://forums.cacti.net/viewtopic.php?t=22586

I use Cacti with Cisco routers and I would greatly benefit from a feature which would let me use a suffix for some OIDs (see my original post for an example).
sh0x
Posts: 32
Joined: Thu Aug 30, 2007 6:12 pm
Location: California

Post by sh0x »

I could use this feature as well. I'm finding this to be a common issue with many Cisco OIDs and would imagine its the same for other vendors MIBs as well.

For example I'm trying to poll frame-relay statistics and my indexes are:

14.100
14.200
19.100
19.200


Then I poll a bunch of OIDs and one of my OIDs adds a .1 to the end so I can't poll that particular OID.

14.100.1
14.200.1
19.100.1
19.200.1


I'm finding this more of an issue when I try to reference another OID for a descriptive information. I'm new to regex though. Can I do a regex to ignore the .1 if it exists, but to still work if it doesn't have a .1?

Thanks,
sh0x
Syngress
Posts: 26
Joined: Tue Apr 24, 2007 9:17 am

Post by Syngress »

Hi,

I am having the same issue as the original poster in that the OID I want use has a suffix to the index

http://forums.cacti.net/viewtopic.php?t=23596 is where I posted my original issue, any idea if this will get fixed as a lot of our new network equipment (Juniper & Foundry) use these sort of OID's.

Syngess
Ragnar
Posts: 5
Joined: Thu Aug 04, 2005 10:33 am

Post by Ragnar »

also requesting this feature, we have quite a few pieces of hardware (Cisco routers, MetaSwitch softswitch) where the developers have suffixed an OID, instead of prefixing into a table like they should have...

Anyone have a workaround/patch for this? We only have a single digit to deal with on the end (.1 = current 5 mins, .2 = prev 5 mins, .3 = current 15 mins, etc), my cacti-fu is weak though, unless it's hacking together composite bandwidth graphs...

Sample of snmpwalk output of the OID's I'm trying to graph:

Code: Select all

$ grep '.1.1.1.1 = ' isupdeststatisticswalk.txt 
METASWITCH-MIB::iSUPRemSigDestStatsNumCircsCfgd.1.7.100.101.102.97.117.108.116.1.1.1.1 = Gauge32: 432
METASWITCH-MIB::iSUPRemSigDestStatsNumCircsAvail.1.7.100.101.102.97.117.108.116.1.1.1.1 = Gauge32: 432
METASWITCH-MIB::iSUPRemSigDestStatsNumCircsInUse.1.7.100.101.102.97.117.108.116.1.1.1.1 = Gauge32: 108
1.7.100.101.102.97.117.108.116.1.1.1 is the index, grabbed from a different portion of the MIB.
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Does anyone have a patch? It won't make it into Saturday's release, but...

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests