Get method and value/regexp in snmp data query

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

Moderators: Developers, Moderators

Post Reply
icewind
Posts: 1
Joined: Sat Aug 16, 2014 3:33 pm

Get method and value/regexp in snmp data query

Post by icewind »

Hi.

I wanna use SNMP data query for getting module statuses and their names in Cisco VSS. I use one OID to retrieve indexes and module statuses and completely different OID to get their names. The problem is the latter OID returns much larger list of names (it contains all desired modules and a lot of unnecessary ones). I tried to solve this problem by using get method in "method" field of XML template and it worked. But then the other problem occured. I'm using VALUE/REGEXP in "source" field to parse a string containing module name (I keep first 3 words). It worked while using walk method, but does not with get method. If I simply use value as a source, everything is fine except that modules' names are too long, so I guess something is wrong with combining get method and VALUE/REGEXP.

Any ideas? :) Can the first problem (having too many indexes for OID returning names) be solved with walk method?

My template:

Code: Select all

<?xml version="1.0"?>

<interface>

    <name>VSS modules status</name>
    <description>VSS modules status</description>
    <oid_index>.1.3.6.1.4.1.9.9.117.1.2.1.1.2</oid_index>
    <oid_index_parse>OID/REGEXP:.*\.([0-9]+)$</oid_index_parse>
    <index_order>VSSmodule_index:VSSmodule_name:VSSmodule_statusIN</index_order>
    <index_order_type>numeric</index_order_type>

    <fields>
      
        <VSSmodule_index>
            <name>Index</name>
            <source>index</source>
            <direction>input</direction>
        </VSSmodule_index>
        <VSSmodule_name>
            <name>Module Name</name>
            <method>get</method>
            <source>VALUE/REGEXP:(^.{10}[-A-Za-z0-9]*).*$</source>
            <direction>input</direction>
            <oid>.1.3.6.1.2.1.47.1.1.1.1.2</oid>
        </VSSmodule_name>

        <VSSmodule_statusIN>
            <name>Module status</name>
            <method>walk</method>
            <source>value</source>
            <direction>input</direction>
            <oid>.1.3.6.1.4.1.9.9.117.1.2.1.1.2</oid>
        </VSSmodule_statusIN>

        <VSSmodule_status>
            <name>Module status</name>
            <method>walk</method>
            <source>value</source>
            <direction>output</direction>
            <oid>.1.3.6.1.4.1.9.9.117.1.2.1.1.2</oid>
        </VSSmodule_status>
      
    </fields>

</interface>
This is what I get with verbosing the query if using walk method (it queries also unnecessary indexes for module name):
+ Index found at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.8009' value: '2'
+ Index found at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.9000' value: '2'
+ Index found at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.9009' value: '2'
+ Index found at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.10000' value: '2'
+ Index found at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.10007' value: '2'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.1000' results: '1000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.1009' results: '1009'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.2000' results: '2000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.2007' results: '2007'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.3000' results: '3000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.3013' results: '3013'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.3018' results: '3018'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.4000' results: '4000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.5000' results: '5000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.5009' results: '5009'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.7000' results: '7000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.7013' results: '7013'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.7018' results: '7018'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.8000' results: '8000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.8009' results: '8009'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.9000' results: '9000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.9009' results: '9009'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.10000' results: '10000'
+ index_parse at OID: '1.3.6.1.4.1.9.9.117.1.2.1.1.2.10007' results: '10007'
+ Inserting index data for field 'VSSmodule_index' [value='1000']
+ Inserting index data for field 'VSSmodule_index' [value='1009']
+ Inserting index data for field 'VSSmodule_index' [value='2000']
+ Inserting index data for field 'VSSmodule_index' [value='2007']
+ Inserting index data for field 'VSSmodule_index' [value='3000']
+ Inserting index data for field 'VSSmodule_index' [value='3013']
+ Inserting index data for field 'VSSmodule_index' [value='3018']
+ Inserting index data for field 'VSSmodule_index' [value='4000']
+ Inserting index data for field 'VSSmodule_index' [value='5000']
+ Inserting index data for field 'VSSmodule_index' [value='5009']
+ Inserting index data for field 'VSSmodule_index' [value='7000']
+ Inserting index data for field 'VSSmodule_index' [value='7013']
+ Inserting index data for field 'VSSmodule_index' [value='7018']
+ Inserting index data for field 'VSSmodule_index' [value='8000']
+ Inserting index data for field 'VSSmodule_index' [value='8009']
+ Inserting index data for field 'VSSmodule_index' [value='9000']
+ Inserting index data for field 'VSSmodule_index' [value='9009']
+ Inserting index data for field 'VSSmodule_index' [value='10000']
+ Inserting index data for field 'VSSmodule_index' [value='10007']
+ Located input field 'VSSmodule_name' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.47.1.1.1.1.2'
+ Found item [VSSmodule_name='Cisco System'] index: 1 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 2 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 3 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 4 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 5 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 6 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 7 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 8 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 9 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 10 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 11 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 Cisco'] index: 12 [from regexp value parse]
+ Found item [VSSmodule_name='Chassis 1 fan-tray'] index: 13 [from regexp value parse]
Image
stromcruncher
Posts: 1
Joined: Tue Nov 18, 2014 6:21 am

Re: Get method and value/regexp in snmp data query

Post by stromcruncher »

Were you able to solve this issue? I have a similar:
<interface>
<name>Get SNMP Rapid City Optical Modules</name>
<description>Queries a host for a list of monitorable optical interfaces</description>
<oid_index>.1.3.6.1.4.1.2272.1.71.1.1.1</oid_index>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>

<fields>
<rcPlugOptModPortIndex>
<name>Index</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2272.1.71.1.1.1</oid>
</rcPlugOptModPortIndex>
<rcPlugOptModConnectorType>
<name>Type</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2272.1.71.1.1.5</oid>
</rcPlugOptModConnectorType>
<rcPlugOptModWaveLength>
<name>WaveLength</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2272.1.71.1.1.16</oid>
</rcPlugOptModWaveLength>

<rcIfDescr>
<name>rcIfDescr</name>
<method>get</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.2.2.1.2</oid>
</rcIfDescr>

...

Gives the debug output:
+ Running data query [10].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/rcPlugOptMod.xml'
+ XML file parsed ok.
+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.2272.1.71.1.1.1' Index Count: 4
+ Index found at OID: '1.3.6.1.4.1.2272.1.71.1.1.1.192' value: '192'
+ Index found at OID: '1.3.6.1.4.1.2272.1.71.1.1.1.228' value: '228'
+ Index found at OID: '1.3.6.1.4.1.2272.1.71.1.1.1.229' value: '229'
+ Index found at OID: '1.3.6.1.4.1.2272.1.71.1.1.1.231' value: '231'
+ Located input field 'rcPlugOptModPortIndex' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.2272.1.71.1.1.1'
+ Found item [rcPlugOptModPortIndex='192'] index: 192 [from value]
+ Found item [rcPlugOptModPortIndex='228'] index: 228 [from value]
+ Found item [rcPlugOptModPortIndex='229'] index: 229 [from value]
+ Found item [rcPlugOptModPortIndex='231'] index: 231 [from value]
+ Located input field 'rcPlugOptModConnectorType' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.2272.1.71.1.1.5'
+ Found item [rcPlugOptModConnectorType='Gbic1000BaseT'] index: 192 [from value]
+ Found item [rcPlugOptModConnectorType='10GbCX'] index: 228 [from value]
+ Found item [rcPlugOptModConnectorType='10GbCX'] index: 229 [from value]
+ Found item [rcPlugOptModConnectorType='GbicSx'] index: 231 [from value]
+ Located input field 'rcPlugOptModWaveLength' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.2272.1.71.1.1.16'
+ Found item [rcPlugOptModWaveLength='0'] index: 192 [from value]
+ Found item [rcPlugOptModWaveLength='1024'] index: 228 [from value]
+ Found item [rcPlugOptModWaveLength='3072'] index: 229 [from value]
+ Found item [rcPlugOptModWaveLength='850'] index: 231 [from value]
+ Located input field 'rcIfDescr' [get]
+ Executing SNMP get for data @ '.1.3.6.1.2.1.2.2.1.2.192' [value='Gbic1000BaseT Port 1/1 Name']
+ Executing SNMP get for data @ '.1.3.6.1.2.1.2.2.1.2.228' [value='10GbCX Port 1/37 Name']
+ Executing SNMP get for data @ '.1.3.6.1.2.1.2.2.1.2.229' [value='10GbCX Port 1/38 Name']
+ Executing SNMP get for data @ '.1.3.6.1.2.1.2.2.1.2.231' [value='1000GbicSx Port 1/40 Name']

I would like to have the interface descrition used in the graphs.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest