Cacti SNMP query script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
Tony Kandaya
Posts: 3
Joined: Fri Mar 17, 2006 9:26 am

Cacti SNMP query script

Post by Tony Kandaya »

I am struggling with setting up a regular expression that ignores the first 14 (.1.3.6.1.4.1.9.9.161.1.4.1.1.3) OIDs and indexes the rest of the fields, this would enable the creation of a variable length index.

*********************
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.4.86.68.71.72}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.5.86.82.80.45.49}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.5.86.82.80.45.50}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.6.86.83.68.71.72.49}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.9.86.82.80.45.49.45.53.53.52}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.9.86.82.80.45.50.45.53.53.52}
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3 {.0.11.86.83.68.71.72.49.45.66.79.79.77}

** {} means that these are the fields I need in creating my variable length index

********************************

<vservers>
<name>Get vservers Connection Information</name>
<description>Queries a host for a list of configured vservers</description>
<oid_index>.1.3.6.1.4.1.9.9.161.1.4.1.1.3</oid_index>
<oid_index_parse>OID/REGEXP:[^(\.[0-9]{1,3})] {14,0}\* </oid_index_parse>
<index_order>slbVirtualIndex</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>

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



Thanks
Tony
tgk
Posts: 28
Joined: Sat Mar 11, 2006 10:46 pm

Post by tgk »

Your oid_index_parse should look like this:

<oid_index_parse>OID/REGEXP:.*\.161\.1\.4\.1\.1\.3\.(.*)$</oid_index_parse>


or even:

<oid_index_parse>OID/REGEXP:\.1\.3\.6\.1\.4\.1\.9\.9\.161\.1\.4\.1\.1\.3\.(.*)$</oid_index_parse>


Your parse is missing the part in parenthesis, which is the one that cacti will use as an index... and it has the "^" symbol, which indicates the beginning of the OID, inside the loop:

<oid_index_parse>OID/REGEXP:^[\.[0-9]{1,3})] {14,0}\.(.*)$</oid_index_parse>
Tony Kandaya
Posts: 3
Joined: Fri Mar 17, 2006 9:26 am

Post by Tony Kandaya »

Thanks for you input, after a couple of trial and errors, I was able to get it working without any () brackets apart from the (.*) used for matching the variable length fields.

<vservers>
<name>Get vservers Connection Information</name>
<description>Queries a host for a list of configured vservers</description>
<oid_index>.1.3.6.1.4.1.9.9.161.1.4.1.1.3</oid_index>
<oid_index_parse>OID/REGEXP:^\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(.*)$</oid_index_parse>
<index_order>slbVirtualIndex</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>


Thanks
Tony
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests